[bluesky] handle exceptions during file extraction

This commit is contained in:
Mike Fährmann
2025-10-08 10:39:51 +02:00
parent a4e0091b25
commit ff0728dcd3
2 changed files with 17 additions and 4 deletions

View File

@@ -150,9 +150,15 @@ class BlueskyExtractor(Extractor):
if "images" in media:
for image in media["images"]:
files.append(self._extract_media(image, "image"))
try:
files.append(self._extract_media(image, "image"))
except Exception:
pass
if "video" in media and self.videos:
files.append(self._extract_media(media, "video"))
try:
files.append(self._extract_media(media, "video"))
except Exception:
pass
post["count"] = len(files)
return files

View File

@@ -364,7 +364,7 @@ __tests__ = (
},
"user": {
"avatar" : "https://cdn.bsky.app/img/avatar/plain/did:plc:eclio37ymobqex2ncko63h4r/bafkreidvvqj5jymmpaeklwkpq6gi532el447mjy2yultuukypzqm5ohfju@jpeg",
"banner" : "https://cdn.bsky.app/img/banner/plain/did:plc:eclio37ymobqex2ncko63h4r/bafkreiaiorkgl6t2j5w3sf6nj37drvwuvriq3e3vqwf4yn3pchpwfbekta@jpeg",
"banner" : "https://cdn.bsky.app/img/banner/plain/did:plc:eclio37ymobqex2ncko63h4r/bafkreidlzzmt7sy2n6imz5mg7siygb3cy4e526nvbjucczeu5cutqro5ni@jpeg",
"createdAt" : "2023-06-05T18:50:31.498Z",
"description" : "In-depth, independent reporting to better understand the world, now on Bluesky. News tips? Share them here: http://nyti.ms/2FVHq9v",
"did" : "did:plc:eclio37ymobqex2ncko63h4r",
@@ -373,7 +373,7 @@ __tests__ = (
"followsCount" : int,
"handle" : "nytimes.com",
"instance" : "nytimes.com",
"indexedAt" : "2024-01-20T05:04:46.757Z",
"indexedAt" : "iso:datetime",
"labels" : [],
"postsCount" : int,
},
@@ -443,6 +443,13 @@ __tests__ = (
"#class" : bluesky.BlueskyPostExtractor,
},
{
"#url" : "https://bsky.app/profile/jacksonlab.bsky.social/post/3m2ms33o6p52k",
"#comment" : "'external' embed - 'images': [], 'video': null",
"#class" : bluesky.BlueskyPostExtractor,
"#count" : 0,
},
{
"#url" : "https://bsky.app/saved",
"#class" : bluesky.BlueskyBookmarkExtractor,