From 29b9753aa3377094572a1b7ee35b33c6fd7b90c6 Mon Sep 17 00:00:00 2001 From: luciano Date: Fri, 28 Aug 2026 10:08:52 +0200 Subject: [PATCH] fix: mostra causa reale dietro "yt-dlp exit 1" (v1.11.3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- core/config.py | 2 +- core/downloader.py | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/core/config.py b/core/config.py index 88bbfff..4a7cc7b 100644 --- a/core/config.py +++ b/core/config.py @@ -5,7 +5,7 @@ import os import sys from pathlib import Path -VERSION = "v1.11.2" +VERSION = "v1.11.3" APP_NAME = "MusicTools" diff --git a/core/downloader.py b/core/downloader.py index 2f3ded0..0092f87 100644 --- a/core/downloader.py +++ b/core/downloader.py @@ -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: