Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: Return Track Numbers #236

Open
fatg3erman opened this issue Oct 10, 2022 · 6 comments
Open

FR: Return Track Numbers #236

fatg3erman opened this issue Oct 10, 2022 · 6 comments

Comments

@fatg3erman
Copy link
Contributor

Last one for now, I'm already convinced this is better than Spotify :). I'm pretty sure Youtube Music can return Track Numbers when the track is from an album - but obviously this isn't always relevant for YouTube videos. Is it possible to return them so that they're present when we do a search or retrieve Mopidy's tracklist?

@natumbri
Copy link
Owner

Ok, I can have a look at that. Shouldn't be too hard.

One of the tricks for me is to continue to have the three ways of accessing YouTube (YouTube API, scraping YouTube, and YT Music through ytmusicapi) working (and working at an acceptable speed).

The plugin predates YouTube Music, but I've had in mind for a while to properly support ytm albums and songs - I started doing some of the work, but life got busy. Track numbers and artists are two good examples of things that ytm brings that are absent (or, at best, unreliable) in normal YouTube.

Anyway, I'll see what I can do.

Not difficult to be better than Spotify when Spotify is irreparably broken! (Hopefully Google doesn't break this for us - it's happened before...)

1 similar comment
@natumbri
Copy link
Owner

Ok, I can have a look at that. Shouldn't be too hard.

One of the tricks for me is to continue to have the three ways of accessing YouTube (YouTube API, scraping YouTube, and YT Music through ytmusicapi) working (and working at an acceptable speed).

The plugin predates YouTube Music, but I've had in mind for a while to properly support ytm albums and songs - I started doing some of the work, but life got busy. Track numbers and artists are two good examples of things that ytm brings that are absent (or, at best, unreliable) in normal YouTube.

Anyway, I'll see what I can do.

Not difficult to be better than Spotify when Spotify is irreparably broken! (Hopefully Google doesn't break this for us - it's happened before...)

@natumbri
Copy link
Owner

I couldn't see where track numbers are returned by ytmusicapi, but YTMusic.get_album does return a list of tracks: assuming that the tracks are always in the right order, the track number could be inferred from the position in that list.

This would require changes to:

  • yt_listitem_to_playlist: where the list item includes tracks, add track numbers
  • ytm_item_to_video: to add the track number to the video item
  • extend_fields: to make sure track numbers are picked up when mopidy-youtube objects are created
  • _set_api_data: to set the track number field of a mopidy-youtube video where track number is known
  • a tracknumber() method in Video objects, with a fallback to None.
  • convert_video_to_track: to add the track number to the mopidy Track when it is created from the mopidy-youtube Video object, if a track number is available

@fatg3erman
Copy link
Contributor Author

fatg3erman commented Oct 11, 2022

I've just noticed that when I use the 'find file yt:playlist:....' addition you put in the other day, I DO get Track Numbers.

OK MPD 0.19.0
find file "youtube:playlist:MPREb_J8oBiEZMFNu"
file: youtube:video:eAOvikzmuGQ
Time: 210
Artist: Ed Sheeran
Album: Celestial
Title: Celestial
Track: 1
X-AlbumUri: yt:playlist:MPREb_J8oBiEZMFNu
OK

But I don't get them in search results. That track had already been found by a search for 'any "Ed Sheeran"' and it came back with no 'Track' field.

@natumbri
Copy link
Owner

I think it was adding a track number for all playlists, regardless of whether it was an album or not. I've made some changes; would be interested to hear if it is working for you.

I think a track number will only be returned if the track is known to be from a known album. Anyway, play around, let me know.

@fatg3erman
Copy link
Contributor Author

fatg3erman commented Oct 13, 2022

Sorry, not had a chance to try it for a few days.

In the testing I've done so far I find I am getting track numbers when I add random Uris to the play qeue.

But, they're often missing from search (they were before) but now when I do the lookup using 'find file' for those albums it doesn't return track numbers like it used to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants