Inicia concerto do Proxy
This commit is contained in:
21
main.py
21
main.py
@@ -105,7 +105,7 @@ def get_video_metadata(
|
||||
|
||||
return info
|
||||
|
||||
info = execute_with_proxy_retry(ydl_opts, extract_metadata)
|
||||
info = execute_with_proxy_retry(ydl_opts, extract_metadata, retry_per_proxy=2)
|
||||
|
||||
except ProxyError as e:
|
||||
error_msg = str(e).replace('\n', ' ').strip()
|
||||
@@ -181,10 +181,17 @@ def download_video(
|
||||
"quiet": True,
|
||||
"noplaylist": True,
|
||||
"merge_output_format": "mp4",
|
||||
"cookiefile": "/app/cookies.txt",
|
||||
"socket_timeout": 8,
|
||||
"nocheckcertificate": True,
|
||||
"socket_timeout": 60,
|
||||
"retries": 0,
|
||||
"extractor_retries": 0,
|
||||
"force_ipv4": True,
|
||||
"geo_bypass": True,
|
||||
"extractor_args": {"youtube": {"player_client": ["android"], "player_skip": ["webpage"]}},
|
||||
"http_headers": {
|
||||
"Accept-Language": "pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7",
|
||||
"User-Agent": "com.google.android.youtube/19.17.36 (Linux; U; Android 13) gzip",
|
||||
},
|
||||
}
|
||||
|
||||
try:
|
||||
@@ -223,7 +230,7 @@ def download_video(
|
||||
"cached": False
|
||||
}
|
||||
|
||||
return execute_with_proxy_retry(ydl_opts, download_operation)
|
||||
return execute_with_proxy_retry(ydl_opts, download_operation, retry_per_proxy=3)
|
||||
|
||||
except ProxyError as e:
|
||||
raise HTTPException(status_code=503, detail=f"Erro com proxies: {e}")
|
||||
@@ -239,6 +246,7 @@ def search_youtube_yt_dlp(
|
||||
"quiet": True,
|
||||
"extract_flat": "in_playlist",
|
||||
"skip_download": True,
|
||||
"nocheckcertificate": True,
|
||||
"socket_timeout": 8,
|
||||
"retries": 0,
|
||||
}
|
||||
@@ -262,7 +270,7 @@ def search_youtube_yt_dlp(
|
||||
})
|
||||
return {"results": results}
|
||||
|
||||
return execute_with_proxy_retry(ydl_opts, search_operation)
|
||||
return execute_with_proxy_retry(ydl_opts, search_operation, retry_per_proxy=2)
|
||||
|
||||
except ProxyError as e:
|
||||
raise HTTPException(status_code=503, detail=f"Erro com proxies: {e}")
|
||||
@@ -275,6 +283,7 @@ def list_formats(url: str):
|
||||
"quiet": False,
|
||||
"no_warnings": False,
|
||||
"noplaylist": True,
|
||||
"nocheckcertificate": True,
|
||||
"force_ipv4": True,
|
||||
"geo_bypass": True,
|
||||
"extractor_args": {"youtube": {"player_client": ["android"], "player_skip": ["webpage"]}},
|
||||
@@ -301,7 +310,7 @@ def list_formats(url: str):
|
||||
} for f in fmts]
|
||||
return {"total": len(brief), "formats": brief[:60]}
|
||||
|
||||
return execute_with_proxy_retry(opts, list_formats_operation)
|
||||
return execute_with_proxy_retry(opts, list_formats_operation, retry_per_proxy=2)
|
||||
|
||||
except ProxyError as e:
|
||||
raise HTTPException(status_code=503, detail=f"Erro com proxies: {e}")
|
||||
|
||||
Reference in New Issue
Block a user