sigma67 / ytmusicapi

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

Artist missing for uploaded music #130

Closed KoljaWindeler closed 3 years ago

KoljaWindeler commented 3 years ago

Hi, I've just scrolled in my uploaded song on the youtube website, selected one song .. played just fine, showing all information correct.

Went into my smarthome system .. opened the youtube GUI (which uses your api), selected the "history" playlist, saw the same song .. with "artist - trackname" (from get_history()) .. played the song (which will call get_song with the videoId) and got an exception due to a missing artist field (exception from my code). Double checked: No artist field .. strange.

Tried to open the get_library_upload_songs ... same thing there .. no artist in the return

Strange, right?

Oh and sidenote: get_uploaded_songs will return "authors" and "author" which looks exactly the same to me ..

KoljaWindeler commented 3 years ago

i just saw that this is likely related to https://github.com/sigma67/ytmusicapi/issues/64, correct?

sigma67 commented 3 years ago

get_library_upload_songs should return an artist if the uploaded song actually has an artist. Please verify in the YTMusic Web UI that this is the case. Same with get_history, it works correctly for me.

get_uploaded_songs does not exist anymore, so not sure what you're referring to there.

KoljaWindeler commented 3 years ago

Hi, I've done a little more digging .. I'm basically using two functions:

  1. get_playlist (that playlist now contains one of the uploaded songs)
  2. once the playlist was selected: get_song (yep, sorry .. not get_uploaded_song)

The tracks of "get_playlist" contain information about the author, get_song does not Any idea?

get_playlist
    {
    'id': 'PLZvjm51R8SGuNroyDal3v9BYdTw6yqrrM', 
    'privacy': 'PRIVATE', 
    'title': 'shorty', 
    'thumbnails': [ ... ], 
    'author': {
        'name': 'Kolja Windeler', 
        'id': 'UCrFSdLT1nmvmcTCzIOr6J3w'
        }, 
    'duration': '8 minutes, 5 seconds', 
    'trackCount': 2, 
    'tracks': [
        {
            'videoId': 'eCpt2qaqKW0', 
            'title': 'So wie du bist (feat. LARY)', 
            'artists': [{  'name': 'MoTrip',  'id': 'UCcyO_SNHFhbdogh9PPBB9LA'}], 
            'album': {'name': 'Mama', 'id': 'MPREb_PIwNkeyJF95'}, 
            'likeStatus': 'INDIFFERENT', 
            'thumbnails': [ ... ], 
            'isAvailable': True, 
            'duration': '4:29', 
            'setVideoId': '56B44F6D10557CC6', 
            'feedbackTokens': {
                'add': 'AB9zfpK7DNYiYtX7A5S4WQJfRvQyDdZaR0s7NvzbrdC2d8uAtT27gHyEcLIKzgKW8Vz5_bB8NasY1v1MyYjzJCstl9wDw1g41A', 
                'remove': 'AB9zfpJLZZo60hYf8Zix_TWLIytG579dMCMo1Ogh4jFau5rTLg-duXSEpQbKEjxyLMGzR7eXdi0aRzqXp0nsgutanvP8uPsilA'}
        },{
            'videoId': 'N4-8lb8ITfw', 
            'title': 'Bitte Bitte', 
            'artists': [{'name': 'Fler', 'id': 'FEmusic_library_privately_owned_artist_detaila_po_CP-Lo4yw76nhFBIEZmxlcg'}], 
            'album': {'name': 'Neue Deutsche Welle', 'id': 'FEmusic_library_privately_owned_release_detailb_po_CP-Lo4yw76nhFBITbmV1ZSBkZXV0c2NoZSB3ZWxsZSIDZ3Bt'}, 
            'likeStatus': 'INDIFFERENT', 
            'thumbnails': [ ... ], 
            'isAvailable': True, 
            'duration': '3:36', 
            'setVideoId': '289F4A46DF0A30D2'}
        ]
    }

get_song(videoId='N4-8lb8ITfw')
    {
        'videoId': 'N4-8lb8ITfw', 
        'title': 'Bitte Bitte', 
        'lengthSeconds': '217', 
        'channelId': 'UCQDzKj5SHlE7d5UaK51rc7g', 
        'isOwnerViewing': False, 
        'shortDescription': 'Uploaded to YouTube via YouTube Music\n\nBitte Bitte', 
        'isCrawlable': False, 
        'thumbnail': {
            'thumbnails': [ ... ]
        }, 
        'averageRating': 0.0, 
        'allowRatings': True, 
        'viewCount': '2', 
        'author': 'Music Library Uploads', 
        'isPrivate': True, 
        'isUnpluggedCorpus': False, 
        'isLiveContent': False, 
        'category': 'Music'
    }
sigma67 commented 3 years ago

The author is missing for get_song because that function uses a YouTube endpoint (not YouTube music). That endpoint does not provide the author of the uploaded track.

If you check that track on YouTube using https://www.youtube.com/watch?v=___, you will find that the artist is nowhere to be found on that site. There is also no metadata in the comments like for auto-uploads. This means there is no way for ytmusicapi to provide the track author of uploaded tracks from that endpoint.

When you play an uploaded track, YouTube Music actually gets the artist using the next endpoint, which is implemented in get_watch_playlist. The function needs a bit of work to properly return album and artist instead of the generic byline, but that would fix your issue.

sigma67 commented 3 years ago

@KoljaWindeler Please check if 3de9b5e fixes this issue.

KoljaWindeler commented 3 years ago

Will do and report back

KoljaWindeler commented 3 years ago

works perfectly! thanks, great work!