Discman
Loading...
Searching...
No Matches
LastFM Class Reference

An interface to last.fm for retrieving album art. More...

#include <last_fm.h>

Inheritance diagram for LastFM:
Collaboration diagram for LastFM:

Public Types

enum  Method { AlbumGetInfo }
 last.fm API methods. More...
 

Public Member Functions

 LastFM ()
 LastFM constructor.
 
void init () override
 Retrieves the last.fm API key as an environment variable.
 
std::vector< AlbumArtalbum_art (const std::string &artist, const std::string &title, const int width, const int height) override
 Retrieves all album art matching the artist and title.
 
- Public Member Functions inherited from AlbumArtProvider
AlbumArt album_art (const std::string &url, const int width, const int height)
 Retrieves the album art image at a given URL.
 

Static Public Attributes

static constexpr const char * BASE_URL = "http://ws.audioscrobbler.com/2.0/"
 The last.fm API base URL.
 

Static Private Member Functions

static std::string method_name (const Method method)
 Conversion method to convert a LastFM::Method to a string.
 
static std::string url (const Method method, const std::map< std::string, std::string > &params)
 Calls url_with_params() after adding additional parameters in params. These additional parameters set the last.fm API key and method name.
 

Static Private Attributes

static std::string _api_key
 last.fm API key.
 

Additional Inherited Members

- Static Public Member Functions inherited from AlbumArtProvider
static AlbumArtProviderinstance ()
 Factory method to return the album art provider. It may be called one or more times. Be sure to destroy() the instance in order to avoid leaks. It is suggested to do so in the teardown of the first caller.
 
static void destroy ()
 Destroys the AlbumArtProvider.
 
static std::string url_with_params (const std::string &url, const std::map< std::string, std::string > &params)
 Returns the URL of the API endpoint with the given parameters encoded as query parameters.
 
static std::string url_encode (const std::string &input)
 Encodes an arbitrary string into a query parameter value.
 
- Protected Member Functions inherited from AlbumArtProvider
 AlbumArtProvider ()
 AlbumArtProvider constructor.
 
virtual ~AlbumArtProvider ()
 AlbumArtProvider destructor.
 

Detailed Description

An interface to last.fm for retrieving album art.

Definition at line 31 of file last_fm.h.

Member Enumeration Documentation

◆ Method

last.fm API methods.

Enumerator
AlbumGetInfo 

Definition at line 35 of file last_fm.h.

Constructor & Destructor Documentation

◆ LastFM()

LastFM::LastFM ( )

LastFM constructor.

Definition at line 11 of file last_fm.cc.

Member Function Documentation

◆ album_art()

std::vector< AlbumArtProvider::AlbumArt > LastFM::album_art ( const std::string & artist,
const std::string & title,
const int width,
const int height )
overridevirtual

Retrieves all album art matching the artist and title.

Parameters
[in]artistAlbum artist.
[in]titleAlbum title.
[in]widthWidth of the returned images.
[in]heightHeight of the returned images.
Returns
List of album art images.

Implements AlbumArtProvider.

Definition at line 21 of file last_fm.cc.

◆ init()

void LastFM::init ( )
overridevirtual

Retrieves the last.fm API key as an environment variable.

Reimplemented from AlbumArtProvider.

Definition at line 17 of file last_fm.cc.

◆ method_name()

std::string LastFM::method_name ( const Method method)
staticprivate

Conversion method to convert a LastFM::Method to a string.

Parameters
[in]methodlast.fm method.
Returns
method as a string.

Definition at line 86 of file last_fm.cc.

◆ url()

std::string LastFM::url ( const Method method,
const std::map< std::string, std::string > & params )
staticprivate

Calls url_with_params() after adding additional parameters in params. These additional parameters set the last.fm API key and method name.

Parameters
[in]methodThe last.fm method.
[in]paramsMethod parameters only.
Returns
last.fm API endpoint URL.

Definition at line 94 of file last_fm.cc.

Member Data Documentation

◆ _api_key

std::string LastFM::_api_key
staticprivate

last.fm API key.

Definition at line 70 of file last_fm.h.

◆ BASE_URL

const char* LastFM::BASE_URL = "http://ws.audioscrobbler.com/2.0/"
staticconstexpr

The last.fm API base URL.

Definition at line 40 of file last_fm.h.


The documentation for this class was generated from the following files: