Skip to content

Commit 7b05995

Browse files
committed
[fansly] handle posts without accountId/contentId/attachments (#8572)
1 parent e91337d commit 7b05995

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

gallery_dl/extractor/fansly.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ def posts(self):
6161
yield from self.posts_wall(account, wall)
6262

6363
def _extract_files(self, post):
64-
files = []
64+
if "attachments" not in post:
65+
return ()
6566

6667
if "_extra" in post:
6768
extra = post.pop("_extra", ())
@@ -75,6 +76,7 @@ def _extract_files(self, post):
7576
if mid in media
7677
)
7778

79+
files = []
7880
for attachment in post.pop("attachments"):
7981
try:
8082
self._extract_attachment(files, post, attachment)
@@ -331,12 +333,20 @@ def _update_posts(self, response):
331333

332334
posts = response["posts"]
333335
for post in posts:
334-
post["account"] = accounts[post.pop("accountId")]
336+
try:
337+
post["account"] = accounts[post.pop("accountId")]
338+
except KeyError:
339+
pass
335340

336341
extra = None
337342
attachments = []
338343
for attachment in post["attachments"]:
339-
cid = attachment["contentId"]
344+
try:
345+
cid = attachment["contentId"]
346+
except KeyError:
347+
attachments.append(attachment)
348+
continue
349+
340350
if cid in media:
341351
attachments.append(media[cid])
342352
elif cid in bundles:

test/results/fansly.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@
118118
"#class" : fansly.FanslyCreatorMediaExtractor,
119119
},
120120

121+
{
122+
"#url" : "https://fansly.com/VchiBan/media",
123+
"#comment" : "posts without 'accountId' or 'contentId'",
124+
"#class" : fansly.FanslyCreatorMediaExtractor,
125+
},
126+
121127
{
122128
"#url" : "https://fansly.com/home",
123129
"#class" : fansly.FanslyHomeExtractor,

0 commit comments

Comments
 (0)