afaik, when page > 67, scratch returns a 404 for profile comment pages. This should return None instead of an empty list, because it is possible to have empty comment pages which have pages after them which have comments
If there is a robust way to know if you are at the end, I would like to know
def comments(self, *, page=1, limit=None) -> list[comment.Comment] | None:
"""
Returns the comments posted on the user's profile (with replies).
Keyword Arguments:
page: The page of the comments that should be returned.
limit: Max. amount of returned comments.
Returns:
list<scratchattach.comment.Comment>: A list containing the requested comments as Comment objects.
"""
URL = f"https://scratch.mit.edu/site-api/comments/user/{self.username}/?page={page}"
DATA = []
with requests.no_error_handling():
resp = requests.get(URL)
if resp.status_code == 404:
# Usually when page > 67. It is possible to have empty pages before
# page 67, but still have pages with content afterwards.
return None
i just changed the top of this function but i havent committed the changes
afaik, when page > 67, scratch returns a 404 for profile comment pages. This should return None instead of an empty list, because it is possible to have empty comment pages which have pages after them which have comments
If there is a robust way to know if you are at the end, I would like to know
i just changed the top of this function but i havent committed the changes