Update bluesky_fetcher.py
Browse files- bluesky_fetcher.py +31 -1
bluesky_fetcher.py
CHANGED
|
@@ -34,6 +34,35 @@ class BlueskyFetcher:
|
|
| 34 |
post_id = parts[-1]
|
| 35 |
web_url = f"https://bsky.app/profile/{author.get('handle', '')}/post/{post_id}"
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
posts.append({
|
| 38 |
"uri": uri,
|
| 39 |
"platform": "bluesky",
|
|
@@ -42,7 +71,8 @@ class BlueskyFetcher:
|
|
| 42 |
"author_avatar": author.get("avatar", ""),
|
| 43 |
"text": record.get("text", ""),
|
| 44 |
"created_at": record.get("createdAt", ""),
|
| 45 |
-
"web_url": web_url
|
|
|
|
| 46 |
})
|
| 47 |
except:
|
| 48 |
pass
|
|
|
|
| 34 |
post_id = parts[-1]
|
| 35 |
web_url = f"https://bsky.app/profile/{author.get('handle', '')}/post/{post_id}"
|
| 36 |
|
| 37 |
+
# Extract quote post if present
|
| 38 |
+
quote_post = None
|
| 39 |
+
embed = post.get("embed", {})
|
| 40 |
+
embed_type = embed.get("$type", "")
|
| 41 |
+
|
| 42 |
+
# Quote post (app.bsky.embed.record#view)
|
| 43 |
+
if "record" in embed_type or embed_type == "app.bsky.embed.record#view":
|
| 44 |
+
quoted = embed.get("record", {})
|
| 45 |
+
if quoted.get("$type") == "app.bsky.embed.record#viewRecord" or "value" in quoted:
|
| 46 |
+
quote_author = quoted.get("author", {})
|
| 47 |
+
quote_value = quoted.get("value", {})
|
| 48 |
+
quote_post = {
|
| 49 |
+
"author_handle": quote_author.get("handle", ""),
|
| 50 |
+
"author_name": quote_author.get("displayName", ""),
|
| 51 |
+
"text": quote_value.get("text", "")
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
# Quote post with media (app.bsky.embed.recordWithMedia#view)
|
| 55 |
+
if "recordWithMedia" in embed_type:
|
| 56 |
+
quoted = embed.get("record", {}).get("record", {})
|
| 57 |
+
if quoted:
|
| 58 |
+
quote_author = quoted.get("author", {})
|
| 59 |
+
quote_value = quoted.get("value", {})
|
| 60 |
+
quote_post = {
|
| 61 |
+
"author_handle": quote_author.get("handle", ""),
|
| 62 |
+
"author_name": quote_author.get("displayName", ""),
|
| 63 |
+
"text": quote_value.get("text", "")
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
posts.append({
|
| 67 |
"uri": uri,
|
| 68 |
"platform": "bluesky",
|
|
|
|
| 71 |
"author_avatar": author.get("avatar", ""),
|
| 72 |
"text": record.get("text", ""),
|
| 73 |
"created_at": record.get("createdAt", ""),
|
| 74 |
+
"web_url": web_url,
|
| 75 |
+
"quote_post": quote_post
|
| 76 |
})
|
| 77 |
except:
|
| 78 |
pass
|