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