sigma67 / ytmusicapi

Unofficial API for YouTube Music
https://ytmusicapi.readthedocs.io
MIT License
1.66k stars 189 forks source link

get_playlist track artists are now None #627

Closed ghost closed 1 month ago

ghost commented 1 month ago

Describe the bug In version 1.7.5, the value of artists in all tracks items in get_playlist() data is always None. This is not the case in 1.7.4.

To Reproduce

>>> from ytmusicapi import YTMusic
>>> YTMusic().get_playlist('VLPLRktPAG0Z4OaqYZbUGifSu3NpFMFQA3-g')

Additional context

1.7.4:

{
    "owned": False,
    "id": "PLRktPAG0Z4OaqYZbUGifSu3NpFMFQA3-g",
    "privacy": "PUBLIC",
    "description": None,
    "title": "Anime Eurobeat Remixes",
    "artists": [],
    "year": "2024",
    "views": 12,
    "duration": "3 hours, 59 minutes",
    "trackCount": 55,
    "related": [],
    "tracks": [
        {
            "videoId": "JXjuDwBKZ6g",
            "title": "Sono Chi No Sadame / Eurobeat remix",
            "artists": [{"name": "Turbo", "id": "UCus8EVJ7Oc9zINhs-fg8l1Q"}],
            "album": None,
            "likeStatus": "INDIFFERENT",
            "inLibrary": None,
            "thumbnails": [
                {
                    "url": "https://i.ytimg.com/vi/JXjuDwBKZ6g/sddefault.jpg?sqp=-oaymwEWCJADEOEBIAQqCghqEJQEGHgg6AJIWg&rs=AMzJL3kWGK675mblmKOt7De-IOU10qzhxw",
                    "width": 400,
                    "height": 225,
                }
            ],
            "isAvailable": True,
            "isExplicit": False,
            "videoType": "MUSIC_VIDEO_TYPE_UGC",
            "views": None,
            "duration": "3:47",
            "duration_seconds": 227,
        },

1.7.5:

{
    "owned": False,
    "id": "PLRktPAG0Z4OaqYZbUGifSu3NpFMFQA3-g",
    "privacy": "PUBLIC",
    "description": None,
    "title": "Anime Eurobeat Remixes",
    "artists": [],
    "year": "2024",
    "views": 12,
    "duration": "3 hours, 59 minutes",
    "trackCount": 55,
    "related": [],
    "tracks": [
        {
            "videoId": "JXjuDwBKZ6g",
            "title": "Sono Chi No Sadame / Eurobeat remix",
            "artists": None, # <--------------- artists missing
            "album": None,
            "likeStatus": "INDIFFERENT",
            "inLibrary": None,
            "thumbnails": [
                {
                    "url": "https://i.ytimg.com/vi/JXjuDwBKZ6g/sddefault.jpg?sqp=-oaymwEWCJADEOEBIAQqCghqEJQEGHgg6AJIWg&rs=AMzJL3kWGK675mblmKOt7De-IOU10qzhxw",
                    "width": 400,
                    "height": 225,
                }
            ],
            "isAvailable": True,
            "isExplicit": False,
            "videoType": "MUSIC_VIDEO_TYPE_UGC",
            "views": None,
            "duration": "3:47",
            "duration_seconds": 227,
        },

Because of this there is no way to get artist information from a playlist in 1.7.5.

czifumasa commented 1 month ago

So yet another case, that I have to adapt to the new logic, this time it's videos uploaded from non-official user channels. I guess initially in 1.7.4 it worked, but then I fixed albums (#618) and I broke this one.

I will revert my fix from #618 and I will remove the new logic for albums, bringing back preset flexColumn meanings.

What do you think? @sigma67

P.S. I know we need tests for all these cases, but tbh I am not sure how to design them.

sigma67 commented 1 month ago

Reverting the fix won't help because then you break the other use cases again.

Good tests would be to add asserts on the existing tests. For all tests with static album and playlist ids (where tracks are known to have artists), add an assert that ensures the artist is parsed correctly

czifumasa commented 1 month ago

What I meant is removing the new logic, but only for albums (see: 3208ca9). So for albums columns are hardcoded and for playlist they are still resolved using navigationEndpoints.

There are border cases with columns without navigationEndpoint, where I have to guess their meaning. Those cases are different for albums and for playlists, so I cannot use the same logic for both methods. Albums always have the same order of flexColumns, so dynamic resolving is not needed there.

sigma67 commented 1 month ago

I see, that's fine. Please also consider the suggestions key in get_playlist in your tests (although I'm not sure why it should behave differently - maybe it doesn't)