diff --git a/gallery_dl/extractor/fansly.py b/gallery_dl/extractor/fansly.py index a81a01d9..1dd802d0 100644 --- a/gallery_dl/extractor/fansly.py +++ b/gallery_dl/extractor/fansly.py @@ -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: diff --git a/test/results/fansly.py b/test/results/fansly.py index 29dfd661..68775d27 100644 --- a/test/results/fansly.py +++ b/test/results/fansly.py @@ -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,