freyr-js icon indicating copy to clipboard operation
freyr-js copied to clipboard

Apple Music service assumes albums always have certain properties

Open KiruPoruno opened this issue 1 year ago • 2 comments

While playing around with this tool, I came across a persistent error:

Checking directory permissions...[done]
[https://music.apple.com/us/album/an-infinite-regression/478776210?i=467902919]
 [•] Identifying service...[Apple Music]
 [•] Checking authentication...[authenticated]
 Detected [track]
 Obtaining track metadata...(failed: [Cannot read properties of undefined (reading '0')])
 [i] An error occurred while processing the query

And it took a bit to realize $SHOW_DEBUG_STACK was a thing, but once that was the case it was easy to track down the issue:

[TypeError: Cannot read properties of undefined (reading '0')
    at AppleMusic.wrapTrackMeta (src/services/apple_music.js:166:38)
    at src/services/apple_music.js:315:21]

The issue stems from the Apple Music service assuming that all tracks have an artist set on the album, this isn't the case, as I realized, although rare, it does occur (as shown with the track in the logs), and the albumInfo.artists will in such a case just be undefined

Edit: After fixing the above locally, this also happens with albumInfo.tracks.reduce() a couple lines down...

KiruPoruno avatar Dec 03 '24 22:12 KiruPoruno

Hi @KiruPoruno, thanks for filing. Cases like these are difficult to preempt, as their potential absence is undocumented in the API and it just "makes sense" for it not to be optional.

I'll find some time to patch this, thanks for providing the link.

miraclx avatar Jan 06 '25 13:01 miraclx

I'm unsure if this is the exact same problem but it seems i'm having a similar issue

[https://music.apple.com/us/playlist/zzz-all-songs/pl.u-mJy8150Cz7mR3dB]
 [•] Identifying service...[Apple Music]
 [•] Checking authentication...[authenticated]
 Detected [playlist]
 Obtaining playlist metadata...[done]
  ➤ Playlist Name: zzz all songs
  ➤ By: Angel Thomas
  ➤ Type: User,Shared
  ➤ Tracks: 7416
 [•] Collating...
  [•] Inquiring tracks...(failed: [Cannot read properties of undefined (reading '0')])
 [i] An error occurred while processing the query (Failed to collect playlist tracks) 

allinduetime avatar Feb 23 '25 01:02 allinduetime