Welcome to spotifynews!

pic1 pic2

API Reference

sqlite3db Module

Python library for database related operations

class spotifynews.database.sqlite3db.Sqlite3db(database_f='spotifynews.db')

Bases: object

__init__(database_f='spotifynews.db')

Create Sqlite3db object. Connect to database if exists. If database does not exist create it and create tables.

Parameters

database_f – name of sqlite3db file

close()

Close database after final interaction.

insert_song(playlist_id, song_id)

Add song_id to songs table if song does not exist, playist_id to playlist table if playlist does not exist. Add connection between song_id and playlist_id to songs_playlists table.

Parameters
  • playlist_id – playlist ID, URI or URL

  • song_id – song ID, URI or URL

insert_songs(playlist_id, song_ids)

Add song_ids to songs table.

Parameters
  • playlist_id – playlist ID, URI or URL

  • song_ids – list of song IDs, URI or URL

select_songs(playlist_id)

Get list of songs from playlist with ID playlist_id.

Parameters

playlist_id – playlist ID, URI or URL

Returns

A list of track IDs

client Module

Python library for operations with Spotify Web API

class spotifynews.spotify.client.Client

Bases: spotipy.client.Spotify

__init__()

Create Client object. Playlist scope will be supplied intuitievly. For most cases user token have to allow for playlist/track remove/add operations.

get_mirror_playlist_id(original_playlist_id, playlist_part_name)

Get mirror playlist id knowing the name of original playlist and playlist_part_name.

Parameters
  • original_playlist_id – playlist ID, URI or URL

  • playlist_part_name – string that was injected in mirror playlist name during process of mirror playlist creation.

Returns

mirror playlist ID

get_mirror_playlist_item_ids(original_playlist_id, known_track_ids)

Get tracks for mirror playlist by getting the tracks from original playlist and excluding tracks which are present in known_track_ids.

Parameters
  • original_playlist_id – playlist ID, URI or URL

  • known_track_ids – a list of track IDs

Returns

a list of track IDs

playlist_remove_all_items(playlist_id)

Remove all tracks from user playlist with ID playlist_id.

Parameters

playlist_id – playlist ID, URI or URL

update_mirror_playlist(original_playlist_id, known_track_ids, playlist_part_name='')

Update mirror playlist or create it if does not exist. Tracks that are not in known_track_ids will be added.

Parameters
  • original_playlist_id – playlist ID that have to be mirrored, URI or URL

  • known_track_ids – a list of track IDs

  • playlist_part_name – string that will be injected in mirror playlist name during process of mirror playlist creation.

Returns

a list of track IDs

spotifynews.spotify.client.chunk_playlist(item_ids)

update Module

Python library for operations with Spotify Web API and database

spotifynews.update.collections(database_f, original_playlist_id)

Get accumulated songs from local database and based on that create clone of original playlist with all tracks.

Parameters
  • database_f – name of sqlite3db file. It will be created if does not exist

  • original_playlist_id – playlist ID, URI or URL

Returns

A list of track IDs

spotifynews.update.news(database_f, original_playlist_id)

Accumulate song from source playlist in local database and based on that find new tracks, which are not yet in database. If this situation occurs, create clone of original playlist.

Parameters
  • database_f – name of sqlite3db file. It will be created if does not exist

  • original_playlist_id – playlist ID, URI or URL

Returns

A list of track IDs

Indices and tables