update
This commit is contained in:
@@ -206,7 +206,7 @@ class DownloadManager:
|
||||
tidal_obj=tidal,
|
||||
path_base=settings.data.download_base_path,
|
||||
fn_logger=logger_tidal,
|
||||
skip_existing=False,
|
||||
skip_existing=True,
|
||||
progress_gui=mock_progress,
|
||||
progress=mock_progress_rich,
|
||||
event_abort=event_abort,
|
||||
|
||||
@@ -153,9 +153,67 @@ class TidalWrapper:
|
||||
return None
|
||||
return f"https://resources.tidal.com/images/{uuid.replace('-', '/')}/{width}x{height}.jpg"
|
||||
|
||||
def get_artist_albums(self, artist_id: str, limit: int = 50):
|
||||
"""Fetch all albums for a given artist"""
|
||||
if not self.is_authenticated():
|
||||
raise Exception("Not authenticated")
|
||||
|
||||
artist = self.session.artist(artist_id)
|
||||
albums = artist.get_albums(limit=limit)
|
||||
|
||||
# Deduplicate albums by title, keeping highest quality version
|
||||
albums_dict = {}
|
||||
for album in albums:
|
||||
title = album.name
|
||||
|
||||
# If we haven't seen this album title before, add it
|
||||
if title not in albums_dict:
|
||||
albums_dict[title] = album
|
||||
else:
|
||||
# If we've seen it, keep the one with higher quality
|
||||
existing = albums_dict[title]
|
||||
|
||||
# Prioritize by audio quality (if available)
|
||||
# TIDAL albums with better quality often have higher audio_quality values
|
||||
# Also prefer explicit versions over clean versions (explicit flag)
|
||||
# And prefer newer releases (release_date)
|
||||
|
||||
# Simple heuristic: prefer albums with explicit tag and newer release date
|
||||
keep_new = False
|
||||
if hasattr(album, 'explicit') and hasattr(existing, 'explicit'):
|
||||
if album.explicit and not existing.explicit:
|
||||
keep_new = True
|
||||
|
||||
# If explicit status is same, prefer newer release
|
||||
if not keep_new and hasattr(album, 'release_date') and hasattr(existing, 'release_date'):
|
||||
if album.release_date and existing.release_date:
|
||||
if album.release_date > existing.release_date:
|
||||
keep_new = True
|
||||
|
||||
if keep_new:
|
||||
albums_dict[title] = album
|
||||
|
||||
# Convert deduplicated dict to output format
|
||||
output = []
|
||||
for album in albums_dict.values():
|
||||
output.append({
|
||||
"id": album.id,
|
||||
"title": album.name,
|
||||
"artist": album.artist.name,
|
||||
"tracks": album.num_tracks,
|
||||
"release_date": str(album.release_date) if album.release_date else "Unknown",
|
||||
"cover": self._get_image_url(album.cover),
|
||||
"type": "album"
|
||||
})
|
||||
|
||||
# Sort by release date (newest first)
|
||||
output.sort(key=lambda x: x['release_date'], reverse=True)
|
||||
|
||||
return output
|
||||
|
||||
def get_track(self, track_id: str):
|
||||
return self.session.track(track_id)
|
||||
|
||||
def get_album(self, album_id: str):
|
||||
return self.session.album(album_id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user