[fanbox] make '_extract_post()' non-fatal (#8711)

fixes regression introduced in 4a4c1a1154
This commit is contained in:
Mike Fährmann
2025-12-15 17:43:21 +01:00
parent d43ce45cb8
commit 9133ee321f
2 changed files with 46 additions and 6 deletions

View File

@@ -127,15 +127,19 @@ class FanboxExtractor(Extractor):
if file.get("extension", "").lower() in exts
]
post["date"] = self.parse_datetime_iso(post["publishedDatetime"])
try:
post["date"] = self.parse_datetime_iso(post["publishedDatetime"])
except Exception:
post["date"] = None
post["text"] = content_body.get("text") if content_body else None
post["isCoverImage"] = False
if self._meta_user:
post["user"] = self._get_user_data(post["creatorId"])
if self._meta_plan:
cid = post.get("creatorId")
if self._meta_user and cid is not None:
post["user"] = self._get_user_data(cid)
if self._meta_plan and cid is not None:
plans = self._get_plan_data(post["creatorId"])
fee = post["feeRequired"]
fee = post.get("feeRequired") or 0
try:
post["plan"] = plans[fee]
except KeyError:
@@ -146,7 +150,7 @@ class FanboxExtractor(Extractor):
plan["fee"] = fee
post["plan"] = plans[fee] = plan
if self._meta_comments:
if post["commentCount"]:
if post.get("commentCount"):
post["comments"] = list(self._get_comment_data(post["id"]))
else:
post["commentd"] = ()

View File

@@ -190,6 +190,42 @@ __tests__ = (
],
},
{
"#url" : "https://etlabsotwe.fanbox.cc/posts/11070192",
"#comment" : "(potentially?) missing 'publishedDatetime' (#8711)",
"#class" : fanbox.FanboxPostExtractor,
"#results" : "https://pixiv.pximg.net/fanbox/public/images/post/11070192/cover/MGoWoTnJphuJSkD3owo3r7wG.jpeg",
"archives" : (),
"creatorId" : "etlabsotwe",
"date" : "dt:2025-12-15 11:31:50",
"excerpt" : "",
"extension" : "jpeg",
"feeRequired" : 200,
"fileUrl" : "https://pixiv.pximg.net/fanbox/public/images/post/11070192/cover/MGoWoTnJphuJSkD3owo3r7wG.jpeg",
"filename" : "MGoWoTnJphuJSkD3owo3r7wG",
"hasAdultContent": True,
"id" : "11070192",
"imageForShare" : "https://pixiv.pximg.net/c/1200x630_90_a2_g5/fanbox/public/images/post/11070192/cover/MGoWoTnJphuJSkD3owo3r7wG.jpeg",
"isCommentingRestricted": False,
"isCoverImage" : True,
"isLiked" : False,
"isPinned" : False,
"isRestricted" : True,
"likeCount" : int,
"num" : 0,
"publishedDatetime": "2025-12-15T20:31:50+09:00",
"tags" : [],
"text" : None,
"title" : "Sketches 2025-12-15",
"type" : "article",
"updatedDatetime": "iso:dt",
"user" : {
"name" : "ET",
"userId" : "74814193",
},
},
{
"#url" : "https://fanbox.cc/",
"#category": ("", "fanbox", "home"),