mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
Fix: Fetch full metadata for manual external mappings
Manual external mappings now fetch complete track metadata from the provider (SquidWTF) instead of using minimal Spotify metadata. This ensures proper IDs, artist IDs, album IDs, cover art, and all metadata needed for playback. Also fixed admin UI to properly detect manual external mappings so tracks show as 'External' instead of 'Missing'. Changes: - Fetch full Song metadata using GetSongAsync when manual mapping exists - Fallback to minimal metadata if fetch fails - Admin controller now checks isManualMapping flag to set correct status - Tracks with manual external mappings now show proper provider badge
This commit is contained in:
@@ -871,10 +871,38 @@ public class SpotifyTrackMatchingService : BackgroundService
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(provider) && !string.IsNullOrEmpty(externalId))
|
if (!string.IsNullOrEmpty(provider) && !string.IsNullOrEmpty(externalId))
|
||||||
{
|
{
|
||||||
// Create a matched track entry for the external mapping
|
// Fetch full metadata from the provider instead of using minimal Spotify data
|
||||||
var externalSong = new Song
|
Song? externalSong = null;
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
Id = $"ext-{provider}-song-{externalId}", // CRITICAL: Set proper ID format
|
using var metadataScope = _serviceProvider.CreateScope();
|
||||||
|
var metadataServiceForFetch = metadataScope.ServiceProvider.GetRequiredService<IMusicMetadataService>();
|
||||||
|
externalSong = await metadataServiceForFetch.GetSongAsync(provider, externalId);
|
||||||
|
|
||||||
|
if (externalSong != null)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("✓ Fetched full metadata for manual external mapping: {Title} by {Artist}",
|
||||||
|
externalSong.Title, externalSong.Artist);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Failed to fetch metadata for {Provider} ID {ExternalId}, using fallback",
|
||||||
|
provider, externalId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, "Error fetching metadata for {Provider} ID {ExternalId}, using fallback",
|
||||||
|
provider, externalId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback to minimal metadata if fetch failed
|
||||||
|
if (externalSong == null)
|
||||||
|
{
|
||||||
|
externalSong = new Song
|
||||||
|
{
|
||||||
|
Id = $"ext-{provider}-song-{externalId}",
|
||||||
Title = spotifyTrack.Title,
|
Title = spotifyTrack.Title,
|
||||||
Artist = spotifyTrack.PrimaryArtist,
|
Artist = spotifyTrack.PrimaryArtist,
|
||||||
Album = spotifyTrack.Album,
|
Album = spotifyTrack.Album,
|
||||||
@@ -884,6 +912,7 @@ public class SpotifyTrackMatchingService : BackgroundService
|
|||||||
ExternalProvider = provider,
|
ExternalProvider = provider,
|
||||||
ExternalId = externalId
|
ExternalId = externalId
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
var matchedTrack = new MatchedTrack
|
var matchedTrack = new MatchedTrack
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user