backup image for library artists
This commit is contained in:
parent
7b6e94772e
commit
e2351eaa5c
2 changed files with 11 additions and 4 deletions
|
|
@ -4318,13 +4318,14 @@ class MusicDatabase:
|
|||
a.musicbrainz_id,
|
||||
a.spotify_artist_id,
|
||||
a.itunes_artist_id,
|
||||
a.deezer_id,
|
||||
COUNT(DISTINCT al.id) as album_count,
|
||||
COUNT(DISTINCT t.id) as track_count
|
||||
FROM artists a
|
||||
LEFT JOIN albums al ON a.id = al.artist_id
|
||||
LEFT JOIN tracks t ON al.id = t.album_id
|
||||
WHERE {where_clause}
|
||||
GROUP BY a.id, a.name, a.thumb_url, a.genres, a.musicbrainz_id
|
||||
GROUP BY a.id, a.name, a.thumb_url, a.genres, a.musicbrainz_id, a.deezer_id
|
||||
ORDER BY a.name COLLATE NOCASE
|
||||
LIMIT ? OFFSET ?
|
||||
"""
|
||||
|
|
@ -4369,6 +4370,7 @@ class MusicDatabase:
|
|||
'image_url': artist.thumb_url,
|
||||
'genres': artist.genres,
|
||||
'musicbrainz_id': row['musicbrainz_id'],
|
||||
'deezer_id': row['deezer_id'],
|
||||
'album_count': row['album_count'] or 0,
|
||||
'track_count': row['track_count'] or 0,
|
||||
'is_watched': bool(is_watched)
|
||||
|
|
|
|||
|
|
@ -25649,9 +25649,14 @@ function createLibraryArtistCard(artist) {
|
|||
img.alt = artist.name;
|
||||
img.loading = 'lazy';
|
||||
img.onerror = () => {
|
||||
console.log(`Failed to load image for ${artist.name}: ${artist.image_url}`);
|
||||
// Replace with fallback on error
|
||||
imageContainer.innerHTML = `<div class="library-artist-image-fallback">🎵</div>`;
|
||||
console.log(`Failed to load image for ${artist.name}: ${img.src}`);
|
||||
// Try Deezer fallback before emoji
|
||||
if (artist.deezer_id && !img.dataset.triedDeezer) {
|
||||
img.dataset.triedDeezer = 'true';
|
||||
img.src = `https://api.deezer.com/artist/${artist.deezer_id}/image?size=big`;
|
||||
} else {
|
||||
imageContainer.innerHTML = `<div class="library-artist-image-fallback">🎵</div>`;
|
||||
}
|
||||
};
|
||||
img.onload = () => {
|
||||
console.log(`Successfully loaded image for ${artist.name}: ${artist.image_url}`);
|
||||
|
|
|
|||
Loading…
Reference in a new issue