[GH-ISSUE #149] Views and duration are incorrectly parsed when searching for a video. #112

Closed
opened 2026-02-27 22:08:06 +03:00 by kerem · 9 comments
Owner

Originally created by @bee395 on GitHub (Jan 11, 2021).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/149

Environment

  • **System OS: Linux

  • **Python Version: 3.9.1

  • installed from master: cb1f58d696

Steps to Reproduce

  1. Create a unit test with results = youtube.search('Adele - Send My Love (To Your New Lover)', filter='videos')
    print(results)
  2. The first to last result is an incorrect parsed video.
    When I get the details of the video through youtube.get_song('wXrZOFRikOY') it correctly returns '... viewCount': '6707', 'author': 'Julie Dowd', ...

Output

...
{'resultType': 'video', 'videoId': 'wXrZOFRikOY', 'title': 'SEND MY LOVE (TO YOUR NEW LOVER) - ADELE - 1 Hour Loop With Lyrics', 'artists': [{'name': 'Julie Dowd', 'id': 'UCB1NyHU7hBR4R_6F1LazkVg'}], 'views': 'Julie', 'duration': '6.7K views', 'thumbnails': [{'url': 'https://i.ytimg.com/vi/wXrZOFRikOY/sddefault.jpg?sqp=-oaymwEWCJADEOEBIAQqCghqEJQEGHgg6AJIWg&rs=AMzJL3lSnjwY_iucJje6idGTFy7zh0ugZg', 'width': 400, 'height': 225}]}
...

Other information

The problem is probably that the video is a "premiere" video
It looks like the get_item_text on parsers/browsing.py:74 takes the wrong columns

Originally created by @bee395 on GitHub (Jan 11, 2021). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/149 ### Environment - **System OS: Linux - **Python Version: 3.9.1 - installed from master: cb1f58d696dc10ca4efc1bb74f7c4cfd2db7eb9c ### Steps to Reproduce 1. Create a unit test with results = youtube.search('Adele - Send My Love (To Your New Lover)', filter='videos') print(results) 2. The first to last result is an incorrect parsed video. When I get the details of the video through youtube.get_song('wXrZOFRikOY') it correctly returns '... viewCount': '6707', 'author': 'Julie Dowd', ... ### Output ``` ... {'resultType': 'video', 'videoId': 'wXrZOFRikOY', 'title': 'SEND MY LOVE (TO YOUR NEW LOVER) - ADELE - 1 Hour Loop With Lyrics', 'artists': [{'name': 'Julie Dowd', 'id': 'UCB1NyHU7hBR4R_6F1LazkVg'}], 'views': 'Julie', 'duration': '6.7K views', 'thumbnails': [{'url': 'https://i.ytimg.com/vi/wXrZOFRikOY/sddefault.jpg?sqp=-oaymwEWCJADEOEBIAQqCghqEJQEGHgg6AJIWg&rs=AMzJL3lSnjwY_iucJje6idGTFy7zh0ugZg', 'width': 400, 'height': 225}]} ... ``` ### Other information The problem is probably that the video is a "premiere" video It looks like the get_item_text on parsers/browsing.py:74 takes the wrong columns
kerem 2026-02-27 22:08:06 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@sigma67 commented on GitHub (Jan 12, 2021):

Unfortunately I cannot reproduce this. Can you show a screenshot of the Web UI where this song is different from the others? Was it a time-limited thing, since you mentioned premiere?

<!-- gh-comment-id:758561556 --> @sigma67 commented on GitHub (Jan 12, 2021): Unfortunately I cannot reproduce this. Can you show a screenshot of the Web UI where this song is different from the others? Was it a time-limited thing, since you mentioned premiere?
Author
Owner

@bee395 commented on GitHub (Jan 12, 2021):

I think that a premiere video is a planned video with a countdown and a livechat, during the video
After the premiere ended, there shouldn't be anything special about the video

Screenshot of the video (it's in Dutch, but it should also show in other languages):
image
Link to the video: https://www.youtube.com/watch?v=wXrZOFRikOY

<!-- gh-comment-id:758572602 --> @bee395 commented on GitHub (Jan 12, 2021): I think that a premiere video is a planned video with a countdown and a livechat, during the video After the premiere ended, there shouldn't be anything special about the video Screenshot of the video (it's in Dutch, but it should also show in other languages): ![image](https://user-images.githubusercontent.com/13592371/104304292-8025fe80-54cb-11eb-8684-9dc632904d38.png) Link to the video: https://www.youtube.com/watch?v=wXrZOFRikOY
Author
Owner

@sigma67 commented on GitHub (Jan 12, 2021):

Sorry if I wasn't clear, I meant the YouTube Music search page, not actual YouTube page. I found the title you mentioned now, it seems to be missing duration, which is unusual.

<!-- gh-comment-id:758587422 --> @sigma67 commented on GitHub (Jan 12, 2021): Sorry if I wasn't clear, I meant the YouTube Music search page, not actual YouTube page. I found the title you mentioned now, it seems to be missing duration, which is unusual.
Author
Owner

@bee395 commented on GitHub (Jan 12, 2021):

Ah sorry, my bad. I wasn't aware that Youtube Music has a different Web interface.

<!-- gh-comment-id:758589644 --> @bee395 commented on GitHub (Jan 12, 2021): Ah sorry, my bad. I wasn't aware that Youtube Music has a different Web interface.
Author
Owner

@bee395 commented on GitHub (Jan 14, 2021):

Today, after I pulled the newest version from master, I tried some new songs, and now I the view count is incorrectly parsed for another song
youtube.search('Young Franco - Miss You', filter='videos') returns a result containing:

...
{'resultType': 'video', 'videoId': '4mUJaWqWb_k', 'title': 'Juice', 'artists': [{'name': 'Pell', 'id': 'UCZGko_JjZgHZlLGbm5itUCw'}, {'name': 'Young Franco', 'id': 'UCvOSkOoJ_5NHQE0XE9HhpZw'}], 'views': 'Young', 'duration': '157K views', 'thumbnails': [{'url': 'https://i.ytimg.com/vi/4mUJaWqWb_k/sddefault.jpg?sqp=-oaymwEWCJADEOEBIAQqCghqEJQEGHgg6AJIWg&rs=AMzJL3nPonplHqd_wAPj-1fxJIL5A0iyNQ', 'width': 400, 'height': 225}]}
...

youtube.get_song('4mUJaWqWb_k') returns the output with the correct amount of views and duration.

The song on Youtube Music: https://music.youtube.com/watch?v=4mUJaWqWb_k&list=RDAMVM4mUJaWqWb_k

<!-- gh-comment-id:760458749 --> @bee395 commented on GitHub (Jan 14, 2021): Today, after I pulled the newest version from master, I tried some new songs, and now I the view count is incorrectly parsed for another song ``youtube.search('Young Franco - Miss You', filter='videos')`` returns a result containing: ``` ... {'resultType': 'video', 'videoId': '4mUJaWqWb_k', 'title': 'Juice', 'artists': [{'name': 'Pell', 'id': 'UCZGko_JjZgHZlLGbm5itUCw'}, {'name': 'Young Franco', 'id': 'UCvOSkOoJ_5NHQE0XE9HhpZw'}], 'views': 'Young', 'duration': '157K views', 'thumbnails': [{'url': 'https://i.ytimg.com/vi/4mUJaWqWb_k/sddefault.jpg?sqp=-oaymwEWCJADEOEBIAQqCghqEJQEGHgg6AJIWg&rs=AMzJL3nPonplHqd_wAPj-1fxJIL5A0iyNQ', 'width': 400, 'height': 225}]} ... ``` `youtube.get_song('4mUJaWqWb_k')` returns the output with the correct amount of views and duration. The song on Youtube Music: https://music.youtube.com/watch?v=4mUJaWqWb_k&list=RDAMVM4mUJaWqWb_k
Author
Owner

@sigma67 commented on GitHub (Jan 14, 2021):

Apologies, I didn't consider the multiple artist case. I have tested both search terms you mentioned locally. Can you retry with latest master and some different search terms?

<!-- gh-comment-id:760473224 --> @sigma67 commented on GitHub (Jan 14, 2021): Apologies, I didn't consider the multiple artist case. I have tested both search terms you mentioned locally. Can you retry with latest master and some different search terms?
Author
Owner

@bee395 commented on GitHub (Jan 14, 2021):

Thanks for your incredible fast responses. That song is now working. But unfortunately I found another song that doesn't work properly:

Namely when I search for Alec Benjamin - Stan - Recorded at Spotify Studios NYC:

...
{'resultType': 'video', 'videoId': 'nFQ4kGbIJa0', 'title': 'Supernova Girl', 'artists': [{'name': 'Tim White', 'id': None}], 'views': 'Ryan', 'duration': '790 views', 'thumbnails': [{'url': 'https://i.ytimg.com/vi/nFQ4kGbIJa0/sddefault.jpg?sqp=-oaymwEWCJADEOEBIAQqCghqEJQEGHgg6AJIWg&rs=AMzJL3mPtskwbVr0z5xNzi5NSCpD1EQgMw', 'width': 400, 'height': 225}]}
...

YT Music link: https://music.youtube.com/watch?v=nFQ4kGbIJa0&list=RDAMVMnFQ4kGbIJa0

<!-- gh-comment-id:760489083 --> @bee395 commented on GitHub (Jan 14, 2021): Thanks for your incredible fast responses. That song is now working. But unfortunately I found another song that doesn't work properly: Namely when I search for `Alec Benjamin - Stan - Recorded at Spotify Studios NYC`: ``` ... {'resultType': 'video', 'videoId': 'nFQ4kGbIJa0', 'title': 'Supernova Girl', 'artists': [{'name': 'Tim White', 'id': None}], 'views': 'Ryan', 'duration': '790 views', 'thumbnails': [{'url': 'https://i.ytimg.com/vi/nFQ4kGbIJa0/sddefault.jpg?sqp=-oaymwEWCJADEOEBIAQqCghqEJQEGHgg6AJIWg&rs=AMzJL3mPtskwbVr0z5xNzi5NSCpD1EQgMw', 'width': 400, 'height': 225}]} ... ``` YT Music link: https://music.youtube.com/watch?v=nFQ4kGbIJa0&list=RDAMVMnFQ4kGbIJa0
Author
Owner

@sigma67 commented on GitHub (Jan 14, 2021):

Ah yes, the tricky edge case where no artists have IDs. Already fixed it for song search, should have seen it coming. I also considered the case with no artist IDs and no duration, even thought I haven't seen it yet. I hope we've covered it all now.

<!-- gh-comment-id:760504516 --> @sigma67 commented on GitHub (Jan 14, 2021): Ah yes, the tricky edge case where no artists have IDs. Already fixed it for song search, should have seen it coming. I also considered the case with no artist IDs and no duration, even thought I haven't seen it yet. I hope we've covered it all now.
Author
Owner

@bee395 commented on GitHub (Jan 14, 2021):

When I now search for a song with no song duration found, it returns None. So that looks good

I think that was everything. Thanks for your help 👍

<!-- gh-comment-id:760521750 --> @bee395 commented on GitHub (Jan 14, 2021): When I now search for a song with no song duration found, it returns `None`. So that looks good I think that was everything. Thanks for your help :+1:
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ytmusicapi#112
No description provided.