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

Method studios_following

scratchattach/site/user.py:538–565  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

536 return studios
537
538 def studios_following(self) -> list[studio.Studio]:
539 with requests.no_error_handling():
540 resp = requests.get(
541 f"https://scratch.mit.edu/users/{self.username}/studios_following/",
542 headers=self._headers,
543 )
544 soup = BeautifulSoup(resp.text, "html.parser")
545 grid = soup.select_one(".media-grid")
546 assert grid is not None
547
548 studios: list[studio.Studio] = []
549 for studio_elem in grid.select("li.gallery.thumb.item"):
550 title_span = studio_elem.select_one("span.title")
551 assert title_span is not None
552 anchor = title_span.find("a")
553 assert anchor is not None
554
555 href = str(anchor["href"])
556 sid = int(href.split("/")[-2])
557 title: str = anchor.text
558
559 if "\n" in title:
560 # we do this instead of title.strip because it *could* be possible for
561 # a studio title to have spaces around it. But I am not 100% sure
562 title = title.split("\n")[0]
563
564 studios.append(studio.Studio(id=sid, title=title, _session=self._session))
565 return studios
566
567 def projects(self, *, limit=40, offset=0) -> list[project.Project]:
568 """

Callers 1

test_userFunction · 0.80

Calls 3

no_error_handlingMethod · 0.45
getMethod · 0.45
findMethod · 0.45

Tested by 1

test_userFunction · 0.64