diff --git a/apireference b/API_REFERENCE similarity index 82% rename from apireference rename to API_REFERENCE index bc2793ca..62f28d5d 100644 --- a/apireference +++ b/API_REFERENCE @@ -12,9 +12,9 @@ $commands¶meters[&optionalparameters]: getIndex (fetch data from index page. Returns: ArtistName, ArtistSortName, ArtistID, Status, DateAdded, [LatestAlbum, ReleaseDate, AlbumID], HaveTracks, TotalTracks, - IncludeExtras) + IncludeExtras, LastUpdated, ArtworkURL: a remote url to the artwork. To get the cached image path, see getArtistArt command) -getArtist&id=$artistid (fetch artist data. returns the artist object (see above) and album info: Status, AlbumASIN, DateAdded, AlbumTitle, ArtistName, ReleaseDate, AlbumID, ArtistID, Type) +getArtist&id=$artistid (fetch artist data. returns the artist object (see above) and album info: Status, AlbumASIN, DateAdded, AlbumTitle, ArtistName, ReleaseDate, AlbumID, ArtistID, Type, ArtworkURL: hosted image path. For cached image, see getAlbumArt command) getAlbum&id=$albumid (fetch data from album page. Returns the album object, a description object and a tracks object. Tracks contain: AlbumASIN, AlbumTitle, TrackID, Format, TrackDuration (ms), ArtistName, TrackTitle, AlbumID, ArtistID, Location, TrackNumber, CleanName (stripped of punctuation /styling), BitRate) @@ -52,4 +52,10 @@ checkGithub (updates the version information above and returns getVersion data) shutdown (shut down headphones) restart (restart headphones) -update (update headphones - you may want to check the install type in get version and not allow this if type==exe) \ No newline at end of file +update (update headphones - you may want to check the install type in get version and not allow this if type==exe) + +getArtistArt&id=$artistid (Returns either a relative path to the cached image, or a remote url if the image can't be saved to the cache dir) +getAlbumArt&id=$albumid (see above) + +getArtistInfo&id=$artistid (Returns the artist bio preformatted in html) +getAlbumInfo&id=$albumid (See above, returns album description in html) diff --git a/headphones/api.py b/headphones/api.py index 3da1ed6b..cf452a5b 100644 --- a/headphones/api.py +++ b/headphones/api.py @@ -15,7 +15,7 @@ import headphones -from headphones import db, mb, importer, searcher, postprocessor, versioncheck, logger +from headphones import db, mb, importer, searcher, cache, postprocessor, versioncheck, logger import lib.simplejson as simplejson from xml.dom.minidom import Document @@ -24,7 +24,7 @@ import copy cmd_list = [ 'getIndex', 'getArtist', 'getAlbum', 'getUpcoming', 'getWanted', 'getSimilar', 'getHistory', 'getLogs', 'findArtist', 'findAlbum', 'addArtist', 'delArtist', 'pauseArtist', 'resumeArtist', 'refreshArtist', 'queueAlbum', 'unqueueAlbum', 'forceSearch', 'forceProcess', 'getVersion', 'checkGithub', - 'shutdown', 'restart', 'update', ] + 'shutdown', 'restart', 'update', 'getArtwork', 'getInfo'] class Api(object): @@ -314,3 +314,43 @@ class Api(object): def _update(self, **kwargs): headphones.SIGNAL = 'update' + + def _getArtistArt(self, **kwargs): + + if 'id' not in kwargs: + self.data = 'Missing parameter: id' + return + else: + self.id = kwargs['id'] + + self.data = cache.getArtwork(ArtistID=self.id) + + def _getAlbumArt(self, **kwargs): + + if 'id' not in kwargs: + self.data = 'Missing parameter: id' + return + else: + self.id = kwargs['id'] + + self.data = cache.getArtwork(AlbumID=self.id) + + def _getArtistInfo(self, **kwargs): + + if 'id' not in kwargs: + self.data = 'Missing parameter: id' + return + else: + self.id = kwargs['id'] + + self.data = cache.getInfo(ArtistID=self.id) + + def _getAlbumInfo(self, **kwargs): + + if 'id' not in kwargs: + self.data = 'Missing parameter: id' + return + else: + self.id = kwargs['id'] + + self.data = cache.getInfo(AlbumID=self.id)