
The Playlist Builder Library¶
The Playlist Builder Library (PBL) is a Python library that you can use to create playlists.
A Quick Example¶
For example, let’s say you like to listen to music on your morning commute. You mostly like to listen to classic rock, but you don’t want to get too out of touch with new music so you’d like a little bit of new music thrown in as well. With PBL you can easily create a such a playlist like so:
from pbl import *
classic_rock = Sample(PlaylistSource('Rock Classics'), sample_size=10)
new_music = Sample(PlaylistSource('New Music Tuesday'), sample_size=5)
combined = Shuffler(Concatenate([classic_rock, new_music]))
show_source(combined)
This program grabs the ‘Rock Classics’ playlist from Spotify (by searching for the most popular playlist on Spotify with that name), and randomly samples 10 tracks from it. Similarly it randomly samples 5 tracks from the ‘New Music Tuesday’ playlist. It concatentates these two playlists together and shuffles them. Here’s the resulting output:
1 Chop Suey! -- System Of A Down
2 Sweet Child O' Mine -- Guns N' Roses
3 Dust in the Wind -- Kansas
4 Dawkins Christ -- Refused
5 Born in the U.S.A. -- Bruce Springsteen
6 Slowly -- Dropout
7 All Along The Watchtower -- Jimi Hendrix
8 Eye of the Tiger -- Survivor
9 My Kind -- Hilary Duff
10 White Knuckles -- Boh Doran
11 Something Like Happiness -- The Maccabees
12 Owner Of A Lonely Heart -- Yes
13 Don't Stop Believin' -- Journey
14 Africa -- Toto
15 Lola - Remastered -- The Kinks
As you can see, that’s 15 songs, 5 are new, and 10 are classic. The function show_source shows the playlist in the terminal, but of course to listen to a playlist, it needs to be saved on Spotify. We can do that by adding a PlaylistSave call like so:
from pbl import *
classic_rock = Sample(PlaylistSource('Rock Classics'), sample_size=10)
new_music = Sample(PlaylistSource('New Music Tuesday'), sample_size=5)
combined = Shuffler(Concatenate([classic_rock, new_music]))
combined = PlaylistSave(combined, 'my morning commute', 'plamere')
show_source(combined)
Now, whenever the program is run, my ‘my morning commute’ playlist will be updated will be updated with a different set of tracks sampled from Rock Classics and New Music Tuesday.
Quick Start¶
To get started, install pbl with:
% pip install pbl
this should take care of all the dependencies (including spotipy, pyen and others).
Or you can get the source from github at https://github.com/plamere/pbl and install it with:
% python setup.py install
Once installed, just import pbl and you’ll have everything you need. Here are a few more quick examples to give you a taste of the kind of things you can do with PBL.
Setup your Spotify API credentials¶
To use any of the Spotify sources or sinks you’ll need to get a Spotify API key. See http://spotipy.readthedocs.org/en/latest/#authorized-requests in the Spotipy docs on how to get a key and how to set the credentials.
Setup your Echo Nest API credentials¶
To use any of the Echo Nest sources or filters you’ll need to get an Echo Nest API key:
- Get an API key - to use the Echo Nest API you need an Echo Nest API key. You can get one for free at http://developer.echonest.com.
- Set an environment variable named ECHO_NEST_API_KEY to your API key
More examples¶
Here are a few more examples to give you a feel for what you can do with PBL.
Playlist of 30 minutes of the lowest energy songs from Your Favorite Coffeehouse:
import pbl
coffeehouse = pbl.PlaylistSource('Your Favorite Coffeehouse')
coffeehouse = pbl.Annotator(coffeehouse, 'echonest')
coffeehouse = pbl.Sorter(coffeehouse, 'echonest.energy')
coffeehouse = pbl.LongerThan(coffeehouse, 30 * 60)
pbl.show_source(coffeehouse, props=['duration', 'echonest.energy'])
Output:
1 Fortune - Acoustic -- William Fitzsimmons
duration -> 228
echonest.energy -> 0.055224
2 I Know It’s Pathetic But That Was the Greatest Night of My Life -- Sun Kil Moon
duration -> 107
echonest.energy -> 0.061157
3 I Shall Cross This River -- The Black Atlantic
duration -> 201
echonest.energy -> 0.100383
4 Say Yes -- Elliott Smith
duration -> 135
echonest.energy -> 0.109814
5 Hurricane -- Mindy Smith
duration -> 212
echonest.energy -> 0.110599
6 I Knew This Would Be Love -- Imaginary Future
duration -> 210
echonest.energy -> 0.119146
7 Emmeline -- Bruno Merz
duration -> 250
echonest.energy -> 0.124862
8 A Heart Arcane -- Horse Feathers
duration -> 169
echonest.energy -> 0.12929
9 Come Home -- Ryan Adams
duration -> 290
echonest.energy -> 0.132386
Sort by title length¶
Re-sort the Teen Party Playlist in order of the length of the title and artist:
from pbl import *
tp = CustomSorter(PlaylistSource('Teen Party'),
lambda tid: len(tlib.get_attr(tid, 'title') + tlib.get_attr(tid, 'artist')))
show_source(tp)
Output:
1 Fun -- Pitbull
2 Bad Girls -- MKTO
3 21 -- Hunter Hayes
4 Fancy -- Iggy Azalea
5 Elastic Heart -- Sia
6 Sparks -- Hilary Duff
7 Beautiful Now -- Zedd
8 Emergency -- Icona Pop
9 In My Head -- Galantis
10 Firework -- Katy Perry
11 Back of the Car -- RAC
12 Stitches -- Shawn Mendes
13 Worth It -- Fifth Harmony
14 Beat of My Drum -- Powers
15 Black Magic -- Little Mix
16 Sunshine -- Young Empires
17 Waiting For Love -- Avicii
18 Victoria -- Jordan Bratton
19 Uma Thurman -- Fall Out Boy
20 Love Me Badder -- Elliphant
21 Pray to God -- Calvin Harris
22 Good Thing -- Sage The Gemini
23 Pity Party -- Melanie Martinez
24 Pretty Girls -- Britney Spears
25 Want To Want Me -- Jason Derulo
26 One In A Million -- Hilary Duff
27 Woke The F*ck Up -- Jon Bellion
28 Another You -- Armin van Buuren
29 Honey, I'm Good. -- Andy Grammer
30 Can't Feel My Face -- The Weeknd
31 You Know You Like It -- DJ Snake
32 Together - Radio Edit -- CAZZETTE
33 Ignition/Do You... -- Phoebe Ryan
34 Shut Up and Dance -- Walk the Moon
35 Drop Dead Beautiful -- Elijah Blake
36 Around The World -- Natalie La Rose
37 New York Raining -- Charles Hamilton
38 Bitch Better Have My Money -- Rihanna
39 Zero Gravity - Radio Edit -- Borgeous
40 I Really Like You -- Carly Rae Jepsen
41 The Night Is Still Young -- Nicki Minaj
42 Flex (Ooh, Ooh, Ooh) -- Rich Homie Quan
43 Senses (feat. Lostboycrow) -- Cheat Codes
44 Lean On (feat. MØ & DJ Snake) -- Major Lazer
45 Where Are Ü Now (with Justin Bieber) -- Jack Ü
46 Cheerleader - Felix Jaehn Remix Radio Edit -- OMI
47 Marvin Gaye (feat. Meghan Trainor) -- Charlie Puth
48 Walk The Moon - Teen Party Intro -- Various Artists
49 Powerful (feat. Ellie Goulding & Tarrus Riley) -- Major Lazer
50 Hey Mama (feat. Nicki Minaj, Bebe Rexha & Afrojack) -- David Guetta
Dad’s Selfish Playlist¶
Dad is on a roadtrip with daughter. They agree to alternate between dad’s music and daughter’s music. Dad is selfish, so he makes a playlist that alternates the longest cool jazz tracks with the shortest teen party playlists with this script:
from pbl import *
teen_party = First(Sorter(PlaylistSource('Teen Party'), 'duration'), 10)
jazz_classics = Last(Sorter(PlaylistSource('Jazz Classics'), 'duration'), 10)
both = Alternate([teen_party, Reverse(jazz_classics)])
show_source(both, props=['duration', 'src'])
Output:
1 Walk The Moon - Teen Party Intro -- Various Artists
spotify.duration_ms -> 7500
src -> Teen Party
2 Feed The Fire -- Geri Allen
spotify.duration_ms -> 683160
src -> Jazz Classics
3 Pretty Girls -- Britney Spears
spotify.duration_ms -> 163960
src -> Teen Party
4 Turiya & Ramakrishna -- Alice Coltrane
spotify.duration_ms -> 498146
src -> Jazz Classics
5 Emergency -- Icona Pop
spotify.duration_ms -> 169617
src -> Teen Party
6 Real & Imagined -- Kait Dunton
spotify.duration_ms -> 465573
src -> Jazz Classics
7 Lean On (feat. MØ & DJ Snake) -- Major Lazer
spotify.duration_ms -> 176561
src -> Teen Party
8 Stand by me -- Buika
spotify.duration_ms -> 442693
src -> Jazz Classics
9 Flex (Ooh, Ooh, Ooh) -- Rich Homie Quan
spotify.duration_ms -> 177057
src -> Teen Party
10 Bewitched, Bothered, And Bewildered -- Ella Fitzgerald
spotify.duration_ms -> 421466
src -> Jazz Classics
11 Cheerleader - Felix Jaehn Remix Radio Edit -- OMI
spotify.duration_ms -> 180021
src -> Teen Party
12 Les Feuilles Mortes / Autumn Leaves -- Dee Dee Bridgewater
spotify.duration_ms -> 409000
src -> Jazz Classics
13 Sparks -- Hilary Duff
spotify.duration_ms -> 185946
src -> Teen Party
14 Falling In Love with Love -- Eliane Elias
spotify.duration_ms -> 386493
src -> Jazz Classics
15 Marvin Gaye (feat. Meghan Trainor) -- Charlie Puth
spotify.duration_ms -> 187741
src -> Teen Party
16 Violets For Your Furs - 2007 - Remaster -- Jutta Hipp
spotify.duration_ms -> 369568
src -> Jazz Classics
17 Together - Radio Edit -- CAZZETTE
spotify.duration_ms -> 188170
src -> Teen Party
18 I Didn't Know What Time It Was -- Cecile McLorin Salvant
spotify.duration_ms -> 367493
src -> Jazz Classics
19 Another You -- Armin van Buuren
spotify.duration_ms -> 192306
src -> Teen Party
20 J.P. Vanderbilt IV -- Charlie Shavers
spotify.duration_ms -> 350600
src -> Jazz Classics
The resulting playlist has is filled with long Jazz tracks (no shorter than 5 minutes) and short Teen Party tracks (no longer than 3 minutes).
Even more examples¶
There are even more examples in the repos at https://github.com/plamere/pbl/tree/master/examples
Using PBL¶
In PBL you create a pipeline of objects that contribute to the playlist. Typically an object in the pipeline will pull tracks from upstream, process them and make them available for objects that are downstream in the pipeline. The pipeline contains at least one Source object and will typically include Operator objects, Filter objects, Sorting objects and Sink objects. Read on to learn more about the different types of objects.
Sources¶
These objects are the source of tracks in a pipeline
Spotify Sources¶
- AlbumSource - produces tracks from the given album
- ArtistTopTracks - produces the top tracks for a given artist
- PlaylistSource - poroduces tracks from a Spotify Playlist
- TrackSource - produces the given tracks
Echo Nest Sources¶
- EchoNestArtistPlaylist - produces tracks from the given artist
- EchoNestArtistRadio - produces tracks from the given artist and similar artists
- EchoNestGenreRadio - produces tracks from the given genre
- EchoNestHotttestSongs - produces the most popular songs
- EchoNestPlaylist - Uses the Echo Nest playlist API to generate a wide range of track sequences
Generic Sources¶
- FakeTrackSource - produces an infinite supply of fake tracks
Operators¶
Operators work on a pipeline of tracks
- Alternate - takes a list of multiple sources and produces a stream of tracks drawn from the sources
- Annotate - Annotates tracks with data from a source such as Spotify or The Echo Nest
- Buffer - Collects a fixed number of tracks (useful when a source could generate a large number of tracks)
- Case - Conditionally choses tracks from multiple sources
- Concatentate - concatenates streams
- Conditional - choses between two streams based on a conditional function
- DeDup - De-duplicates tracks from a stream
- First - Returns the first N tracks from a stream
- Last - Returns the last N tracks from a stream
- LongerThan - Stops the stream when the track duration is longer than the given time
- Looper - Loops through a stream forever
- Sample - Randomly samples tracks from a stream
- ShorterThan - Stops the stream when the next track would make the total stream duration longer than the given time
- Split - Split a stream into two streams
Filters¶
- ArtistFilter - Removes tracks from the stream that match the given aritsts
- AttributeRangeFilter - Filter the stream to only include tracks where the given attribute is in the given range
- TrackFilter - Filter the stream to include tracks that are NOT in the given filter playlist
Sorting¶
- CustomSorter - sort the stream based upon a custom key
- Reverse - reverse the order of the tracks in the stream
- Shuffler - randomly shuffle the order of the tracks
- Sorter - sort the tracks by an attribute
Sinks¶
- Debugger - dump all details of each track in the stream
- Dumper - show tracks with configurable properties in the stream
- PlaylistSave - save the playlist to spotify
- SaveToJson - save the playlist to a json file
API Reference¶
standard
Module¶
A set of standard sources, filters, sorters and sinks
-
class
pbl.standard_plugs.
Alternate
(source_list, fail_fast=False)¶ Alternate tracks from multiple streams
Parameters: source_list – a list of sources
-
class
pbl.standard_plugs.
Annotator
(source, type)¶ Annotates the tracks in a stream with external information
Parameters: - source – the source of tracks
- type – the type of annotation (spotify, echonest)
-
class
pbl.standard_plugs.
ArtistFilter
(source, artistNames)¶ Removes tracks from the stream that have the given artists
Parameters: - source – the source of tracks
- artistNames – the names of the artists to be removed
-
class
pbl.standard_plugs.
AttributeRangeFilter
(source, attr, match=None, min_val=None, max_val=None)¶ Filters tracks based upon range check of an attribute
Parameters: - source – the source of tracks
- attr – the attribute of interest
- match – if not None, attribute value must match this exactly
- min_val – if not None, attribute value must be at least this
- max_val – if not None, attribute value must be no more than this
-
class
pbl.standard_plugs.
Buffer
(source, max_size=40)¶ Buffer up the given number of tracks
Parameters: - source – the stream source
- max_size – the size of the buffer
-
class
pbl.standard_plugs.
Case
(func, source_map)¶ Selects tracks from streams based upon a mapping function
Parameters: - source – the source of tracks
- func – a function that returns the source_map key
- source_map – a may of key to source streams
-
class
pbl.standard_plugs.
Concatenate
(source_list)¶ Concatenate multiple streams
Parameters: source_list – a list of sources
-
class
pbl.standard_plugs.
Conditional
(cond_func, trueSource, falseSource)¶ Alternate tracks from two streams based on a conditional
Parameters: - source – the source of tracks
- cond_func – a function that returns a boolean
- trueSource – source of tracks when conf_func returns True
- falseSource – source of tracks when conf_func returns False
-
class
pbl.standard_plugs.
CustomSorter
(source, keyfunc, reverse=False, max_size=0)¶ Sorts the tracks by a custom key
Parameters: - source – the source of the tracks
- keyfunc – function that turns a track id into the sort key
- reverse – if True reverse the sort
- max_size – maximum tracks to sort
-
class
pbl.standard_plugs.
DeDup
(source, by_name=False)¶ Remove any duplicate tracks in the stream
Parameters: - source – the stream source
- by_name – if True match by track ID and name
-
class
pbl.standard_plugs.
Debugger
(source)¶ Shows details on each track in the stream
Parameters: source – the source of tracks
-
class
pbl.standard_plugs.
Dumper
(source, props)¶ Dumps tracks to the terminal
Parameters: - source – the source of tracks
- props – list of property names to be included in the dump
-
class
pbl.standard_plugs.
FakeTrackSource
(count=10)¶ Generates a series of fake tracks, suitable for testing
param: count: the number of tracks to generate
-
class
pbl.standard_plugs.
First
(source, sample_size=10)¶ Returns the first tracks from a stream
Parameters: - source – the source of tracks
- sample_size – the number of tracks to return
-
class
pbl.standard_plugs.
Last
(source, sample_size=10)¶ Returns the last tracks from a stream
Parameters: - source – the source of tracks
- sample_size – the number of tracks to return
-
class
pbl.standard_plugs.
LongerThan
(source, time=1200)¶ Limit the stream, if possible, to tracks with a duration that is longer than the given time
Parameters: - source – the source stream
- time – the time in seconds
-
class
pbl.standard_plugs.
Looper
(source, max_size=200)¶ Given a source, generate a stream of a given size by circulating through the tracks in the source
Parameters: - source – the stream source
- max_size – the number of tracks returned
-
class
pbl.standard_plugs.
Reverse
(source)¶ Reverses the order of the tracks in the stream
Parameters: source – the source of tracks
-
class
pbl.standard_plugs.
Sample
(source, sample_size=10)¶ Randomly sample tracks from the stream
Parameters: - source – the source of tracks
- sample_size – the number of tracks to return
-
class
pbl.standard_plugs.
SaveToJson
(source, name='playlist.json', max_size=100)¶ Saves the stream to json :param source: the source of tracks :param name: the name of the json file :param max_size: the max tracks to save
-
class
pbl.standard_plugs.
ShorterThan
(source, time=1200)¶ Limit the stream, if possible, to tracks with a duration that is just shorter than the given time
Parameters: - source – the source stream
- time – the time in seconds
-
class
pbl.standard_plugs.
Shuffler
(source, max_size=0)¶ Shuffles the tracks in the stream
Parameters: - source – the source of tracks
- max_size – the maximum number of tracks to return
-
class
pbl.standard_plugs.
Sorter
(source, attr, reverse=False, max_size=0)¶ Sorts the tracks in the given stream by the given attribute
Parameters: - source – the source of the tracks
- attr – the attribute to be sorted
- reverse – if True reverse the sort
- max_size – maximum tracks to sort
-
class
pbl.standard_plugs.
Split
(source, split_index)¶ Splits a stream into two streams
Parameters: - source – the source of the track stream
- split_index – the index where the split occurs
-
class
pbl.standard_plugs.
TrackFilter
(source, filter)¶ Removes tracks from the stream based on a second stream
Parameters: - source – the source of tracks
- filter – the stream of bad tracks to be removed
-
pbl.standard_plugs.
get_simple_day_part
()¶ returns the daypart
-
pbl.standard_plugs.
is_day_of_week
(day_of_week)¶ checks if cur day is given day of the week
Parameters: day_of_week – Monday is 0 and Sunday is 6.
engine
Module¶
methods for running a PBL pipeline
-
pbl.engine.
get_tracks
(source, max_tracks=40)¶ pulls tracks from the given source and returns them
Parameters: - source – the source of tracks
- max_tracks – the maximum number of tracks to pull
Returns: a list of tracks
-
pbl.engine.
run_source
(source, max_tracks=40)¶ pulls tracks from the given source
Parameters: - source – the source of tracks
- max_tracks – the maximum number of tracks to pull
-
pbl.engine.
show_source
(source, ntracks=100, props=[])¶ pulls tracks from the given source and displays them
Parameters: - source – the source of tracks
- ntracks – the maximum number of tracks to pull
- props – properties to display
spotify
Module¶
A set of sources and annotators for Spotify. An Spotify track has the following attributes:
{
"src": "Teen Party",
"artist": "Various Artists",
"title": "Walk The Moon - Teen Party Intro",
"spotify": {
"album": {
"album_type": "album",
"name": "Walk The Moon - Playlist Intros",
"external_urls": {
"spotify": "https://open.spotify.com/album/6ZQf8UHq907D9hu5amANXX"
},
"uri": "spotify:album:6ZQf8UHq907D9hu5amANXX",
"href": "https://api.spotify.com/v1/albums/6ZQf8UHq907D9hu5amANXX",
"images": [
{
"url": "https://i.scdn.co/image/1d06a0a9262a6634ca3a1cf9a9a0855b2245ba81",
"width": 640,
"height": 640
},
{
"url": "https://i.scdn.co/image/2d2dff2f132443083b4368ebead2c71d4dcd7eb7",
"width": 300,
"height": 300
},
{
"url": "https://i.scdn.co/image/c7aa8589b67593d3117020a5a0080598a5997785",
"width": 64,
"height": 64
}
],
"type": "album",
"id": "6ZQf8UHq907D9hu5amANXX",
"available_markets": [ "AD", "...", ]
},
"name": "Walk The Moon - Teen Party Intro",
"uri": "spotify:track:5oPzMRHjORXQlLemgpfacm",
"external_urls": {
"spotify": "https://open.spotify.com/track/5oPzMRHjORXQlLemgpfacm"
},
"popularity": 5,
"explicit": false,
"preview_url": "https://p.scdn.co/mp3-preview/5e14b8b02dae9adf80f41fd0d4c03ca17002b939",
"track_number": 2,
"disc_number": 1,
"href": "https://api.spotify.com/v1/tracks/5oPzMRHjORXQlLemgpfacm",
"artists": [
{
"name": "Various Artists",
"external_urls": {
"spotify": "https://open.spotify.com/artist/0LyfQWJT6nXafLPZqxe9Of"
},
"uri": "spotify:artist:0LyfQWJT6nXafLPZqxe9Of",
"href": "https://api.spotify.com/v1/artists/0LyfQWJT6nXafLPZqxe9Of",
"type": "artist",
"id": "0LyfQWJT6nXafLPZqxe9Of"
}
],
"duration_ms": 7500,
"external_ids": {},
"type": "track",
"id": "5oPzMRHjORXQlLemgpfacm",
"available_markets": [ "AD", "AR", "...", ]
},
"duration": 7,
"id": "5oPzMRHjORXQlLemgpfacm"
}
-
class
pbl.spotify_plugs.
AlbumSource
(title=None, artist=None, uri=None)¶ A PBL Source that generates a series of tracks given an album
Parameters: - title – the title of the album
- artist – the artist of the album
- uri – the URI of the album
-
class
pbl.spotify_plugs.
ArtistTopTracks
(name=None, uri=None)¶ A PBL Source that generates a series of top tracks by the given artist
Parameters: - name – the name of the artist
- uri – the uri of the artist
-
class
pbl.spotify_plugs.
PlaylistSave
(source, playlist_name=None, user=None, uri=None, create=False, append=False, max_size=100)¶ A PBL Sink that saves the source stream of tracks to the given playlist
Parameters: - source – the source of tracks to be saved
- playlist_name – the name of the playlist
- user – the owner of the playlist
- uri – the uri of the playlist
-
class
pbl.spotify_plugs.
PlaylistSource
(name, uri=None, user=None)¶ A PBL source that generates a stream of tracks from the given Spotify playlist. If only a name is provided, the playlist will be searched for. Search success can be improved if the owner of the playlist is also provided.
Parameters: - name – the name of the playlist
- uri – the uri of the playlist
- user – the owner of the playlist
-
class
pbl.spotify_plugs.
TrackSource
(uris=[])¶ A PBL Source that generates the a stream of tracks from the given list of URIs
Parameters: uris – a list of spotify track uris
-
class
pbl.spotify_plugs.
TrackSourceByName
(title)¶ A PBL Source that generates a track given its artist and title
Parameters: title – the title and/or artist of the track
echonest
Module¶
A set of sources and annotators for Echo Nest API. An Echo Nest track has the following attributes:
{
"src": "Echo Nest Playlist Artist radio for weezer",
"artist": "Weezer",
"title": "Perfect Situation",
"id": "3oM0sxN8FZwgUvccT9n34d",
"duration": 255,
"echonest": {
"album_type": "unknown",
"artist_discovery": 0.3328849845870755,
"speechiness": 0.035816,
"duration": 255.37288,
"id": "SOZKJDU1461E3C9B6E",
"title": "Perfect Situation",
"acousticness": 0.03422,
"danceability": 0.452168,
"song_currency": 0.017234941438929167,
"artist_familiarity": 0.812078,
"artist_id": "AR633SY1187B9AC3B9",
"energy": 0.791129,
"song_hotttnesss": 0.391096,
"tempo": 93.946,
"artist_name": "Weezer",
"instrumentalness": 0.000311,
"key": 6,
"audio_md5": "dca9daa0723096d6ed7a5507b1bca17e",
"album_name": "Make Believe",
"album_date": "2005-05-09",
"liveness": 0.135915,
"artist_hotttnesss": 0.72962,
"mode": 1,
"time_signature": 4,
"loudness": -4.131,
"valence": 0.37193
}
}
-
class
pbl.echonest_plugs.
EchoNestArtistPlaylist
(artist, count)¶ A PBL source that generates a stream of tracks by the given artist
Parameters: - artist – the name of the artist
- count – the number of tracks to generate
-
class
pbl.echonest_plugs.
EchoNestArtistRadio
(artist, count)¶ A PBL source that generates a stream of tracks that are by the given artist or similar artists
Parameters: - artist – the name of the artist
- count – the number of tracks to generate
-
class
pbl.echonest_plugs.
EchoNestGenreRadio
(genre, count)¶ A genre radio track source
Parameters: - genre – the genre of interest
- count – the number of tracks to generate
-
class
pbl.echonest_plugs.
EchoNestHottestSongs
(count)¶ Returns the set of hotttest songs from the Echo Nest. TBD :param count: the number of tracks to generate
-
class
pbl.echonest_plugs.
EchoNestPlaylist
(name, params)¶ A track source that uses the Echo Nest playlist API to generate tracks
Parameters: - name – the name of the source
- params – a dictionary of params (see the Echo Nest playlist/static documentation for a full list of available parameters.
-
next_track
()¶ returns the next track in the stream
track_manager
Module¶
-
class
pbl.track_manager.
TrackLibrary
¶ manages track attributes
-
add_track
(source_name, tid, info)¶ Adds a track to the library
Parameters: - source_name – the name of the track source
- tid – the track id
- info – the track info
-
get_attr
(tid, attr)¶ Gets the value of the given attribute for a track
Parameters: - tid – the track id
- attr – the attribte name
-
get_track
(tid)¶ gets the track info
Parameters: tid – the track id
-
frog
Module¶
-
class
pbl.frog.
BoilTheFrogSource
(start, end=None)¶ a PBL source that generates a list of tracks that gradually go from the starting artist to the ending artist
Parameters: - start – the starting artist
- end – the ending artist
Frequently Asked Questions¶
- I get an spotipy.oauth2.SpotifyOauthError: No client id error, what do I do? You need to set up your Spotify API credentials. See the Quick Start section for more details.
- I get an error pyen.PyenConfigurationException: Can’t find your API keyanywhere, what do I do? You need to set up your Echo Nest API credentials. See the Quick Start for more details.