Fix quality format fallbacks and resolution detection above 1080p
The per-quality format strings fell back to best[height<=NNN] which on YouTube resolves to pre-merged streams capped at ~360p, causing every quality selector choice to silently download low-res video. Replace with bestvideo+bestaudio as the intermediate fallback so adaptive streams are always preferred over pre-merged ones. Also fix detect_resolution to correctly label 1440p and 2160p files instead of capping the display at 1080p. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -450,14 +450,14 @@ def fetch_dislike_count(youtube_video_id: str) -> int | None:
|
||||
|
||||
QUALITY_FORMATS = {
|
||||
"best": "bestvideo+bestaudio/best",
|
||||
"2160p": "bestvideo[height<=2160]+bestaudio/best[height<=2160]",
|
||||
"1440p": "bestvideo[height<=1440]+bestaudio/best[height<=1440]",
|
||||
"1080p": "bestvideo[height<=1080]+bestaudio/best[height<=1080]",
|
||||
"720p": "bestvideo[height<=720]+bestaudio/best[height<=720]",
|
||||
"480p": "bestvideo[height<=480]+bestaudio/best[height<=480]",
|
||||
"360p": "bestvideo[height<=360]+bestaudio/best[height<=360]",
|
||||
"240p": "bestvideo[height<=240]+bestaudio/best[height<=240]",
|
||||
"144p": "bestvideo[height<=144]+bestaudio/best[height<=144]",
|
||||
"2160p": "bestvideo[height<=2160]+bestaudio/bestvideo+bestaudio/best",
|
||||
"1440p": "bestvideo[height<=1440]+bestaudio/bestvideo+bestaudio/best",
|
||||
"1080p": "bestvideo[height<=1080]+bestaudio/bestvideo+bestaudio/best",
|
||||
"720p": "bestvideo[height<=720]+bestaudio/bestvideo+bestaudio/best",
|
||||
"480p": "bestvideo[height<=480]+bestaudio/bestvideo+bestaudio/best",
|
||||
"360p": "bestvideo[height<=360]+bestaudio/bestvideo+bestaudio/best",
|
||||
"240p": "bestvideo[height<=240]+bestaudio/bestvideo+bestaudio/best",
|
||||
"144p": "bestvideo[height<=144]+bestaudio/bestvideo+bestaudio/best",
|
||||
}
|
||||
|
||||
|
||||
@@ -470,6 +470,8 @@ def detect_resolution(file_path: str) -> str | None:
|
||||
capture_output=True, text=True, timeout=15,
|
||||
)
|
||||
height = int(result.stdout.strip())
|
||||
if height >= 2160: return "2160p"
|
||||
if height >= 1440: return "1440p"
|
||||
if height >= 1080: return "1080p"
|
||||
if height >= 720: return "720p"
|
||||
if height >= 480: return "480p"
|
||||
|
||||
Reference in New Issue
Block a user