Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent results when searching uploads #193

Closed
jskills opened this issue Apr 24, 2021 · 6 comments
Closed

Inconsistent results when searching uploads #193

jskills opened this issue Apr 24, 2021 · 6 comments

Comments

@jskills
Copy link

jskills commented Apr 24, 2021

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
Copy link
Owner

sigma67 commented 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
Copy link
Author

jskills commented 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
Copy link
Owner

sigma67 commented 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
Copy link
Author

jskills commented Apr 26, 2021

Ok I went ahead and submitted a PR.

#194

@jskills
Copy link
Author

jskills commented 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
Copy link
Author

jskills commented Apr 27, 2021

Latest changes to master correct these issues.

@jskills jskills closed this as completed Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants