@@ -442,68 +442,6 @@ def get_resource_urls():
442442 return requests .get ("https://resources.scratch.mit.edu/localized-urls.json" ).json ()
443443
444444
445- # --- ScratchTools endpoints ---
446- def scratchtools_online_status (username : str ) -> bool | None :
447- """
448- Get the online status of an account.
449- :return: Boolean whether the account is online; if they do not use scratchtools, return None.
450- """
451- data = requests .get (f"https://data.scratchtools.app/isonline/{ username } " ).json ()
452-
453- if data ["scratchtools" ]:
454- return data ["online" ]
455- else :
456- return None
457-
458-
459- def scratchtools_beta_user (username : str ) -> bool :
460- """
461- Get whether a user is a scratchtools beta tester (I think that's what it means)
462- """
463- return requests .get (f"https://data.scratchtools.app/isbeta/{ username } " ).json ()["beta" ]
464-
465-
466- def scratchtools_display_name (username : str ) -> str | None :
467- """
468- Get the display name of a user for scratchtools. Returns none if there is no display name or the username is invalid
469- """
470- return requests .get (f"https://data.scratchtools.app/name/{ username } " ).json ().get ("displayName" )
471-
472-
473- @dataclass (init = True , repr = True )
474- class ScratchToolsTutorial :
475- title : str
476- description : str = field (repr = False )
477- id : str
478-
479- @classmethod
480- def from_json (cls , data : dict [str , str ]) -> ScratchToolsTutorial :
481- return cls (** data )
482-
483- @property
484- def yt_link (self ):
485- return f"https://www.youtube.com/watch?v={ self .id } "
486-
487-
488- def scratchtools_tutorials () -> list [ScratchToolsTutorial ]:
489- """
490- Returns a list of scratchtools tutorials (just yt videos)
491- """
492- data_list = requests .get ("https://data.scratchtools.app/tutorials/" ).json ()
493- return [ScratchToolsTutorial .from_json (data ) for data in data_list ]
494-
495-
496- def scratchtools_emoji_status (username : str ) -> str | None :
497- return requests .get (f"https://data.scratchtools.app/status/{ username } " ).json ().get ("status" ,
498- '🍪' ) # Cookie is the default status, even if the user does not use ScratchTools
499-
500-
501- def scratchtools_pinned_comment (project_id : int ) -> dict [str , str | int ]:
502- data = requests .get (f"https://data.scratchtools.app/pinned/{ project_id } /" ).json ()
503- # Maybe use this info to instantiate a partial comment object?
504- return data
505-
506-
507445# --- Misc ---
508446# I'm not sure what to label this as
509447def scratch_team_members () -> dict :
0 commit comments