[fansly] handle posts without accountId/contentId/attachments (#8572)

This commit is contained in:
Mike Fährmann
2025-11-19 19:20:45 +01:00
parent e91337d5c3
commit 7b059958c2
2 changed files with 19 additions and 3 deletions

View File

@@ -61,7 +61,8 @@ class FanslyExtractor(Extractor):
yield from self.posts_wall(account, wall)
def _extract_files(self, post):
files = []
if "attachments" not in post:
return ()
if "_extra" in post:
extra = post.pop("_extra", ())
@@ -75,6 +76,7 @@ class FanslyExtractor(Extractor):
if mid in media
)
files = []
for attachment in post.pop("attachments"):
try:
self._extract_attachment(files, post, attachment)
@@ -331,12 +333,20 @@ class FanslyAPI():
posts = response["posts"]
for post in posts:
post["account"] = accounts[post.pop("accountId")]
try:
post["account"] = accounts[post.pop("accountId")]
except KeyError:
pass
extra = None
attachments = []
for attachment in post["attachments"]:
cid = attachment["contentId"]
try:
cid = attachment["contentId"]
except KeyError:
attachments.append(attachment)
continue
if cid in media:
attachments.append(media[cid])
elif cid in bundles:

View File

@@ -118,6 +118,12 @@ __tests__ = (
"#class" : fansly.FanslyCreatorMediaExtractor,
},
{
"#url" : "https://fansly.com/VchiBan/media",
"#comment" : "posts without 'accountId' or 'contentId'",
"#class" : fansly.FanslyCreatorMediaExtractor,
},
{
"#url" : "https://fansly.com/home",
"#class" : fansly.FanslyHomeExtractor,