[fansly] implement 'home' extractor (#4401)

This commit is contained in:
Mike Fährmann
2025-09-03 19:52:50 +02:00
parent 556af306f3
commit 1082d99aef
2 changed files with 34 additions and 3 deletions

View File

@@ -96,11 +96,18 @@ class FanslyPostExtractor(FanslyExtractor):
class FanslyHomeExtractor(FanslyExtractor):
subcategory = "home"
pattern = rf"{BASE_PATTERN}/home(?:/(subscribed|list/(\d+)))?"
pattern = rf"{BASE_PATTERN}/home(?:/(?:subscribed()|list/(\d+)))?"
example = "https://fansly.com/home"
def items(self):
pass
def posts(self):
subscribed, list_id = self.groups
if subscribed is not None:
mode = "1"
elif list_id is not None:
mode = None
else:
mode = "0"
return self.api.timeline_home(mode, list_id)
class FanslyListExtractor(FanslyExtractor):
@@ -149,6 +156,15 @@ class FanslyAPI():
params = {"ids": post_id}
return self._update_posts(self._call(endpoint, params))
def timeline_home(self, mode="0", list_id=None):
endpoint = "/v1/timeline/home"
params = {"before": "0", "after": "0"}
if list_id is None:
params["mode"] = mode
else:
params["listId"] = list_id
return self._pagination(endpoint, params)
def timeline_new(self, account_id, wall_id):
endpoint = f"/v1/timelinenew/{account_id}"
params = {

View File

@@ -25,4 +25,19 @@ __tests__ = (
"#class" : fansly.FanslyCreatorPostsExtractor,
},
{
"#url" : "https://fansly.com/home",
"#class" : fansly.FanslyHomeExtractor,
},
{
"#url" : "https://fansly.com/home/subscribed",
"#class" : fansly.FanslyHomeExtractor,
},
{
"#url" : "https://fansly.com/home/list/1234567890",
"#class" : fansly.FanslyHomeExtractor,
},
)