From 7b059958c202bd5aba45f019767afbf6b15d99f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 19 Nov 2025 19:20:45 +0100 Subject: [PATCH] [fansly] handle posts without accountId/contentId/attachments (#8572) --- gallery_dl/extractor/fansly.py | 16 +++++++++++++--- test/results/fansly.py | 6 ++++++ 2 files changed, 19 insertions(+), 3 deletions(-) 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,