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)
| 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 | """ |
nothing calls this directly
no test coverage detected