Skip to content

get_playlist: support audio playlists#696

Merged
sigma67 merged 1 commit intosigma67:mainfrom
sgvictorino:get-audio-playlist
Dec 28, 2024
Merged

get_playlist: support audio playlists#696
sigma67 merged 1 commit intosigma67:mainfrom
sgvictorino:get-audio-playlist

Conversation

@sgvictorino
Copy link
Copy Markdown
Collaborator

No description provided.

@sgvictorino sgvictorino marked this pull request as draft December 18, 2024 00:55
@codecov
Copy link
Copy Markdown

codecov bot commented Dec 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.11%. Comparing base (b86654f) to head (0503d3b).
Report is 19 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #696      +/-   ##
==========================================
+ Coverage   95.07%   95.11%   +0.03%     
==========================================
  Files          40       40              
  Lines        2357     2376      +19     
==========================================
+ Hits         2241     2260      +19     
  Misses        116      116              
Flag Coverage Δ
unittests 95.11% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sgvictorino sgvictorino marked this pull request as ready for review December 18, 2024 02:06
@sigma67
Copy link
Copy Markdown
Owner

sigma67 commented Dec 22, 2024

You're trying to support albums with get_playlist.

Albums are meant to be retrieved with get_album.

I don't see the value in supporting the same content with two different endpoints.

@sigma67
Copy link
Copy Markdown
Owner

sigma67 commented Dec 22, 2024

I realize that right now it's maybe not convenient to call get_album_browse_id(audioPlaylistId) before calling get_album(browseId), but that's just how the API works

@sigma67
Copy link
Copy Markdown
Owner

sigma67 commented Dec 22, 2024

Please also following CONTRIBUTING.rst for more involved changes so wasted effort can be prevented:

https://github.com/sigma67/ytmusicapi/blob/main/CONTRIBUTING.rst#pull-requests

Please open an issue before submitting, unless it's just a typo or some other small error.

@sgvictorino
Copy link
Copy Markdown
Collaborator Author

sgvictorino commented Dec 22, 2024

I think it's useful for listing the audio counterparts, while get_album returns music videos:

>>> yt = YTMusic()
>>> playlist = "OLAK5uy_kzi7k-3sR60kgaRt8HpK2zBN6jlNOMoHw"
>>> [(s["videoId"], s["videoType"]) for s in yt.get_album(yt.get_album_browse_id(playlist))["tracks"]]
[('S9bCLPwzSC0', 'MUSIC_VIDEO_TYPE_OMV'), ('6CQ8FIRzjnk', 'MUSIC_VIDEO_TYPE_ATV'), ('sbCe_L_hXi0', 'MUSIC_VIDEO_TYPE_ATV')]
>>> [(s["videoId"], s["videoType"]) for s in yt.get_playlist(playlist)["tracks"]]
[('clxG52zpxIg', 'MUSIC_VIDEO_TYPE_ATV'), ('6CQ8FIRzjnk', 'MUSIC_VIDEO_TYPE_ATV'), ('sbCe_L_hXi0', 'MUSIC_VIDEO_TYPE_ATV')]

@sigma67
Copy link
Copy Markdown
Owner

sigma67 commented Dec 27, 2024

Ok fair, I guess they do actually return different content. I would accept this if you could move the separate parsing for audio playlists into a separate parsing function.

Don't make the audioPlaylist codepath dependent on a property of the data, instead make it dependent on the playlistId. If it starts with OLA, use the separate function for parsing the data.

This should avoid mangling the code with too many if else statements while keeping it somewhat readable.

Copy link
Copy Markdown
Owner

@sigma67 sigma67 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, almost finished

Comment thread ytmusicapi/mixins/playlists.py Outdated
Comment thread ytmusicapi/mixins/playlists.py Outdated
Comment thread ytmusicapi/mixins/playlists.py Outdated
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move to parsers/playlists.py. Sorry if I wasn't clear here.

The idea is that the mixins contain only the public API and everything related to parsing goes into a parsers/xx file.

@sigma67 sigma67 merged commit 3bd3da1 into sigma67:main Dec 28, 2024
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

Successfully merging this pull request may close these issues.

2 participants