sigma67 / ytmusicapi

Unofficial API for YouTube Music
https://ytmusicapi.readthedocs.io
MIT License
1.59k stars 183 forks source link

Return actual track positions #509

Closed jcbirdwell closed 5 months ago

jcbirdwell commented 6 months ago

Is your feature request related to a problem? Please describe. Occasionally some albums will appear on YouTube music with tracks completely missing (not just unavailable). In these cases using the index of the returned track list is insufficient for positioning all tracks. The correct indexing for these tracks is still maintained on YouTube, but the value isn't parsed from the response.

Describe the solution you'd like Add the track_position key to songs parsed in parse_playlist_items and its corresponding lookup path to the response value.

Describe alternatives you've considered

  1. Ignore it (never).
  2. Separate method for pulling true indexes (seems silly when the value is already there)
  3. The path to a song's index in the response is similar to other keys (duration) and provides potential for refactoring out something similar to navigation.nav for extracting these values. I left it as a basic index lookup for now (similar to nearby stuff) as I'm currently unfamiliar with the labyrinth of parsing code and didn't want to dig into it.

Additional context The album that originally threw the error in my code while using native indexing (browseId: MPREb_TPH4WqN5pUo) https://music.youtube.com/playlist?list=OLAK5uy_n7Xde1CFVX7Y8PeyGiAc2V4ieTRs3PML8

It seems to be a exceedingly rare occurrence.