Playlists

Methods

# (async) addPlaylistItems(playlistId)

Add songs to an existing playlist
Parameters:
Name Type Attributes Default Description
playlistId Playlist id.
options.videoIds Array.<string> <optional>
IDs of songs to create the playlist with.
options.sourcePlaylist string <optional>
Another playlist whose songs should be added to the new playlist.
options.duplicates boolean <optional>
false 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 an object containing the new setVideoId for each videoId or full response.

# (async) createPlaylist(title, description, privacyStatusopt, options)

Creates a new empty playlist and returns its id.
Parameters:
Name Type Attributes Default Description
title Playlist title.
description Optional. Playlist description.
privacyStatus string <optional>
'PRIVATE' Playlists can be 'PUBLIC', 'PRIVATE', or 'UNLISTED'. Default: 'PRIVATE'.
options
Properties
Name Type Attributes Description
videoIds Array.<string> <optional>
IDs of songs to create the playlist with.
sourcePlaylist string <optional>
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.

# (async) deletePlaylist(playlistIdopt)

Delete a playlist.
Parameters:
Name Type Attributes Description
playlistId string <optional>
Playlist id.
Returns:
Status String or full response.

# (async) editPlaylist(playlistId, options)

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:
Name Type Description
playlistId Playlist id.
options
Properties
Name Type Attributes Description
title= string <optional>
New title for the playlist.
description= string <optional>
New description for the playlist.
privacyStatus= pt.PrivacyStatu <optional>
New privacy status for the playlist.
moveItem= string <optional>
Move one item before another. Items are specified by setVideoId, see `getPlaylist`.
addPlaylistId= string <optional>
Id of another playlist to add to this playlist
Returns:
Status String or full response

# (async) getPlaylist(playlistIdopt, limitopt)

Return a list of playlist items.
Parameters:
Name Type Attributes Default Description
playlistId string <optional>
Playlist id.
limit number <optional>
100 How many songs to return.
Example

Each item 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,
  "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",
    "likeStatus": "INDIFFERENT",
    "thumbnails": [...],
    "isAvailable": True,
    "isExplicit": False,
    "feedbackTokens": {
      "add": "AB9zfpJxtvrU...",
      "remove": "AB9zfpKTyZ..."
    }
  ]
}

# (async) getPlaylistSuggestions(suggestionsToken)

Gets suggested tracks to add to a playlist. Suggestions are offered for playlists with less than 100 tracks
Parameters:
Name Type Description
suggestionsToken Token returned by `getPlaylist` or this function
Returns:
Object containing suggested `tracks` and a `refresh_token` to get another set of suggestions. For data format of tracks, check `getPlaylist`

# (async) removePlaylistItems(playlistId:, videos:)

Remove songs from an existing playlist.
Parameters:
Name Type Description
playlistId: Playlist id.
videos: List of PlaylistItems, see `getPlaylist`.