Improve wishlist track sorting and cleanup logic
Wishlist tracks are now sorted by artist and track name for consistent display. The database query for wishlist tracks now orders by date_added instead of randomly. Added logic to remove completed tracks from the wishlist during failed track processing. Updated docker-compose.yml to mount the H: drive for transfer folders.
This commit is contained in:
parent
d51171c180
commit
93ac55a709
4 changed files with 27 additions and 1 deletions
|
|
@ -108,6 +108,17 @@ class WishlistService:
|
||||||
wishlist_tracks = self.database.get_wishlist_tracks(limit=limit)
|
wishlist_tracks = self.database.get_wishlist_tracks(limit=limit)
|
||||||
formatted_tracks = []
|
formatted_tracks = []
|
||||||
|
|
||||||
|
# Sort by artist name, then track name for consistent display order
|
||||||
|
try:
|
||||||
|
wishlist_tracks.sort(key=lambda x: (
|
||||||
|
x['spotify_data'].get('artists', [{}])[0].get('name', '').lower(),
|
||||||
|
x['spotify_data'].get('name', '').lower()
|
||||||
|
))
|
||||||
|
logger.debug(f"Successfully sorted {len(wishlist_tracks)} wishlist tracks by artist/track name")
|
||||||
|
except Exception as sort_error:
|
||||||
|
logger.warning(f"Failed to sort wishlist tracks, using original order: {sort_error}")
|
||||||
|
# Continue with original database order (date_added)
|
||||||
|
|
||||||
for wishlist_track in wishlist_tracks:
|
for wishlist_track in wishlist_tracks:
|
||||||
spotify_data = wishlist_track['spotify_data']
|
spotify_data = wishlist_track['spotify_data']
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1914,7 +1914,7 @@ class MusicDatabase:
|
||||||
SELECT id, spotify_track_id, spotify_data, failure_reason, retry_count,
|
SELECT id, spotify_track_id, spotify_data, failure_reason, retry_count,
|
||||||
last_attempted, date_added, source_type, source_info
|
last_attempted, date_added, source_type, source_info
|
||||||
FROM wishlist_tracks
|
FROM wishlist_tracks
|
||||||
ORDER BY RANDOM()
|
ORDER BY date_added
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if limit:
|
if limit:
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ services:
|
||||||
# IMPORTANT: Mount the drives containing your download and transfer folders
|
# IMPORTANT: Mount the drives containing your download and transfer folders
|
||||||
# If your download/transfer paths are on E: drive, mount E: drive:
|
# If your download/transfer paths are on E: drive, mount E: drive:
|
||||||
- /mnt/e:/host/mnt/e:rw
|
- /mnt/e:/host/mnt/e:rw
|
||||||
|
# Mount H: drive for transfer folder
|
||||||
|
- /mnt/h:/host/mnt/h:rw
|
||||||
# If your download/transfer paths are on C: drive, uncomment this line:
|
# If your download/transfer paths are on C: drive, uncomment this line:
|
||||||
# - /mnt/c:/host/mnt/c:rw
|
# - /mnt/c:/host/mnt/c:rw
|
||||||
# If your download/transfer paths are on D: drive, uncomment this line:
|
# If your download/transfer paths are on D: drive, uncomment this line:
|
||||||
|
|
|
||||||
|
|
@ -6083,6 +6083,19 @@ def _process_failed_tracks_to_wishlist_exact(batch_id):
|
||||||
permanently_failed_tracks = batch.get('permanently_failed_tracks', [])
|
permanently_failed_tracks = batch.get('permanently_failed_tracks', [])
|
||||||
cancelled_tracks = batch.get('cancelled_tracks', set())
|
cancelled_tracks = batch.get('cancelled_tracks', set())
|
||||||
|
|
||||||
|
# STEP 0: Remove completed tracks from wishlist (THIS WAS MISSING!)
|
||||||
|
print(f"🔍 [Wishlist Processing] Checking completed tracks for wishlist removal")
|
||||||
|
for task_id in batch.get('queue', []):
|
||||||
|
if task_id in download_tasks:
|
||||||
|
task = download_tasks[task_id]
|
||||||
|
if task.get('status') == 'completed':
|
||||||
|
try:
|
||||||
|
track_info = task.get('track_info', {})
|
||||||
|
context = {'track_info': track_info, 'original_search_result': track_info}
|
||||||
|
_check_and_remove_from_wishlist(context)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"⚠️ [Wishlist Processing] Error removing completed track from wishlist: {e}")
|
||||||
|
|
||||||
# STEP 1: Add cancelled tracks that were missing to permanently_failed_tracks (replicating sync.py)
|
# STEP 1: Add cancelled tracks that were missing to permanently_failed_tracks (replicating sync.py)
|
||||||
# This matches sync.py's logic for adding cancelled missing tracks to the failed list
|
# This matches sync.py's logic for adding cancelled missing tracks to the failed list
|
||||||
if cancelled_tracks:
|
if cancelled_tracks:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue