Skip to content

feat: mystuff project/studio counts #583

@faretek1

Description

@faretek1

there is a function sess.mystuff_projects determined by page. but there is no function to get the number of projects.

here is an external implementation:

def session_mystuff_counts(self: sa.Session) -> tuple[int, int, int]:
    # returns shared count, unshared count, and studio count
    # TODO: classrooms?
    resp = requests.get(
        "https://scratch.mit.edu/mystuff/", headers=self._headers, cookies=self._cookies
    )
    soup = bs4.BeautifulSoup(resp.text, "html.parser")
    shared_elem = soup.select_one("span[data-content='shared-count']")
    unshared_elem = soup.select_one("span[data-content='unshared-count']")
    gallery_elem = soup.select_one("span[data-content='gallery-count']")
    assert shared_elem is not None
    assert unshared_elem is not None
    assert gallery_elem is not None
    shared: str = shared_elem.text.strip()
    unshared: str = unshared_elem.text.strip()
    gallery: str = gallery_elem.text.strip()
    return int(shared), int(unshared), int(gallery)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions