Allow re-sync from download_complete state and add Rediscover button

All 6 playlist sync endpoints now accept download_complete phase so
users can re-sync after downloading. Added Rediscover button to
discovered and download_complete states (YouTube + Beatport). Added
full button set (Sync, Download Missing, Rediscover) for
download_complete which previously showed no buttons at all.
pull/253/head
Broque Thomas 2 months ago
parent 6ee20973a8
commit 46f82027cb

@ -27036,8 +27036,8 @@ def start_tidal_sync(playlist_id):
state = tidal_discovery_states[playlist_id]
state['last_accessed'] = time.time() # Update access time
if state['phase'] not in ['discovered', 'sync_complete']:
if state['phase'] not in ['discovered', 'sync_complete', 'download_complete']:
return jsonify({"error": "Tidal playlist not ready for sync"}), 400
# Convert discovery results to Spotify tracks format
@ -27865,7 +27865,7 @@ def start_deezer_sync(playlist_id):
state = deezer_discovery_states[playlist_id]
state['last_accessed'] = time.time()
if state['phase'] not in ['discovered', 'sync_complete']:
if state['phase'] not in ['discovered', 'sync_complete', 'download_complete']:
return jsonify({"error": "Deezer playlist not ready for sync"}), 400
# Convert discovery results to Spotify tracks format
@ -28692,7 +28692,7 @@ def start_spotify_public_sync(url_hash):
state = spotify_public_discovery_states[url_hash]
state['last_accessed'] = time.time()
if state['phase'] not in ['discovered', 'sync_complete']:
if state['phase'] not in ['discovered', 'sync_complete', 'download_complete']:
return jsonify({"error": "Spotify Public playlist not ready for sync"}), 400
# Convert discovery results to Spotify tracks format
@ -29728,8 +29728,8 @@ def start_youtube_sync(url_hash):
state = youtube_playlist_states[url_hash]
state['last_accessed'] = time.time() # Update access time
if state['phase'] not in ['discovered', 'sync_complete']:
if state['phase'] not in ['discovered', 'sync_complete', 'download_complete']:
return jsonify({"error": "YouTube playlist not ready for sync"}), 400
# Convert discovery results to Spotify tracks format
@ -35448,7 +35448,7 @@ def start_listenbrainz_sync(playlist_mbid):
state = listenbrainz_playlist_states[state_key]
state['last_accessed'] = time.time() # Update access time
if state['phase'] not in ['discovered', 'sync_complete']:
if state['phase'] not in ['discovered', 'sync_complete', 'download_complete']:
return jsonify({"error": "ListenBrainz playlist not ready for sync"}), 400
# Convert discovery results to Spotify tracks format
@ -37886,7 +37886,7 @@ def start_beatport_sync(url_hash):
print(f"🎧 Beatport chart state: phase={state.get('phase')}, has_discovery_results={len(state.get('discovery_results', []))}")
if state['phase'] not in ['discovered', 'sync_complete']:
if state['phase'] not in ['discovered', 'sync_complete', 'download_complete']:
print(f"❌ Beatport chart not ready for sync: {state['phase']}")
return jsonify({"error": "Beatport chart not ready for sync"}), 400

@ -29257,6 +29257,13 @@ function getModalActionButtons(urlHash, phase, state = null) {
}
}
// Rediscover button — reset and re-run discovery (only for sources with reset endpoints)
if (isBeatport) {
buttons += `<button class="modal-btn modal-btn-secondary" onclick="resetBeatportChart('${urlHash}')">🔄 Rediscover</button>`;
} else if (!isListenBrainz && !isTidal && !isDeezer && !isSpotifyPublic) {
buttons += `<button class="modal-btn modal-btn-secondary" onclick="resetYouTubePlaylist('${urlHash}')">🔄 Rediscover</button>`;
}
if (!buttons) {
buttons = `<div class="modal-info"> No Spotify matches found. Discovery complete but no tracks could be matched.</div>`;
}
@ -29371,19 +29378,60 @@ function getModalActionButtons(urlHash, phase, state = null) {
}
}
if (isListenBrainz) {
// ListenBrainz playlists don't need reset (they're read-only from ListenBrainz API)
} else if (isTidal) {
// Tidal doesn't have a reset function yet, but could be added
// syncCompleteButtons += `<button class="modal-btn modal-btn-secondary" onclick="resetTidalPlaylist('${urlHash}')">🔄 Reset</button>`;
} else if (isBeatport) {
syncCompleteButtons += `<button class="modal-btn modal-btn-secondary" onclick="resetBeatportChart('${urlHash}')">🔄 Reset</button>`;
} else {
syncCompleteButtons += `<button class="modal-btn modal-btn-secondary" onclick="resetYouTubePlaylist('${urlHash}')">🔄 Reset</button>`;
// Rediscover button (only for sources with reset endpoints)
if (isBeatport) {
syncCompleteButtons += `<button class="modal-btn modal-btn-secondary" onclick="resetBeatportChart('${urlHash}')">🔄 Rediscover</button>`;
} else if (!isListenBrainz && !isTidal && !isDeezer && !isSpotifyPublic) {
syncCompleteButtons += `<button class="modal-btn modal-btn-secondary" onclick="resetYouTubePlaylist('${urlHash}')">🔄 Rediscover</button>`;
}
return syncCompleteButtons;
case 'download_complete':
// Same options as sync_complete — allow re-sync, download missing, and reset
let dlCompleteButtons = '';
if (hasSpotifyMatches) {
if (isListenBrainz) {
dlCompleteButtons += `<button class="modal-btn modal-btn-primary" onclick="startListenBrainzPlaylistSync('${urlHash}')">🔄 Sync This Playlist</button>`;
} else if (isTidal) {
dlCompleteButtons += `<button class="modal-btn modal-btn-primary" onclick="startTidalPlaylistSync('${urlHash}')">🔄 Sync This Playlist</button>`;
} else if (isDeezer) {
dlCompleteButtons += `<button class="modal-btn modal-btn-primary" onclick="startDeezerPlaylistSync('${urlHash}')">🔄 Sync This Playlist</button>`;
} else if (isSpotifyPublic) {
dlCompleteButtons += `<button class="modal-btn modal-btn-primary" onclick="startSpotifyPublicPlaylistSync('${urlHash}')">🔄 Sync This Playlist</button>`;
} else if (isBeatport) {
dlCompleteButtons += `<button class="modal-btn modal-btn-primary" onclick="startBeatportPlaylistSync('${urlHash}')">🔄 Sync This Playlist</button>`;
} else {
dlCompleteButtons += `<button class="modal-btn modal-btn-primary" onclick="startYouTubePlaylistSync('${urlHash}')">🔄 Sync This Playlist</button>`;
}
}
if (hasSpotifyMatches || hasConvertedPlaylistId) {
if (isListenBrainz) {
dlCompleteButtons += `<button class="modal-btn modal-btn-primary" onclick="startYouTubeDownloadMissing('${urlHash}')">🔍 Download Missing Tracks</button>`;
} else if (isTidal) {
dlCompleteButtons += `<button class="modal-btn modal-btn-primary" onclick="startTidalDownloadMissing('${urlHash}')">🔍 Download Missing Tracks</button>`;
} else if (isDeezer) {
dlCompleteButtons += `<button class="modal-btn modal-btn-primary" onclick="startDeezerDownloadMissing('${urlHash}')">🔍 Download Missing Tracks</button>`;
} else if (isSpotifyPublic) {
dlCompleteButtons += `<button class="modal-btn modal-btn-primary" onclick="startSpotifyPublicDownloadMissing('${urlHash}')">🔍 Download Missing Tracks</button>`;
} else if (isBeatport) {
dlCompleteButtons += `<button class="modal-btn modal-btn-primary" onclick="startBeatportDownloadMissing('${urlHash}')">🔍 Download Missing Tracks</button>`;
} else {
dlCompleteButtons += `<button class="modal-btn modal-btn-primary" onclick="startYouTubeDownloadMissing('${urlHash}')">🔍 Download Missing Tracks</button>`;
}
}
// Rediscover button (only for sources with reset endpoints)
if (isBeatport) {
dlCompleteButtons += `<button class="modal-btn modal-btn-secondary" onclick="resetBeatportChart('${urlHash}')">🔄 Rediscover</button>`;
} else if (!isListenBrainz && !isTidal && !isDeezer && !isSpotifyPublic) {
dlCompleteButtons += `<button class="modal-btn modal-btn-secondary" onclick="resetYouTubePlaylist('${urlHash}')">🔄 Rediscover</button>`;
}
return dlCompleteButtons;
default:
return '';
}

Loading…
Cancel
Save