better watchlist live status display for auto and manual scan
This commit is contained in:
parent
27f115d719
commit
6db4409d08
2 changed files with 359 additions and 66 deletions
271
web_server.py
271
web_server.py
|
|
@ -14638,26 +14638,42 @@ def start_watchlist_scan():
|
|||
'total_artists': len(watchlist_artists),
|
||||
'current_artist_index': 0,
|
||||
'current_artist_name': '',
|
||||
'current_artist_image_url': '',
|
||||
'current_phase': 'starting',
|
||||
'albums_to_check': 0,
|
||||
'albums_checked': 0,
|
||||
'current_album': '',
|
||||
'current_album_image_url': '',
|
||||
'current_track_name': '',
|
||||
'tracks_found_this_scan': 0,
|
||||
'tracks_added_this_scan': 0
|
||||
'tracks_added_this_scan': 0,
|
||||
'recent_wishlist_additions': []
|
||||
})
|
||||
|
||||
scan_results = []
|
||||
|
||||
for i, artist in enumerate(watchlist_artists):
|
||||
try:
|
||||
# Fetch artist image
|
||||
artist_image_url = ''
|
||||
try:
|
||||
artist_data = spotify_client.get_artist(artist.spotify_artist_id)
|
||||
if artist_data and 'images' in artist_data and artist_data['images']:
|
||||
artist_image_url = artist_data['images'][0]['url']
|
||||
except:
|
||||
pass
|
||||
|
||||
# Update progress
|
||||
watchlist_scan_state.update({
|
||||
'current_artist_index': i + 1,
|
||||
'current_artist_name': artist.artist_name,
|
||||
'current_artist_image_url': artist_image_url,
|
||||
'current_phase': 'fetching_discography',
|
||||
'albums_to_check': 0,
|
||||
'albums_checked': 0,
|
||||
'current_album': ''
|
||||
'current_album': '',
|
||||
'current_album_image_url': '',
|
||||
'current_track_name': ''
|
||||
})
|
||||
|
||||
# Get artist discography
|
||||
|
|
@ -14688,30 +14704,54 @@ def start_watchlist_scan():
|
|||
|
||||
# Scan each album
|
||||
for album_index, album in enumerate(albums):
|
||||
watchlist_scan_state.update({
|
||||
'albums_checked': album_index + 1,
|
||||
'current_album': album.name,
|
||||
'current_phase': f'checking_album_{album_index + 1}_of_{len(albums)}'
|
||||
})
|
||||
|
||||
try:
|
||||
# Get album tracks
|
||||
album_data = scanner.spotify_client.get_album(album.id)
|
||||
if not album_data or 'tracks' not in album_data:
|
||||
continue
|
||||
|
||||
|
||||
tracks = album_data['tracks']['items']
|
||||
|
||||
|
||||
# Get album image
|
||||
album_image_url = ''
|
||||
if 'images' in album_data and album_data['images']:
|
||||
album_image_url = album_data['images'][0]['url']
|
||||
|
||||
watchlist_scan_state.update({
|
||||
'albums_checked': album_index + 1,
|
||||
'current_album': album.name,
|
||||
'current_album_image_url': album_image_url,
|
||||
'current_phase': f'checking_album_{album_index + 1}_of_{len(albums)}'
|
||||
})
|
||||
|
||||
# Check each track
|
||||
for track in tracks:
|
||||
# Update current track being processed
|
||||
track_name = track.get('name', 'Unknown Track')
|
||||
watchlist_scan_state['current_track_name'] = track_name
|
||||
|
||||
if scanner.is_track_missing_from_library(track):
|
||||
artist_new_tracks += 1
|
||||
watchlist_scan_state['tracks_found_this_scan'] += 1
|
||||
|
||||
|
||||
# Add to wishlist
|
||||
if scanner.add_track_to_wishlist(track, album_data, artist):
|
||||
artist_added_tracks += 1
|
||||
watchlist_scan_state['tracks_added_this_scan'] += 1
|
||||
|
||||
# Add to recent wishlist additions feed
|
||||
track_artists = track.get('artists', [])
|
||||
track_artist_name = track_artists[0].get('name', 'Unknown Artist') if track_artists else 'Unknown Artist'
|
||||
|
||||
watchlist_scan_state['recent_wishlist_additions'].insert(0, {
|
||||
'track_name': track_name,
|
||||
'artist_name': track_artist_name,
|
||||
'album_image_url': album_image_url
|
||||
})
|
||||
|
||||
# Keep only last 10
|
||||
if len(watchlist_scan_state['recent_wishlist_additions']) > 10:
|
||||
watchlist_scan_state['recent_wishlist_additions'].pop()
|
||||
|
||||
# Small delay between albums
|
||||
import time
|
||||
|
|
@ -15188,39 +15228,224 @@ def _process_watchlist_scan_automatically():
|
|||
|
||||
print(f"👁️ [Auto-Watchlist] Found {watchlist_count} artists in watchlist, starting automatic scan...")
|
||||
|
||||
# Update global scan state
|
||||
# Get list of artists to scan
|
||||
watchlist_artists = database.get_watchlist_artists()
|
||||
scanner = get_watchlist_scanner(spotify_client)
|
||||
|
||||
# Initialize detailed progress tracking (same as manual scan)
|
||||
watchlist_scan_state = {
|
||||
'status': 'scanning',
|
||||
'started_at': datetime.now(),
|
||||
'total_artists': len(watchlist_artists),
|
||||
'current_artist_index': 0,
|
||||
'current_artist_name': '',
|
||||
'current_artist_image_url': '',
|
||||
'current_phase': 'starting',
|
||||
'albums_to_check': 0,
|
||||
'albums_checked': 0,
|
||||
'current_album': '',
|
||||
'current_album_image_url': '',
|
||||
'current_track_name': '',
|
||||
'tracks_found_this_scan': 0,
|
||||
'tracks_added_this_scan': 0,
|
||||
'recent_wishlist_additions': [],
|
||||
'results': [],
|
||||
'summary': {},
|
||||
'error': None
|
||||
}
|
||||
|
||||
# Run the scan
|
||||
scanner = get_watchlist_scanner(spotify_client)
|
||||
results = scanner.scan_all_watchlist_artists()
|
||||
scan_results = []
|
||||
|
||||
# Scan each artist with detailed tracking
|
||||
for i, artist in enumerate(watchlist_artists):
|
||||
try:
|
||||
# Fetch artist image
|
||||
artist_image_url = ''
|
||||
try:
|
||||
artist_data = spotify_client.get_artist(artist.spotify_artist_id)
|
||||
if artist_data and 'images' in artist_data and artist_data['images']:
|
||||
artist_image_url = artist_data['images'][0]['url']
|
||||
except:
|
||||
pass
|
||||
|
||||
# Update progress
|
||||
watchlist_scan_state.update({
|
||||
'current_artist_index': i + 1,
|
||||
'current_artist_name': artist.artist_name,
|
||||
'current_artist_image_url': artist_image_url,
|
||||
'current_phase': 'fetching_discography',
|
||||
'albums_to_check': 0,
|
||||
'albums_checked': 0,
|
||||
'current_album': '',
|
||||
'current_album_image_url': '',
|
||||
'current_track_name': ''
|
||||
})
|
||||
|
||||
# Get artist discography
|
||||
albums = scanner.get_artist_discography(artist.spotify_artist_id, artist.last_scan_timestamp)
|
||||
|
||||
if albums is None:
|
||||
scan_results.append(type('ScanResult', (), {
|
||||
'artist_name': artist.artist_name,
|
||||
'spotify_artist_id': artist.spotify_artist_id,
|
||||
'albums_checked': 0,
|
||||
'new_tracks_found': 0,
|
||||
'tracks_added_to_wishlist': 0,
|
||||
'success': False,
|
||||
'error_message': "Failed to get artist discography"
|
||||
})())
|
||||
continue
|
||||
|
||||
# Update with album count
|
||||
watchlist_scan_state.update({
|
||||
'current_phase': 'checking_albums',
|
||||
'albums_to_check': len(albums),
|
||||
'albums_checked': 0
|
||||
})
|
||||
|
||||
# Track progress for this artist
|
||||
artist_new_tracks = 0
|
||||
artist_added_tracks = 0
|
||||
|
||||
# Scan each album
|
||||
for album_index, album in enumerate(albums):
|
||||
try:
|
||||
# Get album tracks
|
||||
album_data = scanner.spotify_client.get_album(album.id)
|
||||
if not album_data or 'tracks' not in album_data:
|
||||
continue
|
||||
|
||||
tracks = album_data['tracks']['items']
|
||||
|
||||
# Get album image
|
||||
album_image_url = ''
|
||||
if 'images' in album_data and album_data['images']:
|
||||
album_image_url = album_data['images'][0]['url']
|
||||
|
||||
watchlist_scan_state.update({
|
||||
'albums_checked': album_index + 1,
|
||||
'current_album': album.name,
|
||||
'current_album_image_url': album_image_url,
|
||||
'current_phase': f'checking_album_{album_index + 1}_of_{len(albums)}'
|
||||
})
|
||||
|
||||
# Check each track
|
||||
for track in tracks:
|
||||
# Update current track being processed
|
||||
track_name = track.get('name', 'Unknown Track')
|
||||
watchlist_scan_state['current_track_name'] = track_name
|
||||
|
||||
if scanner.is_track_missing_from_library(track):
|
||||
artist_new_tracks += 1
|
||||
watchlist_scan_state['tracks_found_this_scan'] += 1
|
||||
|
||||
# Add to wishlist
|
||||
if scanner.add_track_to_wishlist(track, album_data, artist):
|
||||
artist_added_tracks += 1
|
||||
watchlist_scan_state['tracks_added_this_scan'] += 1
|
||||
|
||||
# Add to recent wishlist additions feed
|
||||
track_artists = track.get('artists', [])
|
||||
track_artist_name = track_artists[0].get('name', 'Unknown Artist') if track_artists else 'Unknown Artist'
|
||||
|
||||
watchlist_scan_state['recent_wishlist_additions'].insert(0, {
|
||||
'track_name': track_name,
|
||||
'artist_name': track_artist_name,
|
||||
'album_image_url': album_image_url
|
||||
})
|
||||
|
||||
# Keep only last 10
|
||||
if len(watchlist_scan_state['recent_wishlist_additions']) > 10:
|
||||
watchlist_scan_state['recent_wishlist_additions'].pop()
|
||||
|
||||
# Small delay between albums
|
||||
import time
|
||||
time.sleep(0.5)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error checking album {album.name}: {e}")
|
||||
continue
|
||||
|
||||
# Update scan timestamp
|
||||
scanner.update_artist_scan_timestamp(artist.spotify_artist_id)
|
||||
|
||||
# Store result
|
||||
scan_results.append(type('ScanResult', (), {
|
||||
'artist_name': artist.artist_name,
|
||||
'spotify_artist_id': artist.spotify_artist_id,
|
||||
'albums_checked': len(albums),
|
||||
'new_tracks_found': artist_new_tracks,
|
||||
'tracks_added_to_wishlist': artist_added_tracks,
|
||||
'success': True,
|
||||
'error_message': None
|
||||
})())
|
||||
|
||||
print(f"✅ Scanned {artist.artist_name}: {artist_new_tracks} new tracks found, {artist_added_tracks} added to wishlist")
|
||||
|
||||
# Delay between artists
|
||||
if i < len(watchlist_artists) - 1:
|
||||
watchlist_scan_state['current_phase'] = 'rate_limiting'
|
||||
time.sleep(2.0)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error scanning artist {artist.artist_name}: {e}")
|
||||
scan_results.append(type('ScanResult', (), {
|
||||
'artist_name': artist.artist_name,
|
||||
'spotify_artist_id': artist.spotify_artist_id,
|
||||
'albums_checked': 0,
|
||||
'new_tracks_found': 0,
|
||||
'tracks_added_to_wishlist': 0,
|
||||
'success': False,
|
||||
'error_message': str(e)
|
||||
})())
|
||||
continue
|
||||
|
||||
# Update state with results
|
||||
watchlist_scan_state['status'] = 'completed'
|
||||
watchlist_scan_state['results'] = results
|
||||
watchlist_scan_state['completed_at'] = datetime.now()
|
||||
|
||||
# Calculate summary
|
||||
successful_scans = [r for r in results if r.success]
|
||||
successful_scans = [r for r in scan_results if r.success]
|
||||
total_new_tracks = sum(r.new_tracks_found for r in successful_scans)
|
||||
total_added_to_wishlist = sum(r.tracks_added_to_wishlist for r in successful_scans)
|
||||
|
||||
watchlist_scan_state['status'] = 'completed'
|
||||
watchlist_scan_state['results'] = scan_results
|
||||
watchlist_scan_state['completed_at'] = datetime.now()
|
||||
watchlist_scan_state['summary'] = {
|
||||
'total_artists': len(results),
|
||||
'total_artists': len(scan_results),
|
||||
'successful_scans': len(successful_scans),
|
||||
'new_tracks_found': total_new_tracks,
|
||||
'tracks_added_to_wishlist': total_added_to_wishlist
|
||||
}
|
||||
|
||||
print(f"Automatic watchlist scan completed: {len(successful_scans)}/{len(results)} artists scanned successfully")
|
||||
print(f"Automatic watchlist scan completed: {len(successful_scans)}/{len(scan_results)} artists scanned successfully")
|
||||
print(f"Found {total_new_tracks} new tracks, added {total_added_to_wishlist} to wishlist")
|
||||
|
||||
# Populate discovery pool from similar artists
|
||||
print("🎵 Starting discovery pool population...")
|
||||
watchlist_scan_state['current_phase'] = 'populating_discovery_pool'
|
||||
try:
|
||||
scanner.populate_discovery_pool()
|
||||
print("✅ Discovery pool population complete")
|
||||
except Exception as discovery_error:
|
||||
print(f"⚠️ Error populating discovery pool: {discovery_error}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
# Update ListenBrainz playlists cache
|
||||
print("🧠 Starting ListenBrainz playlists update...")
|
||||
watchlist_scan_state['current_phase'] = 'updating_listenbrainz'
|
||||
try:
|
||||
from core.listenbrainz_manager import ListenBrainzManager
|
||||
lb_manager = ListenBrainzManager("database/music_library.db")
|
||||
lb_result = lb_manager.update_all_playlists()
|
||||
if lb_result.get('success'):
|
||||
summary = lb_result.get('summary', {})
|
||||
print(f"✅ ListenBrainz update complete: {summary}")
|
||||
else:
|
||||
print(f"⚠️ ListenBrainz update had issues: {lb_result.get('error', 'Unknown error')}")
|
||||
except Exception as lb_error:
|
||||
print(f"⚠️ Error updating ListenBrainz: {lb_error}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
# Add activity for watchlist scan completion
|
||||
if total_added_to_wishlist > 0:
|
||||
add_activity_item("👁️", "Watchlist Scan Complete", f"{total_added_to_wishlist} new tracks added to wishlist", "Now")
|
||||
|
|
|
|||
|
|
@ -19772,15 +19772,38 @@ async function showWatchlistModal() {
|
|||
modal.innerHTML = `
|
||||
<div class="modal-container playlist-modal">
|
||||
<div class="playlist-modal-header">
|
||||
<div class="playlist-header-content">
|
||||
<div class="playlist-header-content" style="width: 100%;">
|
||||
<h2>👁️ Watchlist</h2>
|
||||
<div class="playlist-quick-info">
|
||||
<span class="playlist-track-count">${countData.count} artist${countData.count !== 1 ? 's' : ''}</span>
|
||||
</div>
|
||||
<div class="playlist-modal-sync-status" id="watchlist-scan-status" style="display: ${scanStatus !== 'idle' ? 'block' : 'none'};">
|
||||
<div class="scan-status-main">
|
||||
<span class="sync-stat"><span id="scan-status-text">${scanStatus}</span></span>
|
||||
<div class="playlist-modal-sync-status" id="watchlist-scan-status" style="display: ${scanStatus !== 'idle' ? 'flex' : 'none'}; flex-direction: column; align-items: center;">
|
||||
<!-- Live Visual Activity Display -->
|
||||
<div id="watchlist-live-activity" style="display: ${scanStatus === 'scanning' ? 'flex' : 'none'}; gap: 15px; margin-top: 15px; padding: 15px; background: #2a2a2a; border-radius: 8px; border: 1px solid #444; justify-content: center; align-items: flex-start;">
|
||||
<!-- Artist Photo -->
|
||||
<div style="display: flex; flex-direction: column; align-items: center; gap: 8px;">
|
||||
<img id="watchlist-artist-img" src="" alt="Artist" style="width: 80px; height: 80px; border-radius: 50%; border: 2px solid #1db954; object-fit: cover; background: #1a1a1a;" onerror="this.style.display='none';" />
|
||||
<div id="watchlist-artist-name" style="font-size: 11px; font-weight: bold; color: #fff; text-align: center; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">Waiting...</div>
|
||||
</div>
|
||||
|
||||
<!-- Album Cover -->
|
||||
<div style="display: flex; flex-direction: column; align-items: center; gap: 8px;">
|
||||
<img id="watchlist-album-img" src="" alt="Album" style="width: 80px; height: 80px; border-radius: 6px; border: 2px solid #ffc107; object-fit: cover; background: #1a1a1a;" onerror="this.style.display='none';" />
|
||||
<div id="watchlist-album-name" style="font-size: 11px; font-weight: bold; color: #fff; text-align: center; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">Waiting...</div>
|
||||
</div>
|
||||
|
||||
<!-- Track and Wishlist Feed -->
|
||||
<div style="display: flex; flex-direction: column; gap: 6px; min-width: 250px; max-width: 300px;">
|
||||
<div style="font-size: 10px; color: #b3b3b3; text-transform: uppercase;">Current Track:</div>
|
||||
<div id="watchlist-track-name" style="font-size: 11px; font-weight: bold; color: #1ed760; margin-bottom: 8px;">Waiting...</div>
|
||||
|
||||
<div style="font-size: 10px; color: #ff9800; text-transform: uppercase;">✨ Recently Added:</div>
|
||||
<div id="watchlist-additions-feed" style="max-height: 80px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; font-size: 10px;">
|
||||
<!-- Populated by JavaScript -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
${statusData.summary ? `
|
||||
<div class="scan-status-summary" style="margin-top: 8px; font-size: 13px; opacity: 0.8;">
|
||||
<span class="sync-stat">Artists: ${statusData.summary.total_artists || 0}</span>
|
||||
|
|
@ -20131,14 +20154,13 @@ async function startWatchlistScan() {
|
|||
}
|
||||
|
||||
button.textContent = 'Scanning...';
|
||||
|
||||
|
||||
// Show scan status
|
||||
const statusDiv = document.getElementById('watchlist-scan-status');
|
||||
if (statusDiv) {
|
||||
statusDiv.style.display = 'flex';
|
||||
document.getElementById('scan-status-text').textContent = 'scanning';
|
||||
}
|
||||
|
||||
|
||||
// Start polling for updates
|
||||
pollWatchlistScanStatus();
|
||||
|
||||
|
|
@ -20160,35 +20182,62 @@ async function pollWatchlistScanStatus() {
|
|||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
const statusText = document.getElementById('scan-status-text');
|
||||
const button = document.getElementById('scan-watchlist-btn');
|
||||
|
||||
if (statusText) {
|
||||
// Show detailed progress if scanning
|
||||
if (data.status === 'scanning' && data.current_artist_name) {
|
||||
const artistProgress = `${data.current_artist_index || 0}/${data.total_artists || 0}`;
|
||||
let detailText = `Scanning ${data.current_artist_name} (${artistProgress})`;
|
||||
|
||||
if (data.current_phase === 'fetching_discography') {
|
||||
detailText += ' - Fetching releases...';
|
||||
} else if (data.current_phase === 'checking_albums' && data.albums_to_check > 0) {
|
||||
const albumProgress = `${data.albums_checked || 0}/${data.albums_to_check}`;
|
||||
detailText += ` - Checking albums (${albumProgress})`;
|
||||
} else if (data.current_phase && data.current_phase.startsWith('checking_album_')) {
|
||||
detailText += ` - "${data.current_album || 'Unknown Album'}"`;
|
||||
} else if (data.current_phase === 'rate_limiting') {
|
||||
detailText += ' - Rate limiting...';
|
||||
}
|
||||
|
||||
// Add running totals
|
||||
if (data.tracks_found_this_scan > 0 || data.tracks_added_this_scan > 0) {
|
||||
detailText += ` | Found: ${data.tracks_found_this_scan || 0}, Added: ${data.tracks_added_this_scan || 0}`;
|
||||
}
|
||||
|
||||
statusText.textContent = detailText;
|
||||
} else {
|
||||
statusText.textContent = data.status;
|
||||
const liveActivity = document.getElementById('watchlist-live-activity');
|
||||
|
||||
// Update live visual activity display
|
||||
if (liveActivity && data.status === 'scanning') {
|
||||
liveActivity.style.display = 'flex';
|
||||
|
||||
// Update artist image and name
|
||||
const artistImg = document.getElementById('watchlist-artist-img');
|
||||
const artistName = document.getElementById('watchlist-artist-name');
|
||||
if (artistImg && data.current_artist_image_url) {
|
||||
artistImg.src = data.current_artist_image_url;
|
||||
artistImg.style.display = 'block';
|
||||
}
|
||||
if (artistName) {
|
||||
artistName.textContent = data.current_artist_name || 'Processing...';
|
||||
}
|
||||
|
||||
// Update album image and name
|
||||
const albumImg = document.getElementById('watchlist-album-img');
|
||||
const albumName = document.getElementById('watchlist-album-name');
|
||||
if (albumImg && data.current_album_image_url) {
|
||||
albumImg.src = data.current_album_image_url;
|
||||
albumImg.style.display = 'block';
|
||||
} else if (albumImg) {
|
||||
albumImg.style.display = 'none';
|
||||
}
|
||||
if (albumName) {
|
||||
albumName.textContent = data.current_album || (data.current_phase === 'fetching_discography' ? 'Fetching releases...' : 'Processing...');
|
||||
}
|
||||
|
||||
// Update current track
|
||||
const trackName = document.getElementById('watchlist-track-name');
|
||||
if (trackName) {
|
||||
trackName.textContent = data.current_track_name || (data.current_phase === 'fetching_discography' ? 'Fetching releases...' : 'Processing...');
|
||||
}
|
||||
|
||||
// Update wishlist additions feed
|
||||
const additionsFeed = document.getElementById('watchlist-additions-feed');
|
||||
if (additionsFeed) {
|
||||
if (data.recent_wishlist_additions && data.recent_wishlist_additions.length > 0) {
|
||||
additionsFeed.innerHTML = data.recent_wishlist_additions.map(item => `
|
||||
<div style="display: flex; gap: 6px; align-items: center; padding: 3px; background: #1a1a1a; border-radius: 4px;">
|
||||
<img src="${item.album_image_url || ''}" alt="" style="width: 24px; height: 24px; border-radius: 3px; object-fit: cover;" onerror="this.style.display='none';" />
|
||||
<div style="flex: 1; overflow: hidden;">
|
||||
<div style="font-weight: bold; color: #1ed760; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${item.track_name}</div>
|
||||
<div style="font-size: 9px; color: #b3b3b3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${item.artist_name}</div>
|
||||
</div>
|
||||
</div>
|
||||
`).join('');
|
||||
} else {
|
||||
additionsFeed.innerHTML = '<div style="color: #666; font-size: 10px;">No tracks added yet...</div>';
|
||||
}
|
||||
}
|
||||
} else if (liveActivity && data.status !== 'scanning') {
|
||||
liveActivity.style.display = 'none';
|
||||
}
|
||||
|
||||
if (data.status === 'completed') {
|
||||
|
|
@ -20196,15 +20245,20 @@ async function pollWatchlistScanStatus() {
|
|||
button.disabled = false;
|
||||
button.textContent = 'Scan for New Releases';
|
||||
}
|
||||
|
||||
// Update status display with results
|
||||
|
||||
// Hide live activity
|
||||
if (liveActivity) {
|
||||
liveActivity.style.display = 'none';
|
||||
}
|
||||
|
||||
// Show completion message in status div
|
||||
const statusDiv = document.getElementById('watchlist-scan-status');
|
||||
if (statusDiv && data.summary) {
|
||||
const newTracks = data.summary.new_tracks_found || 0;
|
||||
const addedTracks = data.summary.tracks_added_to_wishlist || 0;
|
||||
const totalArtists = data.summary.total_artists || 0;
|
||||
const successfulScans = data.summary.successful_scans || 0;
|
||||
|
||||
|
||||
let completionMessage = `Scan completed: ${successfulScans}/${totalArtists} artists scanned`;
|
||||
if (newTracks > 0) {
|
||||
completionMessage += `, found ${newTracks} new track${newTracks !== 1 ? 's' : ''}`;
|
||||
|
|
@ -20214,25 +20268,39 @@ async function pollWatchlistScanStatus() {
|
|||
} else {
|
||||
completionMessage += ', no new tracks found';
|
||||
}
|
||||
|
||||
|
||||
// Update the scan status display with completion message and summary
|
||||
statusDiv.innerHTML = `
|
||||
<div class="scan-status-main">
|
||||
<span class="sync-stat">${completionMessage}</span>
|
||||
<div style="text-align: center; padding: 15px; background: #2a2a2a; border-radius: 8px; border: 1px solid #444;">
|
||||
<div style="font-size: 14px; color: #1ed760; margin-bottom: 10px;">${completionMessage}</div>
|
||||
<div style="font-size: 13px; opacity: 0.8;">
|
||||
<span class="sync-stat">Artists: ${totalArtists}</span>
|
||||
<span class="sync-separator"> • </span>
|
||||
<span class="sync-stat">New tracks: ${newTracks}</span>
|
||||
<span class="sync-separator"> • </span>
|
||||
<span class="sync-stat">Added to wishlist: ${addedTracks}</span>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
// Update watchlist count
|
||||
updateWatchlistButtonCount();
|
||||
|
||||
|
||||
console.log('Watchlist scan completed:', data.summary);
|
||||
return; // Stop polling
|
||||
|
||||
|
||||
} else if (data.status === 'error') {
|
||||
if (button) {
|
||||
button.disabled = false;
|
||||
button.textContent = 'Scan for New Releases';
|
||||
}
|
||||
|
||||
// Hide live activity
|
||||
if (liveActivity) {
|
||||
liveActivity.style.display = 'none';
|
||||
}
|
||||
|
||||
console.error('Watchlist scan error:', data.error);
|
||||
return; // Stop polling
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue