Comments (6)
I'm exploring this issue a bit because I have time. Before 614999c in parse_search_result()
if an element had video_type
it was assumed to be either a song or a video, else get_search_result_type()
would be called to try and determine what we are dealing with.
Now this behavior has been (somewhat) reversed. The problem is that get_search_result_type()
is unable to identify songs/videos and evaluates everything it doesn't recognize as an album, and since it's now an album it never gets a chance to become a song or a video further down the code.
I thought about reversing that part back, but I also noticed that now parse_search_result()
is always called with some dirty value (category[:-1]
) for result_type
:
due to changes in here:
ytmusicapi/ytmusicapi/mixins/search.py
Lines 220 to 225 in ae966bb
from ytmusicapi.
Please check again if the results are good now. There might be some browseId
edge cases I've missed.
from ytmusicapi.
I tried trowing a bunch of different queries at it, observing each element returned and yep, everything matches perfectly now! If I was simply lucky enough to miss any obscure browseId
I'll get back to you.
Thank you very much! 😀
from ytmusicapi.
Thanks!
Sorry the code is so obscure, it's just hard to handle all the different cases. I've been trying to add more tests and make it more readable. I think I got a better grasp on some of the edge cases now, please check #583
from ytmusicapi.
I'm sorry to inform you that now English is broken as well :D
The original behavior, as I understood it, was to [:-1].lower()
the category as a first step, which works well for English (Songs -> song, Albums -> album, etc). Then if nothing matched, which in most cases meant a language different than English, try to guess from the available data. Now this doesn't happen as category
is never taken into account before calling parse_search_results()
, and honestly I think it's a good thing as at least everything fails equally.
The fundamental problem however remains, maybe the last part I added later overshadowed it a little: get_search_result_type()
is the first one to be fed, but get_item_text()
feeds it the wrong data. As an example:
And as a consequence the next step, result_type = 'album'
. I took just a quick look, but nowhere inside the data structure of a song element I saw something that could actually be used by parse_search_results()
.
We have MUSIC_VIDEO_TYPE_ATV though, which as far as I can observe always identifies songs.
Oh, don't worry about the code, I once tried to do something similar for generic Youtube. After few months I trashed everything because the many edge cases and my poor skill made the thing incomprehensible. Kudos for hanging on for so many years.
from ytmusicapi.
Thanks for your diligence.
The heuristic of using the first sub-run as an indicator is inherently broken because it's so inconsistent server-side. Depending on where a Song appears the Song indicator is sometimes there and sometimes not - it's just guesswork that's bound to change at their whim.
The problem was that that bad heuristic was actually covering up the better one that came after.
So I removed that part entirely and am only using the browseId (and MUSIC_VIDEO_TYPE_ATV) now, which seems to work pretty well. It uses the mapping in your screenshot (from the FAQ and my experience basically).
from ytmusicapi.
Related Issues (20)
- KeyError: "Unable to find 'menu' using path HOT 3
- parsers/browsing.py:parse_album() gives incorrect value for "year" HOT 5
- YTMusic::get_artist_albums raises KeyError HOT 1
- Add a get_artist_songs just like get_artist_albums HOT 1
- get_playlist fails if some track has invalid duration_seconds
- get_artist only returns about 10 songs and 10 albums at max HOT 1
- Edge case in edit_playlist: moving a title to the end of the playlist HOT 3
- album information on playlist tracks getting wrongly assigned on collaborative playlists HOT 4
- keyError when using get_playlist() HOT 9
- signatureCipher when requesting for get_song method HOT 4
- `get_playlist` does not work for all languages HOT 1
- `get_playlist` does not work for all languages
- YouTube music changed their UI of playlist page HOT 2
- get_playlist doen't return info about playlist author HOT 1
- get_album() fails if the album artist is 'Various Artists' HOT 1
- KeyError: 'singleColumnBrowseResultsRenderer' HOT 3
- `get_album` returns invalid artist data for track items in 1.7.4 HOT 1
- `get_playlist` returns `None` for track title HOT 3
- Search Continuations
- KeyError: 'thumbnails' when using `get_playlist` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ytmusicapi.