File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- # aka the main file
1+ # main file
2+ import urllib .request
3+ import json
4+ import os
5+
6+ # get username
7+ username = input ("Enter Scratch username: " )
8+
9+ while True :
10+ # get api wrapping utility
11+ utility = input ("Utility [user-projects-wrapper, exit]: " )
12+
13+ if utility == "user-projects-wrapper" :
14+ # url
15+ url = f"https://api.scratch.mit.edu/users/{ username } /projects/"
16+
17+ # fetch daaataaaa
18+ response = urllib .request .urlopen (url )
19+ data = json .loads (response .read ())
20+
21+ # display info
22+ for project in data :
23+ title = project .get ('title' , 'N/A' )
24+ description = project .get ('description' , 'No description available' )
25+ loves = project .get ('stats' , {}).get ('loves' , 0 )
26+ favorites = project .get ('stats' , {}).get ('favorites' , 0 )
27+ views = project .get ('stats' , {}).get ('views' , 0 )
28+ remixes = project .get ('remix' , {}).get ('count' , 0 )
29+
30+ print ("=" * 50 )
31+ print ("PROJECT NAME" )
32+ print ("-" * 50 )
33+ print (f"{ title } " )
34+
35+ print ("\n DESCRIPTION" )
36+ print ("-" * 50 )
37+ print (f"{ description } " )
38+
39+ print ("\n STATS" )
40+ print ("-" * 50 )
41+ print (f"Hearts: { loves } " )
42+ print (f"Stars: { favorites } " )
43+ print (f"Views: { views } " )
44+ print (f"Remixes: { remixes } " )
45+ print ("=" * 50 )
46+ print ("\n " )
47+ if utility == "exit" :
48+ os .exit ()
49+ else :
50+ print ("thats not an option right now!" )
You can’t perform that action at this time.
0 commit comments