Fix: Aggressive YouTube auth bypass with web_creator client and yt-dlp nightly
This commit is contained in:
parent
e412888f68
commit
72858c64f9
2 changed files with 14 additions and 8 deletions
|
|
@ -626,7 +626,7 @@ async def stream_audio(id: str):
|
||||||
try:
|
try:
|
||||||
# Check Cache for stream URL
|
# Check Cache for stream URL
|
||||||
# Check Cache for stream URL
|
# Check Cache for stream URL
|
||||||
cache_key = f"v9:stream:{id}" # v9 cache key - tv_embedded auth bypass
|
cache_key = f"v10:stream:{id}" # v10 - web_creator client bypass
|
||||||
cached_data = cache.get(cache_key)
|
cached_data = cache.get(cache_key)
|
||||||
|
|
||||||
stream_url = None
|
stream_url = None
|
||||||
|
|
@ -644,17 +644,23 @@ async def stream_audio(id: str):
|
||||||
print(f"DEBUG: Fetching new stream URL for '{id}'")
|
print(f"DEBUG: Fetching new stream URL for '{id}'")
|
||||||
url = f"https://www.youtube.com/watch?v={id}"
|
url = f"https://www.youtube.com/watch?v={id}"
|
||||||
ydl_opts = {
|
ydl_opts = {
|
||||||
# Use tv_embedded client which often bypasses sign-in requirements
|
# Try multiple formats, prefer webm which often works better
|
||||||
'format': 'bestaudio[ext=m4a]/bestaudio/best',
|
'format': 'bestaudio[ext=webm]/bestaudio[ext=m4a]/bestaudio/best',
|
||||||
'quiet': True,
|
'quiet': False, # Enable output for debugging
|
||||||
'noplaylist': True,
|
'noplaylist': True,
|
||||||
'nocheckcertificate': True,
|
'nocheckcertificate': True,
|
||||||
'geo_bypass': True,
|
'geo_bypass': True,
|
||||||
|
'geo_bypass_country': 'US',
|
||||||
'socket_timeout': 30,
|
'socket_timeout': 30,
|
||||||
'retries': 3,
|
'retries': 5,
|
||||||
'force_ipv4': True,
|
'force_ipv4': True,
|
||||||
# tv_embedded is an embedded player client that usually doesn't require auth
|
# Try web_creator client which sometimes bypasses auth, fallback to ios/android
|
||||||
'extractor_args': {'youtube': {'player_client': ['tv_embedded', 'mediaconnect']}},
|
'extractor_args': {'youtube': {'player_client': ['web_creator', 'ios', 'android', 'web']}},
|
||||||
|
# Additional options to avoid bot detection
|
||||||
|
'http_headers': {
|
||||||
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
||||||
|
'Accept-Language': 'en-US,en;q=0.9',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,6 @@ pydantic==2.10.4
|
||||||
python-multipart==0.0.20
|
python-multipart==0.0.20
|
||||||
APScheduler>=3.10
|
APScheduler>=3.10
|
||||||
requests==2.32.3
|
requests==2.32.3
|
||||||
yt-dlp==2024.12.23
|
yt-dlp @ https://github.com/yt-dlp/yt-dlp/archive/master.zip
|
||||||
ytmusicapi==1.9.1
|
ytmusicapi==1.9.1
|
||||||
syncedlyrics
|
syncedlyrics
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue