mirror of
https://github.com/sigma67/ytmusicapi.git
synced 2026-04-25 15:26:01 +03:00
[GH-ISSUE #758] YTMusic.search('query', 'songs') returns no view count #486
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#486
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 @serg-bloim on GitHub (Apr 2, 2025).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/758
Describe the bug
The result of YTMusic.search('query') returns no 'views' count for songs, but does so for videos.
To Reproduce
This code snippet should explain the issue:
Additional context
It turns out there is a slight format difference in the output for video and song content:
The views count is being processed here:
github.com/sigma67/ytmusicapi@f59a1b5dfd/ytmusicapi/parsers/search.py (L173)It takes data from
flexColumnsprop of data var. Video records have 2 flexColumns and views count is in the second column. Whereas song records have 3 columns: most data is in the second one and the views(plays) are in the third column.Here's a snippet that works for me locally.
JSON example for video:
JSON example for song:
@sigma67 commented on GitHub (Apr 2, 2025):
Yeah because why should they even bother being a shred consistent about it 🤦♂️
PR welcome
@sigma67 commented on GitHub (Apr 3, 2025):
The root cause here is that for whatever reason the plays data is provided in a separate flex column item.
@serg-bloim commented on GitHub (Apr 3, 2025):
Wow, I see you already addressed it. I wasn't confident filing a PR right away without a discussion.
Anyway, thanks for a quick fix!