[fansly] download user posts from all account walls (#4401)
when no specific wallId is specified
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
"""Extractors for https://fansly.com/"""
|
"""Extractors for https://fansly.com/"""
|
||||||
|
|
||||||
from .common import Extractor, Message
|
from .common import Extractor, Message
|
||||||
from .. import text, util
|
from .. import text, util, exception
|
||||||
import time
|
import time
|
||||||
|
|
||||||
BASE_PATTERN = r"(?:https?://)?(?:www\.)?fansly\.com"
|
BASE_PATTERN = r"(?:https?://)?(?:www\.)?fansly\.com"
|
||||||
@@ -43,6 +43,23 @@ class FanslyExtractor(Extractor):
|
|||||||
url = file["url"]
|
url = file["url"]
|
||||||
yield Message.Url, url, text.nameext_from_url(url, post)
|
yield Message.Url, url, text.nameext_from_url(url, post)
|
||||||
|
|
||||||
|
def posts(self):
|
||||||
|
creator, wall_id = self.groups
|
||||||
|
account = self.api.account(creator)
|
||||||
|
walls = account["walls"]
|
||||||
|
|
||||||
|
if wall_id:
|
||||||
|
for wall in walls:
|
||||||
|
if wall["id"] == wall_id:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
raise exception.NotFoundError("wall")
|
||||||
|
walls = (wall,)
|
||||||
|
|
||||||
|
for wall in walls:
|
||||||
|
self.kwdict["wall"] = wall
|
||||||
|
yield from self.posts_wall(account, wall)
|
||||||
|
|
||||||
def _extract_files(self, post):
|
def _extract_files(self, post):
|
||||||
files = []
|
files = []
|
||||||
|
|
||||||
@@ -190,11 +207,8 @@ class FanslyCreatorPostsExtractor(FanslyExtractor):
|
|||||||
pattern = rf"{BASE_PATTERN}/([^/?#]+)/posts(?:/wall/(\d+))?"
|
pattern = rf"{BASE_PATTERN}/([^/?#]+)/posts(?:/wall/(\d+))?"
|
||||||
example = "https://fansly.com/CREATOR/posts"
|
example = "https://fansly.com/CREATOR/posts"
|
||||||
|
|
||||||
def posts(self):
|
def posts_wall(self, account, wall):
|
||||||
creator, wall_id = self.groups
|
return self.api.timeline_new(account["id"], wall["id"])
|
||||||
account = self.api.account(creator)
|
|
||||||
return self.api.timeline_new(
|
|
||||||
account["id"], wall_id or account["walls"][0]["id"])
|
|
||||||
|
|
||||||
|
|
||||||
class FanslyCreatorMediaExtractor(FanslyExtractor):
|
class FanslyCreatorMediaExtractor(FanslyExtractor):
|
||||||
@@ -202,11 +216,8 @@ class FanslyCreatorMediaExtractor(FanslyExtractor):
|
|||||||
pattern = rf"{BASE_PATTERN}/([^/?#]+)/media(?:/wall/(\d+))?"
|
pattern = rf"{BASE_PATTERN}/([^/?#]+)/media(?:/wall/(\d+))?"
|
||||||
example = "https://fansly.com/CREATOR/media"
|
example = "https://fansly.com/CREATOR/media"
|
||||||
|
|
||||||
def posts(self):
|
def posts_wall(self, account, wall):
|
||||||
creator, wall_id = self.groups
|
return self.api.mediaoffers_location(account["id"], wall["id"])
|
||||||
account = self.api.account(creator)
|
|
||||||
return self.api.mediaoffers_location(
|
|
||||||
account["id"], wall_id or account["walls"][0]["id"])
|
|
||||||
|
|
||||||
|
|
||||||
class FanslyAPI():
|
class FanslyAPI():
|
||||||
|
|||||||
Reference in New Issue
Block a user