Cookies 3
This commit is contained in:
@@ -985,7 +985,10 @@ def process_tiktok(tiktok: ScrapedTikTok, client: Client,
|
|||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
# Entry point
|
# Entry point
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
|
# ✅ FIXED — global declared at the very top of the function
|
||||||
def main():
|
def main():
|
||||||
|
global TIKTOK_COOKIES_PATH # ← must be first, before any other statement
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
@@ -1003,8 +1006,7 @@ def main():
|
|||||||
)
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# Allow overriding cookie path via CLI
|
# Now safe to reassign the global
|
||||||
global TIKTOK_COOKIES_PATH
|
|
||||||
TIKTOK_COOKIES_PATH = args.cookies_path
|
TIKTOK_COOKIES_PATH = args.cookies_path
|
||||||
|
|
||||||
logging.info(f"🤖 TikTok→Bluesky bot started. Scraping @{args.tiktok_handle}")
|
logging.info(f"🤖 TikTok→Bluesky bot started. Scraping @{args.tiktok_handle}")
|
||||||
@@ -1021,7 +1023,6 @@ def main():
|
|||||||
|
|
||||||
logging.info("🔄 Starting TikTok → Bluesky sync cycle...")
|
logging.info("🔄 Starting TikTok → Bluesky sync cycle...")
|
||||||
|
|
||||||
# ── Scrape (Playwright first, yt-dlp fallback is automatic) ───────
|
|
||||||
tiktoks = scrape_tiktoks_via_playwright(args.tiktok_handle)
|
tiktoks = scrape_tiktoks_via_playwright(args.tiktok_handle)
|
||||||
|
|
||||||
if not tiktoks:
|
if not tiktoks:
|
||||||
@@ -1036,7 +1037,6 @@ def main():
|
|||||||
try:
|
try:
|
||||||
if process_tiktok(tiktok, client, args.bsky_langs, state):
|
if process_tiktok(tiktok, client, args.bsky_langs, state):
|
||||||
posted += 1
|
posted += 1
|
||||||
# Small courtesy delay between posts
|
|
||||||
time.sleep(random.uniform(3.0, 7.0))
|
time.sleep(random.uniform(3.0, 7.0))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"❌ Unexpected error processing video: {e}")
|
logging.error(f"❌ Unexpected error processing video: {e}")
|
||||||
|
|||||||
Reference in New Issue
Block a user