Skip to content

Commit

Permalink
feat: Add Bluesky media extraction support
Browse files Browse the repository at this point in the history
  • Loading branch information
seriaati committed Oct 30, 2024
1 parent a430acc commit 6d3b8d4
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions embed_fixer/cogs/fixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,28 @@ async def _fetch_bluesky_media_urls(self, url: str) -> list[str]:
urls: list[str] = []
post = data["posts"][0]
embed = post.get("embed")

if embed is None:
return []

images = embed.get("images")
if images is not None:
# Image
if (images := embed.get("images")) is not None:
urls.extend(image["fullsize"] for image in images)

# Video
if (
(cid := embed.get("cid")) is not None
and (author := post.get("author")) is not None
and (did := author.get("did"))
):
urls.append(
f"https://bsky.social/xrpc/com.atproto.sync.getBlob?cid={cid}&did={did}"
)

# External GIF
if (external := (embed.get("external"))) and (uri := external.get("uri")):
urls.append(uri)

return urls

async def _fetch_iwara_video_urls(self, url: str) -> list[str]:
Expand Down

0 comments on commit 6d3b8d4

Please sign in to comment.