Fix NAS NotSupportedError: Force m4a format and remove web client
This commit is contained in:
parent
b75b6b1aa6
commit
f073846d4b
1 changed files with 11 additions and 8 deletions
|
|
@ -619,15 +619,15 @@ 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 = {
|
||||||
'format': 'bestaudio[ext=m4a]/bestaudio[ext=webm]/bestaudio/best',
|
'format': 'bestaudio[ext=m4a]/bestaudio/best', # Prefer m4a for direct streaming
|
||||||
'quiet': True,
|
'quiet': True,
|
||||||
'noplaylist': True,
|
'noplaylist': True,
|
||||||
'nocheckcertificate': True, # Bypass SSL issues in Docker
|
'nocheckcertificate': True,
|
||||||
'geo_bypass': True, # Bypass geo restrictions
|
'geo_bypass': True,
|
||||||
'socket_timeout': 30, # Timeout for sockets
|
'socket_timeout': 30,
|
||||||
'retries': 3, # Retry on transient errors
|
'retries': 3,
|
||||||
'force_ipv4': True, # Force IPv4 (Fixes NAS/Docker IPv6 issues)
|
'force_ipv4': True,
|
||||||
'extractor_args': {'youtube': {'player_client': ['ios', 'android', 'web']}}, # Use stable clients
|
'extractor_args': {'youtube': {'player_client': ['ios', 'android']}}, # Remove 'web' to avoid blocking
|
||||||
}
|
}
|
||||||
|
|
||||||
# Extract direct URL
|
# Extract direct URL
|
||||||
|
|
@ -660,8 +660,11 @@ async def stream_audio(id: str):
|
||||||
if http_err.response.status_code == 403:
|
if http_err.response.status_code == 403:
|
||||||
cache.delete(cache_key)
|
cache.delete(cache_key)
|
||||||
raise
|
raise
|
||||||
|
except Exception as e:
|
||||||
|
print(f"DEBUG: Stream Iterator Error: {e}")
|
||||||
|
raise
|
||||||
|
|
||||||
return StreamingResponse(iterfile(), media_type="audio/mpeg")
|
return StreamingResponse(iterfile(), media_type="audio/mp4")
|
||||||
|
|
||||||
except HTTPException:
|
except HTTPException:
|
||||||
raise
|
raise
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue