examples.special_mix.special_mix¶
An example of generating personalised playlists based on a user’s listening history.
The idea of Special Mix is: create a 60 minute playlist, taking a specific year of listen-history as the starting point.
Usage¶
The example can be run from the calliope_examples package when installed:
python3 -m calliope_examples.special_mix ...
You’ll need to choose and configure a listen history provider. Listen history
can be fetched using any of the
calliope.available_listen_history_providers() classes.
An example of using calliope.listenbrainz.listens to fetch Listenbrainz history:
... --history-provider=listenbrainz_history --history-provider-args="username=mylistenbrainzusername"
You also need to choose and configure a content resolver. Playable tracks can
be resolved using any of the calliope.available_content_resolvers() classes.
An example using calliope.localsearch to resolve tracks to locally available music:
... --resolver=localsearch
An example using calliope.spotify to resolve tracks to Spotify:
# Make sure `calliope.conf` exists and defines spotify API key, etc.
... --resolver=spotify --resolver-args=user=myspotifyusername
Notes
Listen history needs to be synced, and the initial sync can take a long time if there is a lot of history.
All candidate tracks are resolved before generating the playlist, as the
select module needs to know the track durations in advance. This can make
execution take a long time. Caching means that it should be faster once it has
run a few times.
If none of the tracks from listen history can be resolved, the output will be an empty playlist.
Attributes¶
Exceptions¶
Common base class for all non-exit exceptions. |
Classes¶
Config is stored in 'special_mix' section of calliope.conf |
|
Tracks where first play was in specified time period. |
Functions¶
|
Module Contents¶
- examples.special_mix.special_mix.DURATION = 3600¶
- exception examples.special_mix.special_mix.ConfigError¶
Bases:
ExceptionCommon base class for all non-exit exceptions.
Initialize self. See help(type(self)) for accurate signature.
- class examples.special_mix.special_mix.Config(sync=True, history_provider=None, history_provider_args=None, resolver=None, resolver_args=None)¶
Bases:
calliope.config.ConfigurationConfig is stored in ‘special_mix’ section of calliope.conf
- content_resolver()¶
- history_provider()¶
- sync()¶
- class examples.special_mix.special_mix.PlaylistGenerator(config)¶
- Parameters:
config (Config)
- config¶
- setup_content_resolver()¶
- setup_listen_history()¶
- examples.special_mix.special_mix.one_year_after(d)¶
- Parameters:
d (datetime.datetime)
- Return type:
datetime.datetime
- class examples.special_mix.special_mix.DiscoveredInTimePeriod(config, span='year', period=None, minimum_tracks=100)¶
Bases:
PlaylistGeneratorTracks where first play was in specified time period.
- Parameters:
config (Config)
- span = 'year'¶
- period = None¶
- minimum_tracks = 100¶
- setup()¶
- run()¶
- examples.special_mix.special_mix.main(output, debug, random_seed, history_provider, history_provider_args, resolver, resolver_args, sync)¶