Compare commits

...
1 Commits
Author SHA1 Message Date
luciano 29b9753aa3 fix: mostra causa reale dietro "yt-dlp exit 1" (v1.11.3)
In download_playlist il codice legge stdout/stderr merged per parsare
il progress ma poi butta via tutte le righe. Se return_code != 0
l'utente vedeva solo "error: yt-dlp exit 1" senza sapere il perche'
(video bloccato? age-gate? 403? region-lock?).

Fix: buffer ring (10 righe non-progress) durante il download. Se
return_code != 0, estrae la riga con ERROR/error e la accoda al
messaggio -> "error: yt-dlp exit 1 — ERROR: [youtube] Video unavailable".
Massimo 220 char per non intasare il log.

Applicato solo al pattern download_playlist per ora (quello che usa il
utente sul batch Spotify). Direct URL e batch tags idem se emergono.
2026-08-28 10:08:52 +02:00
2 changed files with 19 additions and 2 deletions

No files matched your search

+1 -1
View File
@@ -5,7 +5,7 @@ import os
import sys
from pathlib import Path
VERSION = "v1.11.2"
VERSION = "v1.11.3"
APP_NAME = "MusicTools"
+18 -1
View File
@@ -247,6 +247,7 @@ def download_playlist(
**subprocess_flags(),
)
last_lines: list = [] # buffer per capire l'errore se exit != 0
for line in _current_process.stdout:
if is_stopped():
_current_process.terminate()
@@ -254,6 +255,13 @@ def download_playlist(
progress_callback(i, total, query, "stopped", 0)
return
# Tieni le ultime 10 righe non-progress per il report d'errore
stripped = line.strip()
if stripped and not re.match(r"^\[download\]\s+\d", stripped):
last_lines.append(stripped)
if len(last_lines) > 10:
last_lines.pop(0)
# Parse progress da output yt-dlp
pct_match = re.search(r"(\d+(?:\.\d+)?)%", line)
if pct_match and progress_callback:
@@ -278,8 +286,17 @@ def download_playlist(
if progress_callback:
progress_callback(i, total, query, "done", 100)
else:
# Estrai la vera causa da last_lines: cerca la riga ERROR di yt-dlp
err_hint = ""
for l in reversed(last_lines):
if "ERROR" in l or "error" in l:
err_hint = l[:220]
break
if not err_hint and last_lines:
err_hint = last_lines[-1][:220]
detail = f" — {err_hint}" if err_hint else ""
if progress_callback:
progress_callback(i, total, query, f"error: yt-dlp exit {return_code}", 0)
progress_callback(i, total, query, f"error: yt-dlp exit {return_code}{detail}", 0)
except Exception as e:
with _process_lock: