[GH-ISSUE #64] yt.get_song does not work for uploaded songs #48

Closed
opened 2026-02-27 22:07:44 +03:00 by kerem · 7 comments
Owner

Originally created by @xplorr on GitHub (Aug 25, 2020).
Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/64

I try to get the dict info from an uploaded song, but for all uploaded songids I try, I get the same error.
Here is the content of my test python script isolating the problem:

from ytmusicapi import YTMusic
ytmusic = YTMusic('headers_auth.json')
song = ytmusic.get_song("kLXRb5ah7Fo")
print(song)

And this is the error it generates no matter what uploaded songid I specify:

Traceback (most recent call last):
  File "F:\Develop\test.py", line 3, in <module>
    song = ytmusic.get_song("kLXRb5ah7Fo")
  File "F:\Python38.32\lib\site-packages\ytmusicapi\mixins\browsing.py", line 535, in get_song
    song_meta['streamingData'] = player_response['streamingData']
KeyError: 'streamingData'

What is the reason?
ps. all my other calls creating playlists, adding songs to playlists etc. work perfectly
ps. for public songs, the call works ok
ps. i need this function to remove songs from an existing playlist (YTMusic.remove_playlist_items)

Originally created by @xplorr on GitHub (Aug 25, 2020). Original GitHub issue: https://github.com/sigma67/ytmusicapi/issues/64 I try to get the dict info from an **uploaded** song, but for all **uploaded** songids I try, I get the same error. Here is the content of my test python script isolating the problem: ``` from ytmusicapi import YTMusic ytmusic = YTMusic('headers_auth.json') song = ytmusic.get_song("kLXRb5ah7Fo") print(song) ``` And this is the error it generates no matter what **uploaded** songid I specify: ``` Traceback (most recent call last): File "F:\Develop\test.py", line 3, in <module> song = ytmusic.get_song("kLXRb5ah7Fo") File "F:\Python38.32\lib\site-packages\ytmusicapi\mixins\browsing.py", line 535, in get_song song_meta['streamingData'] = player_response['streamingData'] KeyError: 'streamingData' ``` What is the reason? ps. all my other calls creating playlists, adding songs to playlists etc. work perfectly ps. for public songs, the call works ok ps. i need this function to remove songs from an existing playlist (YTMusic.remove_playlist_items)
kerem 2026-02-27 22:07:44 +03:00
Author
Owner

@sigma67 commented on GitHub (Aug 26, 2020):

This method was not intended for uploaded songs, so I'm not surprised it yields an error. I'll have to look into it to see if it's possible to get metadata for a single uploaded song somehow.

As for your actual use case, I'm not sure why you'd need this call to remove uploaded items from a playlist. The proper way to this is to first call get_playlist, then filter out the items you want to remove, and then call remove_playlist_items with a List of Dicts, where each Dict contains a videoId and a setVideoId from the playlist you're targeting.

<!-- gh-comment-id:680772707 --> @sigma67 commented on GitHub (Aug 26, 2020): This method was not intended for uploaded songs, so I'm not surprised it yields an error. I'll have to look into it to see if it's possible to get metadata for a single uploaded song somehow. As for your actual use case, I'm not sure why you'd need this call to remove uploaded items from a playlist. The proper way to this is to first call `get_playlist`, then filter out the items you want to remove, and then call `remove_playlist_items` with a List of Dicts, where each Dict contains a `videoId` and a `setVideoId` from the playlist you're targeting.
Author
Owner

@xplorr commented on GitHub (Aug 26, 2020):

I need it because for my WinAmp/WACUP sync tool WinaYo, I create a local "database" of songsids and playlistids to be able to sync my local playlists with Youtube Music. So I already have all the songids of all playlists (to do SQL queries). Because I want to reduce the number of ytmusicapi calls, I use this information iso calling get_playlist again.

Besides, all other functions (I tested so far) of ytmusicapi also work correctly with uploaded songids, so consequently I expected that yt.get_song would also work for uploaded songs. So, would be very glad if it worked.

<!-- gh-comment-id:680802801 --> @xplorr commented on GitHub (Aug 26, 2020): I need it because for my WinAmp/WACUP sync tool [WinaYo](https://vanbarel.eu.org/tools/winayo/index.html), I create a local "database" of songsids and playlistids to be able to sync my local playlists with Youtube Music. So I already have all the songids of all playlists (to do SQL queries). Because I want to reduce the number of ytmusicapi calls, I use this information iso calling get_playlist again. Besides, all other functions (I tested so far) of ytmusicapi also work correctly with uploaded songids, so consequently I expected that yt.get_song would also work for uploaded songs. So, would be very glad if it worked.
Author
Owner

@sigma67 commented on GitHub (Aug 26, 2020):

Makes sense so far, but to be able to remove entries from the playlist again you also need to store the setVideoId for each playlist entry in your database. The song id (videoId) is not enough. I'm not sure how get_song would help you achieve that goal?

Nevertheless, I'll do some research on retrieving metadata for uploaded songs.

<!-- gh-comment-id:680808509 --> @sigma67 commented on GitHub (Aug 26, 2020): Makes sense so far, but to be able to remove entries from the playlist again you also need to store the setVideoId for each playlist entry in your database. The song id (videoId) is not enough. I'm not sure how `get_song` would help you achieve that goal? Nevertheless, I'll do some research on retrieving metadata for uploaded songs.
Author
Owner

@xplorr commented on GitHub (Aug 26, 2020):

Because I avoid/don't allow double songid entries in playlists.

<!-- gh-comment-id:680809889 --> @xplorr commented on GitHub (Aug 26, 2020): Because I avoid/don't allow double songid entries in playlists.
Author
Owner

@sigma67 commented on GitHub (Aug 31, 2020):

The get_video_info API used by get_song does not work with uploaded songs.

The metadata you see in the web API is retrieved from the next endpoint used by get_watch_playlist, which is quite unstructured and has no annotations for the text (i.e. if it's artist, title etc.). See the below example. So I'm not sure if it's possible to support uploaded songs properly. Perhaps we could add a metadata key to the response of get_watch_playlist.

  "metadataScreen": {
    "sectionListRenderer": {
      "contents": [
        {
          "itemSectionRenderer": {
            "contents": [
              {
                "musicWatchMetadataRenderer": {
                  "title": {
                    "runs": [
                      {
                        "text": "A Different Way (Tritonal Remix)"
                      }
                    ]
                  },
                  "byline": {
                    "runs": [
                      {
                        "text": "DJ Snake ft Lauv",
                        "navigationEndpoint": {
                          "clickTrackingParams": "CAQQkGsYACITCNHtl_y4xesCFcOOfAodn8UC4w==",
                          "browseEndpoint": {
                            "browseId": "FEmusic_library_privately_owned_artist_detaila_po_CICr2crg7OWpchIQZGogc25ha2UgZnQgbGF1dg",
                            "browseEndpointContextSupportedConfigs": {
                              "browseEndpointContextMusicConfig": {
                                "pageType": "MUSIC_PAGE_TYPE_UNKNOWN"
                              }
                            }
                          }
                        }
                      },
                      {
                        "text": " • "
                      },
                      {
                        "text": "A Different Way (Tritonal Remix)",
                        "navigationEndpoint": {
                          "clickTrackingParams": "CAQQkGsYACITCNHtl_y4xesCFcOOfAodn8UC4w==",
                          "browseEndpoint": {
                            "browseId": "FEmusic_library_privately_owned_release_detailb_po_CICr2crg7OWpchIcZGlmZmVyZW50IHdheSB0cml0b25hbCByZW1peBoQZGogc25ha2UgZnQgbGF1diIDZ3Bt",
                            "browseEndpointContextSupportedConfigs": {
                              "browseEndpointContextMusicConfig": {
                                "pageType": "MUSIC_PAGE_TYPE_ALBUM"
                              }
                            }
                          }
                        }
                      }
                    ]
                  },
                  "secondaryByline": {
                    "runs": [
                      {
                        "text": "3 views"
                      },
                      {
                        "text": " • "
                      },
                      {
                        "text": "1 like"
                      }
                    ]
                  },
                  "secondaryTitle": {
                    "runs": [
                      {
                        "text": "A Different Way (Tritonal Remix)"
                      }
                    ]
                  },
                  "trackingParams": "CAQQkGsYACITCNHtl_y4xesCFcOOfAodn8UC4w==",
                  "albumName": {
                    "runs": [
                      {
                        "text": "A Different Way (Tritonal Remix)"
                      }
                    ]
                  }
                }
              }
            ],
            "trackingParams": "CAMQuy8YACITCNHtl_y4xesCFcOOfAodn8UC4w=="
          }
        }
      ],
      "trackingParams": "CAIQui8iEwjR7Zf8uMXrAhXDjnwKHZ_FAuM="
    }
  }
<!-- gh-comment-id:683753904 --> @sigma67 commented on GitHub (Aug 31, 2020): The `get_video_info` API used by `get_song` does not work with uploaded songs. The metadata you see in the web API is retrieved from the `next` endpoint used by `get_watch_playlist`, which is quite unstructured and has no annotations for the text (i.e. if it's artist, title etc.). See the below example. So I'm not sure if it's possible to support uploaded songs properly. Perhaps we could add a metadata key to the response of `get_watch_playlist`. ```json "metadataScreen": { "sectionListRenderer": { "contents": [ { "itemSectionRenderer": { "contents": [ { "musicWatchMetadataRenderer": { "title": { "runs": [ { "text": "A Different Way (Tritonal Remix)" } ] }, "byline": { "runs": [ { "text": "DJ Snake ft Lauv", "navigationEndpoint": { "clickTrackingParams": "CAQQkGsYACITCNHtl_y4xesCFcOOfAodn8UC4w==", "browseEndpoint": { "browseId": "FEmusic_library_privately_owned_artist_detaila_po_CICr2crg7OWpchIQZGogc25ha2UgZnQgbGF1dg", "browseEndpointContextSupportedConfigs": { "browseEndpointContextMusicConfig": { "pageType": "MUSIC_PAGE_TYPE_UNKNOWN" } } } } }, { "text": " • " }, { "text": "A Different Way (Tritonal Remix)", "navigationEndpoint": { "clickTrackingParams": "CAQQkGsYACITCNHtl_y4xesCFcOOfAodn8UC4w==", "browseEndpoint": { "browseId": "FEmusic_library_privately_owned_release_detailb_po_CICr2crg7OWpchIcZGlmZmVyZW50IHdheSB0cml0b25hbCByZW1peBoQZGogc25ha2UgZnQgbGF1diIDZ3Bt", "browseEndpointContextSupportedConfigs": { "browseEndpointContextMusicConfig": { "pageType": "MUSIC_PAGE_TYPE_ALBUM" } } } } } ] }, "secondaryByline": { "runs": [ { "text": "3 views" }, { "text": " • " }, { "text": "1 like" } ] }, "secondaryTitle": { "runs": [ { "text": "A Different Way (Tritonal Remix)" } ] }, "trackingParams": "CAQQkGsYACITCNHtl_y4xesCFcOOfAodn8UC4w==", "albumName": { "runs": [ { "text": "A Different Way (Tritonal Remix)" } ] } } } ], "trackingParams": "CAMQuy8YACITCNHtl_y4xesCFcOOfAodn8UC4w==" } } ], "trackingParams": "CAIQui8iEwjR7Zf8uMXrAhXDjnwKHZ_FAuM=" } } ```
Author
Owner

@xplorr commented on GitHub (Aug 31, 2020):

That would be a real pity if the function get_song() does not work with uploaded songs.

<!-- gh-comment-id:683838721 --> @xplorr commented on GitHub (Aug 31, 2020): That would be a real pity if the function get_song() does not work with uploaded songs.
Author
Owner

@sigma67 commented on GitHub (Feb 11, 2021):

I believe get_watch_playlist should now return sufficient information (first track of returned tracks).

<!-- gh-comment-id:777273829 --> @sigma67 commented on GitHub (Feb 11, 2021): I believe get_watch_playlist should now return sufficient information (first track of returned tracks).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ytmusicapi#48
No description provided.