[GH-ISSUE #193] Inconsistent results when searching uploads #149

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

Originally created by @jskills on GitHub (Apr 24, 2021).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/193

First off - thanks for writing this!

I am seeing inconsistent results when searching uploads. I have about 75K uploaded songs and am looking to build playlists with those songs only. I have been able to find about 75% of them in searches using the API.

ytm = YTMusic('headers_auth.json')
searchFor = artist + " - " + album + " - " song
ytm.search(searchFor, 'uploads', limit=40)

I have adjusted the contents of the "searchFor" variable to be song only, artist plus song, and the format above which includes the album name too (which seems to be the best in terms of getting results).

But there are still many songs I can search for in Youtube Music via browser and show up but I simply cannot get them to be returned by the API.

I am happy to provide more details, screen shots and/or write code patches if need be. I was just wondering if this was a known issue or anyone else had encountered it.

Originally created by @jskills on GitHub (Apr 24, 2021). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/193 First off - thanks for writing this! I am seeing inconsistent results when searching uploads. I have about 75K uploaded songs and am looking to build playlists with those songs only. I have been able to find about 75% of them in searches using the API. ytm = YTMusic('headers_auth.json') searchFor = artist + " - " + album + " - " song ytm.search(searchFor, 'uploads', limit=40) I have adjusted the contents of the "searchFor" variable to be song only, artist plus song, and the format above which includes the album name too (which seems to be the best in terms of getting results). But there are still many songs I can search for in Youtube Music via browser and show up but I simply cannot get them to be returned by the API. I am happy to provide more details, screen shots and/or write code patches if need be. I was just wondering if this was a known issue or anyone else had encountered it.
kerem closed this issue 2026-02-27 22:08:18 +03:00
Author
Owner

@sigma67 commented on GitHub (Apr 24, 2021):

No, that's the first time I've heard of something like that. It would be great if you could provide a screenshot of a specific query in the YTM web interface, and the result of the same query when using ytmusicapi. Perhaps you could even narrow down the cause if you're able to figure out the characteristics of songs are not being returned.

<!-- gh-comment-id:826121962 --> @sigma67 commented on GitHub (Apr 24, 2021): No, that's the first time I've heard of something like that. It would be great if you could provide a screenshot of a specific query in the YTM web interface, and the result of the same query when using ytmusicapi. Perhaps you could even narrow down the cause if you're able to figure out the characteristics of songs are not being returned.
Author
Owner

@jskills commented on GitHub (Apr 25, 2021):

For some background, I migrated a large library of MP3s from Google Play Music to Youtube Music.

Searches in the browser for simple song titles were coming back fine, but using this API, occasional errors. The places in code I tracked it down to were areas where data structures were expected to be populated a certain way and were not.

I added 4 lines of changes that alleviated it. I can submit a pull request if you like.

Here are the changes ...

#ytmusicapi/parsers/browsing.py" line 84 of 220
} if flex_items[1].count(2) else ''

#ytmusicapi/parsers/browsing.py" line 85 of 220
search_result['duration'] = flex_items[1][4]['text'] if flex_items[1].count(4) else ''

#ytmusicapi/parsers/browsing.py" line 98 of 220
search_result['artist'] = runs[1] if runs.count(1) else ''

#ytmusicapi/parsers/utils.py" line 147 of 166
return None

I can provide all of the use cases that required these changes in order to work .

<!-- gh-comment-id:826401016 --> @jskills commented on GitHub (Apr 25, 2021): For some background, I migrated a large library of MP3s from Google Play Music to Youtube Music. Searches in the browser for simple song titles were coming back fine, but using this API, occasional errors. The places in code I tracked it down to were areas where data structures were expected to be populated a certain way and were not. I added 4 lines of changes that alleviated it. I can submit a pull request if you like. Here are the changes ... #ytmusicapi/parsers/browsing.py" line 84 of 220 } if flex_items[1].count(2) else '' #ytmusicapi/parsers/browsing.py" line 85 of 220 search_result['duration'] = flex_items[1][4]['text'] if flex_items[1].count(4) else '' #ytmusicapi/parsers/browsing.py" line 98 of 220 search_result['artist'] = runs[1] if runs.count(1) else '' #ytmusicapi/parsers/utils.py" line 147 of 166 return None I can provide all of the use cases that required these changes in order to work .
Author
Owner

@sigma67 commented on GitHub (Apr 26, 2021):

Thanks! It would be great if you could submit a PR with these changes and a bit of reasoning why each of them is necessary.

<!-- gh-comment-id:826562070 --> @sigma67 commented on GitHub (Apr 26, 2021): Thanks! It would be great if you could submit a PR with these changes and a bit of reasoning why each of them is necessary.
Author
Owner

@jskills commented on GitHub (Apr 26, 2021):

Ok I went ahead and submitted a PR.

https://github.com/sigma67/ytmusicapi/pull/194

<!-- gh-comment-id:827106612 --> @jskills commented on GitHub (Apr 26, 2021): Ok I went ahead and submitted a PR. https://github.com/sigma67/ytmusicapi/pull/194
Author
Owner

@jskills commented on GitHub (Apr 26, 2021):

And here is a Google Doc with screenshots of search results compared from browser to using the API.

https://docs.google.com/document/d/1SPs0KqeVSYGBtypUfqFFY4hSiNqc8BSMhSF3_MxV9gg/edit?usp=sharing

<!-- gh-comment-id:827206606 --> @jskills commented on GitHub (Apr 26, 2021): And here is a Google Doc with screenshots of search results compared from browser to using the API. [https://docs.google.com/document/d/1SPs0KqeVSYGBtypUfqFFY4hSiNqc8BSMhSF3_MxV9gg/edit?usp=sharing](https://docs.google.com/document/d/1SPs0KqeVSYGBtypUfqFFY4hSiNqc8BSMhSF3_MxV9gg/edit?usp=sharing)
Author
Owner

@jskills commented on GitHub (Apr 27, 2021):

Latest changes to master correct these issues.

<!-- gh-comment-id:827918604 --> @jskills commented on GitHub (Apr 27, 2021): Latest changes to master correct these issues.
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#149
No description provided.