Playlists

YTMusic.get_playlist(playlistId: str, limit: int | None = 100, related: bool = False, suggestions_limit: int = 0) dict

Returns a list of playlist items

Parameters:
  • playlistId – Playlist id

  • limit – How many songs to return. None retrieves them all. Default: 100

  • related – Whether to fetch 10 related playlists or not. Default: False

  • suggestions_limit – How many suggestions to return. The result is a list of suggested playlist items (videos) contained in a “suggestions” key. 7 items are retrieved in each internal request. Default: 0

Returns:

Dictionary with information about the playlist. The key tracks contains a List of playlistItem dictionaries

The result is in the following format:

{
  "id": "PLQwVIlKxHM6qv-o99iX9R85og7IzF9YS_",
  "privacy": "PUBLIC",
  "title": "New EDM This Week 03/13/2020",
  "thumbnails": [...]
  "description": "Weekly r/EDM new release roundup. Created with github.com/sigma67/spotifyplaylist_to_gmusic",
  "author": "sigmatics",
  "year": "2020",
  "duration": "6+ hours",
  "duration_seconds": 52651,
  "trackCount": 237,
  "suggestions": [
      {
        "videoId": "HLCsfOykA94",
        "title": "Mambo (GATTÜSO Remix)",
        "artists": [{
            "name": "Nikki Vianna",
            "id": "UCMW5eSIO1moVlIBLQzq4PnQ"
          }],
        "album": {
          "name": "Mambo (GATTÜSO Remix)",
          "id": "MPREb_jLeQJsd7U9w"
        },
        "likeStatus": "LIKE",
        "thumbnails": [...],
        "isAvailable": true,
        "isExplicit": false,
        "duration": "3:32",
        "duration_seconds": 212,
        "setVideoId": "to_be_updated_by_client"
      }
  ],
  "related": [
      {
        "title": "Presenting MYRNE",
        "playlistId": "RDCLAK5uy_mbdO3_xdD4NtU1rWI0OmvRSRZ8NH4uJCM",
        "thumbnails": [...],
        "description": "Playlist • YouTube Music"
      }
  ],
  "tracks": [
    {
      "videoId": "bjGppZKiuFE",
      "title": "Lost",
      "artists": [
        {
          "name": "Guest Who",
          "id": "UCkgCRdnnqWnUeIH7EIc3dBg"
        },
        {
          "name": "Kate Wild",
          "id": "UCwR2l3JfJbvB6aq0RnnJfWg"
        }
      ],
      "album": {
        "name": "Lost",
        "id": "MPREb_PxmzvDuqOnC"
      },
      "duration": "2:58",
      "duration_seconds": 178,
      "setVideoId": "748EE8..."
      "likeStatus": "INDIFFERENT",
      "thumbnails": [...],
      "isAvailable": True,
      "isExplicit": False,
      "videoType": "MUSIC_VIDEO_TYPE_OMV",
      "feedbackTokens": {
        "add": "AB9zfpJxtvrU...",
        "remove": "AB9zfpKTyZ..."
    }
  ]
}

The setVideoId is the unique id of this playlist item and needed for moving/removing playlist items

YTMusic.create_playlist(title: str, description: str, privacy_status: str = 'PRIVATE', video_ids: list | None = None, source_playlist: str | None = None) str | dict

Creates a new empty playlist and returns its id.

Parameters:
  • title – Playlist title

  • description – Playlist description

  • privacy_status – Playlists can be PUBLIC, PRIVATE, or UNLISTED. Default: PRIVATE

  • video_ids – IDs of songs to create the playlist with

  • source_playlist – Another playlist whose songs should be added to the new playlist

Returns:

ID of the YouTube playlist or full response if there was an error

YTMusic.edit_playlist(playlistId: str, title: str | None = None, description: str | None = None, privacyStatus: str | None = None, moveItem: str | tuple[str, str] | None = None, addPlaylistId: str | None = None, addToTop: bool | None = None) str | dict

Edit title, description or privacyStatus of a playlist. You may also move an item within a playlist or append another playlist to this playlist.

Parameters:
  • playlistId – Playlist id

  • title – Optional. New title for the playlist

  • description – Optional. New description for the playlist

  • privacyStatus – Optional. New privacy status for the playlist

  • moveItem – Optional. Move one item before another. Items are specified by setVideoId, which is the unique id of this playlist item. See get_playlist()

  • addPlaylistId – Optional. Id of another playlist to add to this playlist

  • addToTop – Optional. Change the state of this playlist to add items to the top of the playlist (if True) or the bottom of the playlist (if False - this is also the default of a new playlist).

Returns:

Status String or full response

YTMusic.delete_playlist(playlistId: str) str | dict

Delete a playlist.

Parameters:

playlistId – Playlist id

Returns:

Status String or full response

YTMusic.add_playlist_items(playlistId: str, videoIds: list[str] | None = None, source_playlist: str | None = None, duplicates: bool = False) str | dict

Add songs to an existing playlist

Parameters:
  • playlistId – Playlist id

  • videoIds – List of Video ids

  • source_playlist – Playlist id of a playlist to add to the current playlist (no duplicate check)

  • duplicates – If True, duplicates will be added. If False, an error will be returned if there are duplicates (no items are added to the playlist)

Returns:

Status String and a dict containing the new setVideoId for each videoId or full response

YTMusic.remove_playlist_items(playlistId: str, videos: list[dict]) str | dict

Remove songs from an existing playlist

Parameters:
  • playlistId – Playlist id

  • videos – List of PlaylistItems, see get_playlist(). Must contain videoId and setVideoId

Returns:

Status String or full response