Managers
Operations on spotify playlists.
create(name, description='Randomly Generated Mix', overwrite=True)
Create a new, empty, playlist.
Warning
If the name of the playlist is an existing playlist, and overwrite is True, the said playlist will
be emptied.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
name of your playlist. |
required |
description
|
str
|
description of your playlist |
'Randomly Generated Mix'
|
overwrite
|
bool
|
Overwrite the existing playlist if the |
True
|
Returns:
| Type | Description |
|---|---|
PlaylistData
|
Created playlist |
Source code in chopin/managers/playlist.py
create_playlist(name, description='Playlist created with Chopin')
Create a playlist in the user library.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name for the playlist |
required |
description
|
str
|
Optional description for the playlist |
'Playlist created with Chopin'
|
Returns:
| Type | Description |
|---|---|
PlaylistData
|
Created playlist data. |
Source code in chopin/managers/playlist.py
create_playlist_from_queue(name, description='Mix generated from queue')
Create a playlist from the user's queue.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the playlist |
required |
description
|
str
|
An optional description |
'Mix generated from queue'
|
Returns:
| Type | Description |
|---|---|
PlaylistData
|
The created playlist |
Notes
Due to Spotify limitations, only 20 songs from the queue can be fetched and added to the playlist.
Source code in chopin/managers/playlist.py
doppelganger_playlist(source_playlist, new_playlist)
Create a "doppelganger", a similar playlist from an existing one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_playlist
|
str
|
The name of the playlist to copy. |
required |
new_playlist
|
str
|
The name of the new playlist. |
required |
Returns:
| Type | Description |
|---|---|
PlaylistData
|
The created playlist. |
Source code in chopin/managers/playlist.py
dump(playlist, filepath)
Dump a playlist in a JSON format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
playlist
|
PlaylistSummary
|
The playlist to write |
required |
filepath
|
Path
|
Target file to receive the dump |
required |
Source code in chopin/managers/playlist.py
fill(uri, tracks)
Fill a playlist with tracks.
Note
Duplicate tracks will be removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
uri of the playlist to fill |
required |
tracks
|
list[TrackData]
|
List of track uuids to add to the playlist |
required |
Source code in chopin/managers/playlist.py
shuffle_playlist(name)
Fetch a playlist from its name and shuffle_playlist it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
playlist name. |
required |
Returns:
| Type | Description |
|---|---|
PlaylistData
|
Shuffled playlist data. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the playlist name was not found. |
Source code in chopin/managers/playlist.py
summarize_playlist(playlist)
From a given playlist, create its summary.
Summaries are useful to describe and backup playlists. They contain extensive information about tracks, features, and can be serialized.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
playlist
|
PlaylistData
|
The playlist to summarize. |
required |
Returns:
| Type | Description |
|---|---|
PlaylistSummary
|
A playlist summary, with extended informations about tracks and statistics. |
Source code in chopin/managers/playlist.py
tracks_from_playlist_name(playlist_name, nb_tracks, user_playlists, release_range=None, selection_method=None)
Get a number of tracks from a playlist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
playlist_name
|
str
|
The name of your playlist |
required |
nb_tracks
|
int
|
Number of tracks to retrieve |
required |
user_playlists
|
list[PlaylistData]
|
List of existing user playlists. Used to map the name with the URI. |
required |
release_range
|
ReleaseRange | None
|
An optional datetime range for the release date of the tracks. |
None
|
selection_method
|
SelectionMethod | None
|
How tracks are chosen from the retrieved tracks.
See |
None
|
Returns:
| Type | Description |
|---|---|
list[TrackData]
|
A list of track data from the playlists |
Source code in chopin/managers/playlist.py
tracks_from_playlist_uri(playlist_uri, nb_tracks, release_range=None, selection_method=None)
Get tracks from a playlist URI.
Spotify API depreciation
It must be a public playlist, and the playlist must not be owned by Spotify.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
playlist_uri
|
str
|
Name of the artist or band to fetch related tracks from |
required |
nb_tracks
|
int
|
Number of tracks to retrieve. |
required |
release_range
|
ReleaseRange | None
|
An optional datetime range for the release date of the tracks. |
None
|
selection_method
|
SelectionMethod | None
|
How tracks are chosen from the retrieved tracks.
See |
None
|
Returns:
| Type | Description |
|---|---|
list[TrackData]
|
A list of track data from the artist radio. |
Source code in chopin/managers/playlist.py
Operations on spotify tracks.
save_tracks(tracks)
Add tracks to the current user liked songs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tracks
|
list[TrackData]
|
Tracks to add |
required |