API
This covers the API autodoc from the Harvest Media library.
Client
-
class harvestmedia.api.client.Client(api_key, debug_level='INFO', webservice_url='https://service.harvestmedia.net/HMP-WS.svc')[source]
This class handles all HTTP interaction with the Harvest
Media API.
Parameters: |
- api_key – the Harvest Media API key to use
- debug_level – a Python logging debug level to use for the HM logger
- webservice_url – the base Harvest Media API URL
|
-
get_service_info()[source]
Gets the service info for the current HM account.
Service info includes URLs for album art, waveforms,
music streaming, and music downloading
This method is called automatically on client init
-
get_xml(method_uri)[source]
Called by the model classes to perform an HTTP GET and receive
XML from the HM API
Parameters: | method_uri – The Harvest Media endpoint to hit, without the host e.g. /getserviceinfo/{{service_token}} |
-
post_xml(method_uri, xml_post_body)[source]
Called by the model classes to perform an HTTP POST and receive
XML from the HM API
Parameters: |
- method_uri – The Harvest Media endpoint to hit, without the host e.g. /gettracks/{{service_token}}
- xml_post_body – The XML string to POST to the API
|
-
request_service_token()[source]
Uses the API key to get a valid service token from the HM api.
Service tokens are used for every call to the API, embedded in the URL
This method is called automatically on client init
Library
-
class harvestmedia.api.library.Library(_client)[source]
-
get_albums()[source]
Gets all of the albums for this library
-
class harvestmedia.api.library.LibraryQuery[source]
Performs calls for the Library model, also useful in a static
context. Available at Library.query or library_instance.query
-
get_libraries(_client)[source]
Returns all of the libraries on the configured Harvest Media account
Album
-
class harvestmedia.api.album.Album(_client)[source]
Represents a Harvest Media album asset
-
as_dict()[source]
Returns the dictionary representation of this Track
-
get_cover_url(width=None, height=None)[source]
Generates a URL that can be used to fetch the
cover image for this album on Harvest Media
Parameters: | width – optional integer specifiying the width of the image to fetch |
-
get_tracks(get_full_detail=True)[source]
Gets all of the tracks for a this album.
Parameters: | get_full_detail – if True, sends a second request to get all of the details for every track on the album |
-
class harvestmedia.api.album.AlbumQuery[source]
Performs calls for the Album model, also useful in a static
context. Available at Album.query or album_instance.query
-
get_albums_for_library(library_id, _client)[source]
Gets all of the albums for a particular library.
-
get_cover_url_for_album(album_id, _client, width=None, height=None)[source]
Generates a URL that can be used to fetch the
cover image for an album on Harvest Media
Parameters: |
- library_id – The Harvest Media library identifer
- _client – An initialized instance of harvestmedia.api.client.Client
- width – optional integer specifiying the width of the image to fetch
- height – optional integer specifiying the height of the image to fetch
|
Member
-
class harvestmedia.api.member.Member(_client)[source]
Represents a Harvest Media Member
-
classmethod register(**kwargs)[source]
Creates a new member from the params in kwargs.
See
Register Member
for valid arguments.
-
class harvestmedia.api.member.MemberQuery[source]
Performs calls for the Member model, also useful in a static
context. Available at Member.query
-
add_favourite(member_id, track_id, _client)[source]
Adds a track to a member’s favourites
Parameters: |
- member_id – The Harvest Media member identifer
- track_id – The Harvest Media track identifer
- _client – An initialized instance of harvestmedia.api.client.Client
|
-
get_by_id(member_id, _client)[source]
Takes takes a single member id and returns a
harvestmedia.api.member.Member object.
-
remove_favourite(member_id, track_id, _client)[source]
Removes a track from a member’s favourites
Parameters: |
- member_id – The Harvest Media member identifer
- track_id – The Harvest Media track identifer
- _client – An initialized instance of harvestmedia.api.client.Client
|
-
update_member(member_id, _client, **kwargs)[source]
Updates a member’s preferences and profile in the
Harvest Media database. Values in kwargs need to
match the nodes in the XML submission, see
Update Member
Playlists
-
class harvestmedia.api.playlist.Playlist(_client)[source]
Represents a Harvest Media member playlist asset
-
classmethod add(**kwargs)[source]
Creates and returns a new (empty) playlist for a member
Add Member Playlist
for arguments.
-
add_track(track_id)[source]
Add a track to a this playlist
Parameters: | track_id – The Harvest Media track identifer |
-
remove()[source]
Remove this playlist
-
remove_track(track_id)[source]
Removes a track from this playlist
Parameters: | track_id – The Harvest Media track identifer |
-
update()[source]
Updates the playlist on Harvest Media with the current values
values .
-
class harvestmedia.api.playlist.PlaylistQuery[source]
Performs calls for the Playlist model, also useful in a static
context. Available at Playlist.query or playlist_instance.query
-
add_track(member_id, playlist_id, track_id, _client)[source]
Adds a track to a member playlist.
Parameters: |
- member_id – The Harvest Media member identifer
- playlist_id – The Harvest Media playlist identifer
- track_id – The Harvest Media track identifer
- _client – An initialized instance of harvestmedia.api.client.Client
|
-
get_member_playlists(member_id, _client)[source]
Gets all of the playlists for a particular member.
-
remove_playlist(member_id, playlist_id, _client)[source]
Removes a member playlist.
Parameters: |
- member_id – The Harvest Media member identifer
- playlist_id – The Harvest Media playlist identifer
- _client – An initialized instance of harvestmedia.api.client.Client
|
-
remove_track(member_id, playlist_id, track_id, _client)[source]
Removes a track from a member playlist.
Parameters: |
- member_id – The Harvest Media member identifer
- playlist_id – The Harvest Media playlist identifer
- track_id – The Harvest Media track identifer
- _client – An initialized instance of harvestmedia.api.client.Client
|
-
update_playlist(member_id, playlist_id, playlist_name, _client)[source]
Updates a playlist in the Harvest Media database. Essentially
just a rename.
Parameters: |
- member_id – The Harvest Media member identifer
- playlist_id – The Harvest Media playlist_id identifer
- playlist_name – The new name of the playlist”
- _client – An initialized instance of harvestmedia.api.client.Client
- kwargs –
|
Track
-
class harvestmedia.api.track.Track(_client)[source]
Represents a Harvest Media track asset
-
as_dict()[source]
Returns the dictionary representation of this Track
-
get_waveform_url(width=None, height=None)[source]
Generates a URL that can be used to fetch the
waveform image of this track from Harvest Media
Parameters: |
- width – optional integer specifiying the width of the image to fetch
- height – optional integer specifiying the height of the image to fetch
|
-
class harvestmedia.api.track.TrackQuery[source]
Performs calls for the Track model, also useful in a static
context. Available at Track.query or track_instance.query
-
get_by_id(track_id, _client)[source]
Takes takes a single track id and returns a
harvestmedia.api.track.Track object.
-
get_tracks(track_ids, _client)[source]
Takes a list of track ids and returns a list of
harvestmedia.api.track.Track objects.
-
get_tracks_for_album(album_id, _client, get_full_detail=True)[source]
Gets all of the tracks for a particular album.
Parameters: |
- album_id – The Harvest Media album identifer
- _client – An initialized instance of harvestmedia.api.client.Client
- get_full_detail – if True, sends a second request to get all of the details for every track on the album
|
Support Classes
-
class harvestmedia.api.category.Category(_client)[source]
Represents a Harvest Media category item.
Consists of a name and a collection of sub-attributes
-
class harvestmedia.api.category.Attribute(_client)[source]
Represents a Harvest Media category attibute.
Consists of a name and a collection of sub-attributes