Ajusta parametros

This commit is contained in:
LeoMortari
2025-09-28 19:35:14 -03:00
parent 9df4e20578
commit defe489f80

27
main.py
View File

@@ -171,15 +171,12 @@ def download_video(
unique_id = str(uuid.uuid4()) unique_id = str(uuid.uuid4())
outtmpl = os.path.join(videos_dir, f"{unique_id}.%(ext)s") outtmpl = os.path.join(videos_dir, f"{unique_id}.%(ext)s")
# Expressão de formato robusta:
# 1) Tenta bestvideo até a altura desejada + bestaudio (mp4/m4a quando der)
# 2) Cai para best [altura<=] em um único arquivo
# 3) Finalmente qualquer best disponível
fmt_expr = ( fmt_expr = (
f"bv*[height<={target_height}][ext=mp4]+ba[ext=m4a]/" # tenta vídeo <= alvo + melhor áudio
f"bv*[height<={target_height}]+ba/" f"bv*[height<={target_height}]+ba/"
f"b[height<={target_height}][ext=mp4]/" # cai pra qualquer melhor vídeo <= alvo (progressivo se houver)
f"b[height<={target_height}]/" f"b[height<={target_height}]/"
# último recurso: qualquer best
f"b" f"b"
) )
@@ -188,13 +185,17 @@ def download_video(
"quiet": True, "quiet": True,
"no_warnings": True, "no_warnings": True,
"ignoreerrors": False, "ignoreerrors": False,
"no_color": True, "noplaylist": True,
"noplaylist": True, # não tratar como playlist "format": fmt_expr,
"format": fmt_expr, # <<< chave da correção "merge_output_format": "mp4",
"merge_output_format": "mp4", # força saída mp4 quando há merge "force_ipv4": True,
# NUNCA usar force_generic_extractor p/ YouTube "geo_bypass": True,
# NUNCA usar extract_flat aqui "extractor_args": {
# NÃO usar allow_unplayable_formats "youtube": {
"player_client": ["android"],
"player_skip": ["webpage"]
}
},
} }
try: try: