watchlist stuck fix
This commit is contained in:
parent
7e43a26408
commit
14548ec640
2 changed files with 47 additions and 3 deletions
|
|
@ -8218,6 +8218,7 @@ def start_wishlist_missing_downloads():
|
||||||
try:
|
try:
|
||||||
data = request.get_json() or {}
|
data = request.get_json() or {}
|
||||||
force_download_all = data.get('force_download_all', False)
|
force_download_all = data.get('force_download_all', False)
|
||||||
|
category = data.get('category') # Get category filter (albums or singles)
|
||||||
|
|
||||||
from core.wishlist_service import get_wishlist_service
|
from core.wishlist_service import get_wishlist_service
|
||||||
wishlist_service = get_wishlist_service()
|
wishlist_service = get_wishlist_service()
|
||||||
|
|
@ -8235,6 +8236,45 @@ def start_wishlist_missing_downloads():
|
||||||
|
|
||||||
print(f"🔧 [Manual-Wishlist] Sanitized {len(wishlist_tracks)} tracks from wishlist service")
|
print(f"🔧 [Manual-Wishlist] Sanitized {len(wishlist_tracks)} tracks from wishlist service")
|
||||||
|
|
||||||
|
# FILTER BY CATEGORY if specified (same logic as auto-processing)
|
||||||
|
if category:
|
||||||
|
import json
|
||||||
|
filtered_tracks = []
|
||||||
|
for track in wishlist_tracks:
|
||||||
|
# Extract track count from spotify_data
|
||||||
|
spotify_data = track.get('spotify_data', {})
|
||||||
|
if isinstance(spotify_data, str):
|
||||||
|
try:
|
||||||
|
spotify_data = json.loads(spotify_data)
|
||||||
|
except:
|
||||||
|
spotify_data = {}
|
||||||
|
|
||||||
|
album_data = spotify_data.get('album', {})
|
||||||
|
total_tracks = album_data.get('total_tracks')
|
||||||
|
album_type = album_data.get('album_type', 'album').lower()
|
||||||
|
|
||||||
|
# Categorize by track count if available, otherwise use album_type
|
||||||
|
# Single: 1 track, EP: 2-5 tracks, Album: 6+ tracks
|
||||||
|
is_single_or_ep = False
|
||||||
|
is_album = False
|
||||||
|
|
||||||
|
if total_tracks is not None and total_tracks > 0:
|
||||||
|
# Use track count (most accurate)
|
||||||
|
is_single_or_ep = total_tracks < 6
|
||||||
|
is_album = total_tracks >= 6
|
||||||
|
else:
|
||||||
|
# Fall back to Spotify's album_type
|
||||||
|
is_single_or_ep = album_type in ['single', 'ep']
|
||||||
|
is_album = album_type == 'album'
|
||||||
|
|
||||||
|
if category == 'singles' and is_single_or_ep:
|
||||||
|
filtered_tracks.append(track)
|
||||||
|
elif category == 'albums' and is_album:
|
||||||
|
filtered_tracks.append(track)
|
||||||
|
|
||||||
|
wishlist_tracks = filtered_tracks
|
||||||
|
print(f"🔍 [Manual-Wishlist] Filtered to {len(wishlist_tracks)} tracks for category: {category}")
|
||||||
|
|
||||||
# Add activity for wishlist download start
|
# Add activity for wishlist download start
|
||||||
add_activity_item("📥", "Wishlist Download Started", f"{len(wishlist_tracks)} tracks", "Now")
|
add_activity_item("📥", "Wishlist Download Started", f"{len(wishlist_tracks)} tracks", "Now")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5261,6 +5261,9 @@ async function openDownloadMissingWishlistModal(category = null) {
|
||||||
|
|
||||||
console.log(`📥 Opening Download Missing Tracks modal for wishlist${category ? ' (' + category + ')' : ''}`);
|
console.log(`📥 Opening Download Missing Tracks modal for wishlist${category ? ' (' + category + ')' : ''}`);
|
||||||
|
|
||||||
|
// Store category in global state for when process starts
|
||||||
|
window.currentWishlistCategory = category;
|
||||||
|
|
||||||
// Fetch actual wishlist tracks from the server
|
// Fetch actual wishlist tracks from the server
|
||||||
let tracks;
|
let tracks;
|
||||||
try {
|
try {
|
||||||
|
|
@ -5452,7 +5455,8 @@ async function startWishlistMissingTracksProcess(playlistId) {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
force_download_all: forceDownloadAll
|
force_download_all: forceDownloadAll,
|
||||||
|
category: window.currentWishlistCategory // Pass category to backend
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue