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