Fet
This commit is contained in:
18
bsky_post.py
18
bsky_post.py
@@ -326,7 +326,11 @@ def upload_video_and_wait(
|
||||
alt_text: str = ""
|
||||
) -> models.AppBskyEmbedVideo.Main | None:
|
||||
|
||||
# --- Helper class to mock the SDK's internal Session object ---
|
||||
# --- Helper classes to mock the SDK's internal Session object ---
|
||||
class MockPayload:
|
||||
def __init__(self, exp):
|
||||
self.exp = exp
|
||||
|
||||
class VideoSession:
|
||||
def __init__(self, token, handle, did):
|
||||
self.access_jwt = token
|
||||
@@ -334,17 +338,23 @@ def upload_video_and_wait(
|
||||
self.handle = handle
|
||||
self.did = did
|
||||
|
||||
# The SDK needs this payload to check token expiration
|
||||
self.access_jwt_payload = {"exp": int(time.time()) + 3600}
|
||||
# Default to 1 hour from now if decoding fails
|
||||
exp_time = int(time.time()) + 3600
|
||||
|
||||
try:
|
||||
parts = token.split('.')
|
||||
if len(parts) == 3:
|
||||
payload = parts[1]
|
||||
# Pad base64 string if necessary
|
||||
payload += '=' * (-len(payload) % 4)
|
||||
self.access_jwt_payload = json.loads(base64.urlsafe_b64decode(payload).decode('utf-8'))
|
||||
decoded = json.loads(base64.urlsafe_b64decode(payload).decode('utf-8'))
|
||||
if 'exp' in decoded:
|
||||
exp_time = decoded['exp']
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Assign as an object so the SDK can call .exp
|
||||
self.access_jwt_payload = MockPayload(exp_time)
|
||||
|
||||
try:
|
||||
logging.info("🎬 Requesting Service Auth for Video Upload...")
|
||||
|
||||
Reference in New Issue
Block a user