fix the 'fix' modal on discovery modal if track is incorrect
This commit is contained in:
parent
c48ac1d4f9
commit
e66ed32463
3 changed files with 34 additions and 17 deletions
|
|
@ -15832,7 +15832,8 @@ def update_tidal_discovery_match():
|
|||
'id': spotify_track['id'],
|
||||
'name': spotify_track['name'],
|
||||
'artists': spotify_track['artists'],
|
||||
'album': spotify_track['album']
|
||||
'album': spotify_track['album'],
|
||||
'duration_ms': spotify_track.get('duration_ms', 0)
|
||||
}
|
||||
|
||||
result['manual_match'] = True # Flag for tracking
|
||||
|
|
@ -16758,7 +16759,8 @@ def update_youtube_discovery_match():
|
|||
'id': spotify_track['id'],
|
||||
'name': spotify_track['name'],
|
||||
'artists': spotify_track['artists'],
|
||||
'album': spotify_track['album']
|
||||
'album': spotify_track['album'],
|
||||
'duration_ms': spotify_track.get('duration_ms', 0)
|
||||
}
|
||||
|
||||
result['manual_match'] = True # Flag for tracking
|
||||
|
|
@ -21397,14 +21399,28 @@ def update_listenbrainz_discovery_match():
|
|||
result['status'] = '✅ Found' if spotify_track else '❌ Not Found'
|
||||
result['status_class'] = 'found' if spotify_track else 'not-found'
|
||||
result['spotify_track'] = spotify_track.get('name', '') if spotify_track else ''
|
||||
result['spotify_artist'] = spotify_track.get('artists', [''])[0] if spotify_track and spotify_track.get('artists') else ''
|
||||
result['spotify_album'] = spotify_track.get('album', {}).get('name', '') if spotify_track else ''
|
||||
# Join all artists (matching YouTube/Tidal/Beatport format)
|
||||
artists = spotify_track.get('artists', []) if spotify_track else []
|
||||
result['spotify_artist'] = ', '.join(artists) if isinstance(artists, list) else artists
|
||||
# Album comes as a string from the frontend fix modal
|
||||
album = spotify_track.get('album', '') if spotify_track else ''
|
||||
result['spotify_album'] = album if isinstance(album, str) else album.get('name', '') if isinstance(album, dict) else ''
|
||||
result['spotify_id'] = spotify_track.get('id', '') if spotify_track else ''
|
||||
|
||||
if spotify_track:
|
||||
result['spotify_data'] = spotify_track
|
||||
# Store spotify_data in the same format as other platforms
|
||||
result['spotify_data'] = {
|
||||
'id': spotify_track.get('id', ''),
|
||||
'name': spotify_track.get('name', ''),
|
||||
'artists': artists if isinstance(artists, list) else [artists],
|
||||
'album': result['spotify_album'],
|
||||
'duration_ms': spotify_track.get('duration_ms', 0)
|
||||
}
|
||||
else:
|
||||
result['spotify_data'] = None
|
||||
|
||||
result['manual_match'] = True
|
||||
|
||||
print(f"✅ Updated ListenBrainz match for track {track_index}: {result['status']}")
|
||||
return jsonify({'success': True})
|
||||
else:
|
||||
|
|
@ -23314,7 +23330,8 @@ def update_beatport_discovery_match():
|
|||
'id': spotify_track['id'],
|
||||
'name': spotify_track['name'],
|
||||
'artists': spotify_track['artists'],
|
||||
'album': spotify_track['album']
|
||||
'album': spotify_track['album'],
|
||||
'duration_ms': spotify_track.get('duration_ms', 0)
|
||||
}
|
||||
|
||||
result['manual_match'] = True # Flag for tracking
|
||||
|
|
|
|||
|
|
@ -10096,8 +10096,8 @@ function openDiscoveryFixModal(platform, identifier, trackIndex) {
|
|||
platform,
|
||||
identifier,
|
||||
trackIndex,
|
||||
sourceTrack: result.yt_track || result.tidal_track?.name || result.beatport_track?.title,
|
||||
sourceArtist: result.yt_artist || result.tidal_track?.artist || result.beatport_track?.artist
|
||||
sourceTrack: result.lb_track || result.yt_track || result.tidal_track?.name || result.beatport_track?.title || result.track_name || 'Unknown Track',
|
||||
sourceArtist: result.lb_artist || result.yt_artist || result.tidal_track?.artist || result.beatport_track?.artist || result.artist_name || 'Unknown Artist'
|
||||
};
|
||||
|
||||
// Find the fix modal within the active discovery modal
|
||||
|
|
@ -10119,11 +10119,11 @@ function openDiscoveryFixModal(platform, identifier, trackIndex) {
|
|||
console.log('🔍 Source artist:', currentDiscoveryFix.sourceArtist);
|
||||
console.log('🔍 Fix modal overlay found:', fixModalOverlay);
|
||||
|
||||
// Populate modal - use document.getElementById since IDs are unique globally
|
||||
const sourceTrackEl = document.getElementById('fix-modal-source-track');
|
||||
const sourceArtistEl = document.getElementById('fix-modal-source-artist');
|
||||
const trackInput = document.getElementById('fix-modal-track-input');
|
||||
const artistInput = document.getElementById('fix-modal-artist-input');
|
||||
// Populate modal - scope within the specific fix modal overlay to handle duplicate IDs
|
||||
const sourceTrackEl = fixModalOverlay.querySelector('#fix-modal-source-track');
|
||||
const sourceArtistEl = fixModalOverlay.querySelector('#fix-modal-source-artist');
|
||||
const trackInput = fixModalOverlay.querySelector('#fix-modal-track-input');
|
||||
const artistInput = fixModalOverlay.querySelector('#fix-modal-artist-input');
|
||||
|
||||
console.log('🔍 Elements found:', {
|
||||
sourceTrackEl,
|
||||
|
|
@ -10418,8 +10418,8 @@ async function selectDiscoveryFixTrack(track) {
|
|||
* Update a single row in the discovery modal table
|
||||
*/
|
||||
function updateDiscoveryModalSingleRow(platform, identifier, trackIndex) {
|
||||
// Note: Beatport and Tidal reuse youtubePlaylistStates for discovery results
|
||||
const state = youtubePlaylistStates[identifier];
|
||||
// Check both state maps - ListenBrainz uses its own, others reuse youtubePlaylistStates
|
||||
const state = listenbrainzPlaylistStates[identifier] || youtubePlaylistStates[identifier];
|
||||
|
||||
// Support both camelCase and snake_case
|
||||
const results = state?.discoveryResults || state?.discovery_results;
|
||||
|
|
@ -19450,7 +19450,7 @@ function startListenBrainzDiscoveryPolling(playlistMbid) {
|
|||
status_class: result.status_class || (result.status === 'found' || result.status === '✅ Found' ? 'found' : (result.status === 'error' ? 'error' : 'not-found')),
|
||||
spotify_track: result.spotify_data ? result.spotify_data.name : (result.spotify_track || '-'),
|
||||
spotify_artist: result.spotify_data ? (result.spotify_data.artists && result.spotify_data.artists[0] ? result.spotify_data.artists[0] : '-') : (result.spotify_artist || '-'),
|
||||
spotify_album: result.spotify_data ? (result.spotify_data.album && result.spotify_data.album.name ? result.spotify_data.album.name : '-') : (result.spotify_album || '-'),
|
||||
spotify_album: result.spotify_data ? (typeof result.spotify_data.album === 'object' ? result.spotify_data.album.name : result.spotify_data.album) || '-' : (result.spotify_album || '-'),
|
||||
spotify_data: result.spotify_data,
|
||||
duration: result.duration || '0:00'
|
||||
})),
|
||||
|
|
|
|||
|
|
@ -2832,7 +2832,7 @@ body {
|
|||
bottom: 20px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
z-index: 10000;
|
||||
z-index: 99999;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
|
|
|||
Loading…
Reference in a new issue