Add detailed error logging and timeout to remote track downloads

This commit is contained in:
ComputerTech 2026-01-20 17:05:24 +00:00
parent bd87eb719d
commit 06beed2110
1 changed files with 19 additions and 2 deletions

View File

@ -277,8 +277,18 @@ class DownloadThread(QThread):
def run(self):
try:
response = requests.get(self.url, stream=True)
print(f"📥 Downloading from: {self.url}")
response = requests.get(self.url, stream=True, timeout=30)
# Check if request was successful
if response.status_code != 200:
print(f"❌ HTTP {response.status_code}: {self.url}")
self.finished.emit(self.filepath, False)
return
total_size = int(response.headers.get('content-length', 0))
print(f"📦 File size: {total_size / 1024 / 1024:.2f} MB")
os.makedirs(os.path.dirname(self.filepath), exist_ok=True)
downloaded = 0
@ -291,9 +301,16 @@ class DownloadThread(QThread):
progress = int((downloaded / total_size) * 100)
self.progress.emit(progress)
print(f"✅ Download complete: {os.path.basename(self.filepath)}")
self.finished.emit(self.filepath, True)
except requests.exceptions.Timeout:
print(f"❌ Download timeout: {self.url}")
self.finished.emit(self.filepath, False)
except requests.exceptions.ConnectionError as e:
print(f"❌ Connection error: {e}")
self.finished.emit(self.filepath, False)
except Exception as e:
print(f"Download error: {e}")
print(f"Download error: {type(e).__name__}: {e}")
self.finished.emit(self.filepath, False)