From 96152194ea6b00d84e63c81fdda72455e8352e7d Mon Sep 17 00:00:00 2001 From: Guillem Hernandez Sola Date: Tue, 19 May 2026 11:08:24 +0200 Subject: [PATCH] Cookies 3 --- tiktok2bsky.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tiktok2bsky.py b/tiktok2bsky.py index 9343337..7e28533 100644 --- a/tiktok2bsky.py +++ b/tiktok2bsky.py @@ -985,7 +985,10 @@ def process_tiktok(tiktok: ScrapedTikTok, client: Client, # ───────────────────────────────────────────── # Entry point # ───────────────────────────────────────────── +# ✅ FIXED — global declared at the very top of the function def main(): + global TIKTOK_COOKIES_PATH # ← must be first, before any other statement + load_dotenv() parser = argparse.ArgumentParser( @@ -1003,8 +1006,7 @@ def main(): ) args = parser.parse_args() - # Allow overriding cookie path via CLI - global TIKTOK_COOKIES_PATH + # Now safe to reassign the global TIKTOK_COOKIES_PATH = args.cookies_path logging.info(f"🤖 TikTok→Bluesky bot started. Scraping @{args.tiktok_handle}") @@ -1021,7 +1023,6 @@ def main(): logging.info("🔄 Starting TikTok → Bluesky sync cycle...") - # ── Scrape (Playwright first, yt-dlp fallback is automatic) ─────── tiktoks = scrape_tiktoks_via_playwright(args.tiktok_handle) if not tiktoks: @@ -1036,7 +1037,6 @@ def main(): try: if process_tiktok(tiktok, client, args.bsky_langs, state): posted += 1 - # Small courtesy delay between posts time.sleep(random.uniform(3.0, 7.0)) except Exception as e: logging.error(f"❌ Unexpected error processing video: {e}")