From bae6a32711aae4e8e0ce05936b8db545d238439d Mon Sep 17 00:00:00 2001 From: Guillem Hernandez Sola Date: Fri, 8 May 2026 11:00:38 +0200 Subject: [PATCH] ff --- bsky_post.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/bsky_post.py b/bsky_post.py index 7b7ef8a..713644c 100644 --- a/bsky_post.py +++ b/bsky_post.py @@ -327,12 +327,21 @@ def upload_video_and_wait( alt_text: str = "" ) -> models.AppBskyEmbedVideo.Main | None: try: - VIDEO_SERVICE_DID = "did:web:video.bsky.app" + # --- Resolve PDS host + DID dynamically --- + # The Client stores the service URL it logged into + pds_base = str(client._base_url).rstrip("/") # e.g. https://eurosky.social - # --- Token #1: bound to uploadVideo --- + # Derive the DID from the hostname (works for did:web PDSes) + from urllib.parse import urlparse + host = urlparse(pds_base).netloc + service_did = f"did:web:{host}" + + logging.info(f"🎬 Using video service at {pds_base} (aud={service_did})") + + # --- Token #1: uploadVideo, scoped to *this* PDS --- logging.info("🎬 Requesting Service Auth for Video Upload...") upload_auth = client.com.atproto.server.get_service_auth({ - 'aud': VIDEO_SERVICE_DID, + 'aud': service_did, 'lxm': 'app.bsky.video.uploadVideo', 'exp': int(time.time()) + 60 * 30, }) @@ -341,8 +350,9 @@ def upload_video_and_wait( "Content-Type": "video/mp4", } - logging.info("🎬 Uploading video to Bluesky Video Service...") - upload_url = "https://video.bsky.app/xrpc/app.bsky.video.uploadVideo" + # --- Upload to the PDS, not video.bsky.app --- + upload_url = f"{pds_base}/xrpc/app.bsky.video.uploadVideo" + logging.info(f"🎬 Uploading video to {upload_url}...") upload_resp = requests.post(upload_url, headers=upload_headers, data=video_data) if upload_resp.status_code != 200: @@ -356,15 +366,15 @@ def upload_video_and_wait( logging.info(f"⏳ Video uploaded! Job ID: {job_id}. Waiting for processing...") - # --- Token #2: bound to getJobStatus --- + # --- Token #2: getJobStatus --- status_auth = client.com.atproto.server.get_service_auth({ - 'aud': VIDEO_SERVICE_DID, + 'aud': service_did, 'lxm': 'app.bsky.video.getJobStatus', 'exp': int(time.time()) + 60 * 30, }) status_headers = {"Authorization": f"Bearer {status_auth.token}"} - status_url = "https://video.bsky.app/xrpc/app.bsky.video.getJobStatus" + status_url = f"{pds_base}/xrpc/app.bsky.video.getJobStatus" params = {"jobId": job_id} while True: