improve videos
This commit is contained in:
41
bsky_post.py
41
bsky_post.py
@@ -347,6 +347,9 @@ def upload_video(
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# Post
|
||||||
|
# ============================================================
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Post
|
# Post
|
||||||
# ============================================================
|
# ============================================================
|
||||||
@@ -359,25 +362,39 @@ def post_to_bsky(
|
|||||||
alt_text: str = "",
|
alt_text: str = "",
|
||||||
) -> bool:
|
) -> bool:
|
||||||
rich_text = make_rich(text)
|
rich_text = make_rich(text)
|
||||||
embed = None
|
|
||||||
|
|
||||||
if image_path:
|
try:
|
||||||
|
# --- VIDEO POSTING ---
|
||||||
|
if video_path:
|
||||||
|
logging.info(f"🎬 Preparing video upload: {video_path}")
|
||||||
|
with open(video_path, "rb") as f:
|
||||||
|
video_data = f.read()
|
||||||
|
|
||||||
|
logging.info(f"🚀 Sending video post (this may take a moment to process)...")
|
||||||
|
# client.send_video automatically handles the video service upload and processing wait
|
||||||
|
result = client.send_video(
|
||||||
|
text=rich_text,
|
||||||
|
video=video_data,
|
||||||
|
video_alt=alt_text,
|
||||||
|
langs=langs
|
||||||
|
)
|
||||||
|
|
||||||
|
# --- IMAGE POSTING ---
|
||||||
|
elif image_path:
|
||||||
image = upload_image(client, image_path, alt_text=alt_text)
|
image = upload_image(client, image_path, alt_text=alt_text)
|
||||||
if not image:
|
if not image:
|
||||||
logging.error("❌ Aborting post: image upload failed.")
|
logging.error("❌ Aborting post: image upload failed.")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
embed = models.AppBskyEmbedImages.Main(images=[image])
|
embed = models.AppBskyEmbedImages.Main(images=[image])
|
||||||
|
logging.info(f"🚀 Sending image post...")
|
||||||
elif video_path:
|
|
||||||
video = upload_video(client, video_path, alt_text=alt_text)
|
|
||||||
if not video:
|
|
||||||
logging.error("❌ Aborting post: video upload failed.")
|
|
||||||
return False
|
|
||||||
embed = video
|
|
||||||
|
|
||||||
try:
|
|
||||||
logging.info(f"🚀 Sending post (langs={langs}, text={text!r})")
|
|
||||||
result = client.send_post(text=rich_text, embed=embed, langs=langs)
|
result = client.send_post(text=rich_text, embed=embed, langs=langs)
|
||||||
|
|
||||||
|
# --- TEXT ONLY POSTING ---
|
||||||
|
else:
|
||||||
|
logging.info(f"🚀 Sending text post...")
|
||||||
|
result = client.send_post(text=rich_text, langs=langs)
|
||||||
|
|
||||||
uri = getattr(result, "uri", None)
|
uri = getattr(result, "uri", None)
|
||||||
logging.info(f"✅ Post published! URI: {uri}")
|
logging.info(f"✅ Post published! URI: {uri}")
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user