MCPcopy Create free account
hub / github.com/TimMcCool/scratchattach / favorite

Method favorite

scratchattach/site/project.py:527–541  ·  view source on GitHub ↗

Posts a favorite on the project. You can only use this function if this object was created using :meth:`scratchattach.session.Session.connect_project`

(self)

Source from the content-addressed store, hash-verified

525 raise exceptions.APIError(str(r))
526
527 def favorite(self):
528 """
529 Posts a favorite on the project. You can only use this function if this object was created using :meth:`scratchattach.session.Session.connect_project`
530 """
531 session = self._assert_auth()
532 r = requests.post(
533 f"https://api.scratch.mit.edu/proxy/projects/{self.id}/favorites/user/{session.username}",
534 headers=self._headers,
535 cookies=self._cookies,
536 ).json()
537 if "userFavorite" in r:
538 if r["userFavorite"] is False:
539 self.favorite()
540 else:
541 raise exceptions.APIError(str(r))
542
543 def unfavorite(self):
544 """

Callers

nothing calls this directly

Calls 3

jsonMethod · 0.80
postMethod · 0.80
_assert_authMethod · 0.45

Tested by

no test coverage detected