Skip to content

Conversation

FAReTek1
Copy link
Collaborator

@FAReTek1 FAReTek1 commented Oct 29, 2024

The scratch API does not provide an endpoint to fetch the list of projects loved by a given user. However, the scratch website does actually have a hidden link that displays the list of projects loved by a user as well as the number of projects loved by said user: https://scratch.mit.edu/projects/all/<user>/loves/
This is most likely a legacy feature from an earlier version of the scratch website.

This pull requests introduces the User.loves() and User.loves_count() functions that parse this page and return a list of project objects and the number of loved projects respectively.

NOTE: Since the webpage only provides some of the detail for the projects compared to the detail provided by the API for projects, so the Project objects that are instantiated contain less detail.
The parameter get_full_project can be set to True to make a web request for each project to fully instantiate it, using the Project.update() method.

(cherry picked from commit 41b3ecc)
(cherry picked from commit 365f08c)
(cherry picked from commit 0e176eb)
(cherry picked from commit c8ca641)
(cherry picked from commit 1ca66e8)
(cherry picked from commit 21a1245)
(cherry picked from commit 1f066f1)
@TimMcCool TimMcCool closed this Oct 31, 2024
@TimMcCool TimMcCool reopened this Oct 31, 2024
Signed-off-by: Tim <53166177+TimMcCool@users.noreply.github.com>
@TimMcCool TimMcCool merged commit 5ee6330 into TimMcCool:main Oct 31, 2024
@FAReTek1 FAReTek1 deleted the user-loved-projects branch November 7, 2024 17:08
@FAReTek1 FAReTek1 restored the user-loved-projects branch November 7, 2024 17:08
@FAReTek1 FAReTek1 deleted the user-loved-projects branch November 7, 2024 17:08
@FAReTek1 FAReTek1 restored the user-loved-projects branch November 7, 2024 17:08
@FAReTek1 FAReTek1 deleted the user-loved-projects branch November 7, 2024 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants