mirror of
https://github.com/sigma67/ytmusicapi.git
synced 2026-04-25 07:16:00 +03:00
[GH-ISSUE #193] Inconsistent results when searching uploads #149
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#149
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 @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.
@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.
@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 .
@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.
@jskills commented on GitHub (Apr 26, 2021):
Ok I went ahead and submitted a PR.
https://github.com/sigma67/ytmusicapi/pull/194
@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
@jskills commented on GitHub (Apr 27, 2021):
Latest changes to master correct these issues.