v5.0
This commit is contained in:
+3
-11
@@ -8,8 +8,6 @@ import re
|
||||
import asyncio
|
||||
from packaging import version
|
||||
import qdarktheme
|
||||
|
||||
# Import for reading metadata from FLAC files
|
||||
from mutagen.flac import FLAC
|
||||
|
||||
from PyQt6.QtWidgets import (
|
||||
@@ -105,13 +103,11 @@ class DownloadWorker(QThread):
|
||||
self.skipped_tracks = []
|
||||
|
||||
def get_flac_isrc(self, filepath):
|
||||
"""Reads the ISRC tag from a FLAC file."""
|
||||
try:
|
||||
audio = FLAC(filepath)
|
||||
if 'isrc' in audio:
|
||||
return audio['isrc'][0]
|
||||
except Exception:
|
||||
# Ignores errors like file not found, not a FLAC file, etc.
|
||||
pass
|
||||
return None
|
||||
|
||||
@@ -169,12 +165,10 @@ class DownloadWorker(QThread):
|
||||
else:
|
||||
track_outpath = self.outpath
|
||||
|
||||
# Logic for ISRC check
|
||||
spotify_isrc = track.isrc
|
||||
if spotify_isrc:
|
||||
is_already_downloaded = False
|
||||
try:
|
||||
# Check all .flac files in the target folder for a matching ISRC
|
||||
for filename in os.listdir(track_outpath):
|
||||
if filename.lower().endswith('.flac'):
|
||||
filepath = os.path.join(track_outpath, filename)
|
||||
@@ -185,13 +179,12 @@ class DownloadWorker(QThread):
|
||||
int((i + 1) / total_tracks * 100))
|
||||
self.skipped_tracks.append(track)
|
||||
is_already_downloaded = True
|
||||
break # Match found, no need to check other files
|
||||
break
|
||||
except FileNotFoundError:
|
||||
# This means the target directory doesn't exist yet, so we can proceed.
|
||||
pass
|
||||
|
||||
if is_already_downloaded:
|
||||
continue # Move to the next track in the main loop
|
||||
continue
|
||||
|
||||
if (self.is_album or self.is_playlist) and self.use_track_numbers:
|
||||
new_filename = f"{track.track_number:02d} - {self.get_formatted_filename(track)}"
|
||||
@@ -201,7 +194,6 @@ class DownloadWorker(QThread):
|
||||
new_filename = re.sub(r'[<>:"/\\|?*]', lambda m: "'" if m.group() == '"' else '_', new_filename)
|
||||
new_filepath = os.path.join(track_outpath, new_filename)
|
||||
|
||||
# Fallback check by filename
|
||||
if os.path.exists(new_filepath) and os.path.getsize(new_filepath) > 0:
|
||||
self.progress.emit(f"File already exists by name: {new_filename}. Skipping download.", 0)
|
||||
self.progress.emit(f"Skipped: {track.title} - {track.artists}",
|
||||
@@ -515,7 +507,7 @@ class ServiceComboBox(QComboBox):
|
||||
class SpotiFLACGUI(QWidget):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.current_version = "4.9"
|
||||
self.current_version = "5.0"
|
||||
self.tracks = []
|
||||
self.all_tracks = []
|
||||
self.successful_downloads = []
|
||||
|
||||
Reference in New Issue
Block a user