spotify_playlist_utility package¶
Submodules¶
spotify_playlist_utility.Spotify module¶
- class spotify_playlist_utility.Spotify.SpotifyManager(config_parser: configparser.ConfigParser)¶
Bases:
object
- authorize(scope_set: str) → None¶
- build_track_object_from_data(data: dict) → spotify_playlist_utility.Track.Track¶
Returns a Track object from a provided dict data
- Parameters
data (dict) – Dictionary representing representing a Spotify
"TrackObject" (API) –
- Returns
Track object capturing key elements of dict data
- Return type
- chunk_list(list, n)¶
- create_playlist(filepath: str) → str¶
Generate a playlist using the name and data of a .csv at the specified file path (format must match that of exported .csv files).
- Parameters
filepath (str) – File path to .csv file listing desired
to include in new playlist (tracks) –
- Returns
ID of newly generated playlist
- Return type
str
- export_playlist_tracks(filepath: str) → None¶
Generate a .csv listing of the specified playlist’s tracks and save to the specified file path (if not specified, default: .data.csv).
Called by argument: “-p”/”–export-playlist-tracks”
- Parameters
filepath (str) – File path pointing at where to save the generated .csv file.
- export_saved_tracks(file_path: str) → None¶
Generate a .csv listing of the user’s saved tracks and save to the specified file path (If not specified, default: .data.csv).
Called by argument: “-s/–export-saved-tracks”.
- Parameters
file_path (string) – File path pointing at where to save the generated .csv file.
- get_playlist(playlist_id: str) → spotify_playlist_utility.TrackLists.Playlist¶
Fetches Playlist object and populates the instance’s ‘tracks’ variable with the playlist’s tracks.
- Called by argument:
“-p”/”–export-playlist-tracks” “-z”/”–shuffle-playlist”
- Parameters
playlist_id (str) – ID of desired playlist.
- Returns
Playlist object with populated ‘tracks’ instance variable per playlist’s contents.
- Return type
- get_playlists() → List[spotify_playlist_utility.TrackLists.Playlist]¶
Fetches playlists from the user’s playlists. Creates data objects from the resulting playlists.
- Called by arguments:
“-p”/”–export-playlist-tracks” “-l”/”–list-playlists” “-z”/”–shuffle-playlist”
- Returns
List of playlist objects representing the user’s playlists.
- Return type
typing.List[Playlist]
- get_saved_tracks() → spotify_playlist_utility.TrackLists.TrackListing¶
Generate a TrackListing of the user’s saved tracks.
Called by argument: “-s/–export-saved-tracks”.
- Returns
TrackListing object storing a list of saved tracks.
- Return type
- list_playlists() → List[spotify_playlist_utility.TrackLists.Playlist]¶
Lists playlists in the console with indexing for user selection purposes.
- Called by arguments:
“-p”/”–export-playlist-tracks” “-l”/”–list-playlists” “-z”/”–shuffle-playlist”
- Returns
List of Playlist objects representing the user’s playlists.
- Return type
typing.List[Playlist]
- playlist_picker() → spotify_playlist_utility.TrackLists.Playlist¶
Lists user’s playlists. Prompts for numeric selection for desired playlist selection.
- Called by arguments:
“-p”/”–export-playlist-tracks” “-z”/”–shuffle-playlist”
- Returns
Returns Playlist object of selected playlist per input.
- Return type
- shuffle_playlist() → None¶
Shuffles the track order of a selected spotify playlist.
spotify_playlist_utility.Track module¶
spotify_playlist_utility.TrackLists module¶
- class spotify_playlist_utility.TrackLists.Playlist(uri: Optional[str] = None, name: Optional[str] = None, description: Optional[str] = None, tracks: List[spotify_playlist_utility.Track.Track] = [], reported_length=None)¶
- class spotify_playlist_utility.TrackLists.TrackListing(tracks: List[spotify_playlist_utility.Track.Track] = [])¶
Bases:
object
- export_tracks(file_path) → None¶
- import_tracks(file_path) → None¶