✅ FULLY OPERATIONAL - Tested & working
## Infrastructure
- PO Token Provider (Docker bgutil, port 4416)
- SMS Receiver endpoint (Node.js, port 4417)
- Deno JavaScript runtime (signature decryption)
- Logged-in cookies system
## Features
- Anti-bot bypass (PO Token + cookies)
- Auto-login scripts with SMS forwarding
- Cookie extraction (Camoufox)
- Full automation ready
## Tested
- Multiple videos downloaded successfully
- Audio extraction to MP3 working
- Download speeds 15-30 MB/s
## Documentation
- YOUTUBE_SETUP_COMPLETE.md (full usage guide)
- SMS_FORWARDER_SETUP.md (SMS automation)
- QUICK_SETUP_COOKIES.md (cookie renewal)
## Scripts
- src/sms_receiver.js - SMS webhook endpoint
- src/python/auto_login_full_auto.py - Auto-login with SMS
- test_youtube_download.sh - Test script
Ready for production integration.
89 lines
3.3 KiB
Python
Executable File
89 lines
3.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Extract YouTube cookies with manual login using Camoufox.
|
|
Run this ONCE to login, then cookies will work for weeks.
|
|
"""
|
|
|
|
import asyncio
|
|
import sys
|
|
from pathlib import Path
|
|
from camoufox.async_api import AsyncCamoufox
|
|
|
|
async def extract_cookies_with_login(output_path='youtube-cookies.txt'):
|
|
"""
|
|
Extract YouTube cookies after manual login.
|
|
Opens browser window for user to login.
|
|
"""
|
|
|
|
print("🦊 Starting Camoufox (with GUI for login)...")
|
|
print("")
|
|
print("╔══════════════════════════════════════════════════╗")
|
|
print("║ 📝 INSTRUCTIONS: ║")
|
|
print("║ 1. Browser will open ║")
|
|
print("║ 2. Login to your YouTube account ║")
|
|
print("║ 3. Press Enter in this terminal when done ║")
|
|
print("╚══════════════════════════════════════════════════╝")
|
|
print("")
|
|
|
|
async with AsyncCamoufox(
|
|
headless=False, # GUI visible for login
|
|
humanize=True,
|
|
geoip=True,
|
|
) as browser:
|
|
page = await browser.new_page()
|
|
|
|
# Navigate to YouTube
|
|
print("📺 Loading YouTube...")
|
|
await page.goto('https://www.youtube.com', wait_until='domcontentloaded', timeout=30000)
|
|
|
|
# Wait for user to login
|
|
input("⏸️ Press Enter after you've logged in to YouTube...")
|
|
|
|
# Navigate to confirm cookies are set
|
|
await page.goto('https://www.youtube.com', wait_until='domcontentloaded')
|
|
await asyncio.sleep(2)
|
|
|
|
# Extract cookies
|
|
cookies = await page.context.cookies()
|
|
|
|
# Filter YouTube cookies
|
|
yt_cookies = [c for c in cookies if 'youtube.com' in c['domain']]
|
|
|
|
if not yt_cookies:
|
|
print("❌ No YouTube cookies found!")
|
|
return False
|
|
|
|
# Save to Netscape format
|
|
output = Path(output_path)
|
|
with open(output, 'w') as f:
|
|
f.write("# Netscape HTTP Cookie File\n")
|
|
f.write("# Generated by Camoufox with logged-in account\n")
|
|
for c in yt_cookies:
|
|
# Handle expires properly
|
|
expires = int(c.get('expires', 0))
|
|
if expires <= 0:
|
|
expires = 2147483647 # Max 32-bit timestamp (year 2038)
|
|
|
|
line = f"{c['domain']}\tTRUE\t{c['path']}\t"
|
|
line += f"{'TRUE' if c.get('secure') else 'FALSE'}\t"
|
|
line += f"{expires}\t{c['name']}\t{c['value']}\n"
|
|
f.write(line)
|
|
|
|
# Set secure permissions
|
|
output.chmod(0o600)
|
|
|
|
print("")
|
|
print(f"✅ Cookies saved: {output_path}")
|
|
print(f" Total cookies: {len(yt_cookies)}")
|
|
print(f" Logged in: Yes")
|
|
print("")
|
|
print("💡 These cookies will work for 2-4 weeks!")
|
|
print(" Run this script again when they expire.")
|
|
|
|
return True
|
|
|
|
if __name__ == '__main__':
|
|
output = sys.argv[1] if len(sys.argv) > 1 else 'youtube-cookies.txt'
|
|
success = asyncio.run(extract_cookies_with_login(output))
|
|
sys.exit(0 if success else 1)
|