GithubHelp home page GithubHelp logo

Comments (6)

shibotto avatar shibotto commented on July 18, 2024 1

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:
Schermata da 2024-05-13 15-35-30
due to changes in here:

elif "musicShelfRenderer" in res:
shelf_contents = res["musicShelfRenderer"]["contents"]
category = nav(res, MUSIC_SHELF + TITLE_TEXT, True)
type_filter = filter or category
type = type_filter[:-1].lower() if type_filter else None

from ytmusicapi.

sigma67 avatar sigma67 commented on July 18, 2024 1

Please check again if the results are good now. There might be some browseId edge cases I've missed.

from ytmusicapi.

shibotto avatar shibotto commented on July 18, 2024 1

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.

sigma67 avatar sigma67 commented on July 18, 2024

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.

shibotto avatar shibotto commented on July 18, 2024

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:
Schermata da 2024-05-14 00-31-19
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.

sigma67 avatar sigma67 commented on July 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.