Add detailed error logging and timeout to remote track downloads
This commit is contained in:
parent
bd87eb719d
commit
06beed2110
21
techdj_qt.py
21
techdj_qt.py
|
|
@ -277,8 +277,18 @@ class DownloadThread(QThread):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
try:
|
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))
|
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)
|
os.makedirs(os.path.dirname(self.filepath), exist_ok=True)
|
||||||
|
|
||||||
downloaded = 0
|
downloaded = 0
|
||||||
|
|
@ -291,9 +301,16 @@ class DownloadThread(QThread):
|
||||||
progress = int((downloaded / total_size) * 100)
|
progress = int((downloaded / total_size) * 100)
|
||||||
self.progress.emit(progress)
|
self.progress.emit(progress)
|
||||||
|
|
||||||
|
print(f"✅ Download complete: {os.path.basename(self.filepath)}")
|
||||||
self.finished.emit(self.filepath, True)
|
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:
|
except Exception as e:
|
||||||
print(f"Download error: {e}")
|
print(f"❌ Download error: {type(e).__name__}: {e}")
|
||||||
self.finished.emit(self.filepath, False)
|
self.finished.emit(self.filepath, False)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue