fix(db): playlist username fallback handling

This commit is contained in:
2025-10-04 20:38:59 -04:00
parent 05acc3483c
commit f4ef13ec0d
2 changed files with 10 additions and 2 deletions

View File

@@ -146,7 +146,7 @@ export async function upsertPlaylists(playlists: any[]): Promise<void> {
String(playlist.PLAYLIST_ID), String(playlist.PLAYLIST_ID),
playlist.TITLE || '', playlist.TITLE || '',
playlist.NB_SONG || 0, playlist.NB_SONG || 0,
playlist.PARENT_USERNAME || 'Unknown', playlist.PARENT_USERNAME || playlist._USER_NAME_FALLBACK || 'Unknown',
playlist.PLAYLIST_PICTURE || null, playlist.PLAYLIST_PICTURE || null,
playlist.PICTURE_TYPE || null, playlist.PICTURE_TYPE || null,
now now

View File

@@ -340,7 +340,15 @@ export class DeezerAPI {
nb: -1 nb: -1
}); });
return response.TAB?.playlists?.data || []; const playlists = response.TAB?.playlists?.data || [];
const userName = response.DATA?.USER?.BLOG_NAME || 'Unknown';
// Attach userName to each playlist for use as fallback in database
playlists.forEach((playlist: any) => {
playlist._USER_NAME_FALLBACK = userName;
});
return playlists;
} catch (error) { } catch (error) {
console.error('Error fetching playlists:', error); console.error('Error fetching playlists:', error);
return []; return [];