ListenBrainz Elements

The following elements fetch data from ListenBrainz:

troi.listenbrainz.dataset_fetcher.DataSetFetcherElement

ListenBrainz has developed a tool called the dataset hoster which allows us to quickly host SQL queries on the web. This Element is a shortcut for fetching data from one of these endpoints and to return a list of Recordings.

troi.listenbrainz.feedback.ListensFeedbackLookup

Given a list of Recordings as input, fetch the feedback (like/hate) for a given user_name.

class troi.listenbrainz.feedback.ListensFeedbackLookup(user_name, auth_token=None)

Element to look up the user’s feedback for the given Recordings.

Parameters:

user_name – The ListenBrainz user_name for whom to fetch feedback information.

troi.listenbrainz.listens.RecentListensTimestampLookup

Given a list of Recordings, fetch the timestamp for when that Recording was listened to in the window specified by the days parameter.

class troi.listenbrainz.listens.RecentListensTimestampLookup(user_name, days: int, auth_token=None)

Element to look up the time when a user last listened given recordings in past X days. Note that the element is stateful and caches the recent listens lookup results!

Timestamps are stored in the listenbrainz dict, with key name “latest_listened_at”.

Parameters:
  • user_name – The ListenBrainz user for whome to fetch recent listen timestamps.

  • auth_token – a ListenBrainz auth token

  • days – The number of days to check.

troi.listenbrainz.recs.UserRecordingRecommendationsElement

Given a user_name and artist_type, fetch Recordings for that user if they are available. artist_type must be one of “top” for top artist recommendations (for that user), “similar” for similar artist recommendations (also for that user) or “raw” recommendations that have not be filtered like the top/similar recommendations.

troi.listenbrainz.stats.UserArtistsElement

Given a user_name and a time_range, fetch the top artist statistics for that user and time_range. Available time_ranges are defined in the ListenBrainz Statistics API documentation.

troi.listenbrainz.stats.UserReleasesElement

Given a user_name and a time_range, fetch the top release statistics for that user and time_range. Available time_ranges are defined in the ListenBrainz Statistics API documentation.

troi.listenbrainz.stats.UserRecordingsElement

Given a user_name and a time_range, fetch the top recording statistics for that user and time_range. Available time_ranges are defined in the ListenBrainz Statistics API documentation.

troi.listenbrainz.user.UserListElement

Given a list of users, return those users as User objects.

class troi.listenbrainz.user.UserListElement(user_list)

This element is used to pass a provided list of users into the pipeline.

Parameters:

user_list – A list of user_names

troi.listenbrainz.yim_user.YIMUserListElement

This Element is used for when we run the Year in Music report and create playlists. The elment fetches the list of users who should have YIM playlists generated and returns them.