This commit is contained in:
Guillem Hernandez Sola
2026-05-08 09:43:31 +02:00
parent d14a1f6d9d
commit 3cbb0a5853

View File

@@ -322,21 +322,22 @@ def upload_image(
def upload_video_and_wait(
client: Client,
video_data: bytes,
alt_text: str = ""
alt_text: str = "",
password: str = ""
) -> models.AppBskyEmbedVideo.Main | None:
try:
logging.info("🎬 Uploading video to Bluesky Video Service...")
# Create a temporary client pointing to the official Bluesky service
# just for the video upload, using the same session token.
# just for the video upload
video_client = Client(base_url="https://bsky.social")
# We must manually set the session so it knows who we are
if client.me:
# Re-use the existing authentication token
video_client.login(client.me.handle, client._session.app_password)
if client.me and password:
# Login using the explicitly passed password
video_client.login(client.me.handle, password)
else:
logging.error("❌ Main client is not logged in.")
logging.error("❌ Main client is not logged in or password missing.")
return None
# 1. Upload the video to the official service
@@ -379,6 +380,7 @@ def post_to_bsky(
image_path: str | None = None,
video_path: str | None = None,
alt_text: str = "",
password: str = "",
) -> bool:
rich_text = make_rich(text)
@@ -389,8 +391,8 @@ def post_to_bsky(
with open(video_path, "rb") as f:
video_data = f.read()
# Use our custom polling function
video_embed = upload_video_and_wait(client, video_data, alt_text)
# Pass the password to our custom polling function
video_embed = upload_video_and_wait(client, video_data, alt_text, password)
if not video_embed:
logging.error("❌ Aborting post: video upload/processing failed.")
@@ -470,6 +472,7 @@ def main():
image_path=args.image,
video_path=args.video,
alt_text=args.alt,
password=args.password,
)
if not post_success: