mirror of
https://github.com/sigma67/ytmusicapi.git
synced 2026-04-25 07:16:00 +03:00
[GH-ISSUE #365] Playlist 'trackCount' returning unexpected value #291
Labels
No labels
a/b
bug
documentation
enhancement
good first issue
help wanted
invalid
pull-request
question
wontfix
yt-error
yt-update
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ytmusicapi#291
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @JohnHKoh on GitHub (Mar 24, 2023).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/365
When using the
YTMusic.get_playlistmethod (documentation), getting thetrackCountvalue from the returned playlist object seems to return an unexpected value. This has only recently started happening.For example, the playlist ID "PLnlxKMP5GzKCXJ3Cw99qSWgC01cuhTFxG" has 100 songs. However,
playlist['trackCount']returns 13, whilelen(playlist['tracks'])returns the correct value of 100. This issue first started appearing on March 22, 2023. Before then,trackCountwould return the same value as the length oftracks, as expected. I've tried multiple playlist, and none of thetrackCountvalues match up with the number of songs in the playlist. Did YouTube update whattrackCountmeans?@mtbrandao commented on GitHub (Mar 24, 2023):
Looking at the web interface, looks like the playlists have a new field called "views".
Example: "7.1K views"
For me, the "trackCount" value matches the "view" value on the web interface
@mtbrandao commented on GitHub (Mar 24, 2023):
The "get_playlist" function also uses the "trackCount" value to orient itself.
As currently, the track count is wrong, the "get_playlist" function is only returning 100 song maximum.
@sigma67 commented on GitHub (Mar 24, 2023):
I'm not able to reproduce. For me the playlist you provided has a
trackCountof 100 and 100 returned playlist items. It's a top 100 playlist, so that's exactly what's expected.@JohnHKoh commented on GitHub (Mar 24, 2023):
This is exactly it. I've tried multiple playlists. If it says "8.5K views",
trackCountwill return 85. If it says "22 views",trackCountwill return 22. It seems to be the numeric part of the view count without the decimal.I've figured it out. This bug seems to only happen on playlists that you have created. If you use someone else's playlist,
trackCountwill use the right value. This is because the view count is only shown when viewing your own playlist. Look at the difference when viewing the same playlist in different scenarios:Logged in:

Logged out (incognito):

This is the code that needs to be updated.
github.com/sigma67/ytmusicapi@19ad424e0e/ytmusicapi/mixins/playlists.py (L136-L137)The
['secondSubtitle']['runs']array looks different based on whether you own a playlist or not.Here it is when it is someone else's playlist:
And here it is when it is your own:
Using the [0] index will return the wrong value for your own playlist. Maybe the length of the
runsarray could be checked? Or maybe we could use the locale translation for "song", in this case, the Korean "노래", to see which object to extract the number from?@JohnHKoh commented on GitHub (Mar 24, 2023):
This also means that the following lines need to be fixed as well:
github.com/sigma67/ytmusicapi@19ad424e0e/ytmusicapi/mixins/playlists.py (L138-L139)@sigma67 commented on GitHub (Mar 25, 2023):
I see, they've added view counts to playlists. Will adjust accordingly.