From faac6e4c983f681f934f9a1389ee0c8235661cd8 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Tue, 18 Jun 2013 13:25:19 +0700 Subject: [PATCH] addAlbum added to API --- API_REFERENCE | 1 + headphones/api.py | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/API_REFERENCE b/API_REFERENCE index c20d32cb..d84590eb 100644 --- a/API_REFERENCE +++ b/API_REFERENCE @@ -35,6 +35,7 @@ findArtist&name=$artistname[&limit=$limit] (perform artist query on musicbrainz. findAlbum&name=$albumname[&limit=$limit] (perform album query on musicbrainz. Returns: title, url (artist), id (artist), albumurl, albumid, score, uniquename (artist - with disambiguation) addArtist&id=$artistid (add an artist to the db by artistid) +addAlbum&id=$releaseid (add an album to the db by album release id) delArtist&id=$artistid (delete artist from db by artistid) diff --git a/headphones/api.py b/headphones/api.py index b2ea1c18..16a22229 100644 --- a/headphones/api.py +++ b/headphones/api.py @@ -23,7 +23,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', + 'addAlbum', 'queueAlbum', 'unqueueAlbum', 'forceSearch', 'forceProcess', 'getVersion', 'checkGithub', 'shutdown', 'restart', 'update', 'getArtistArt', 'getAlbumArt', 'getArtistInfo', 'getAlbumInfo', 'getArtistThumb', 'getAlbumThumb'] class Api(object): @@ -247,6 +247,20 @@ class Api(object): return + def _addAlbum(self, **kwargs): + if 'id' not in kwargs: + self.data = 'Missing parameter: id' + return + else: + self.id = kwargs['id'] + + try: + importer.addReleaseById(self.id) + except Exception, e: + self.data = e + + return + def _queueAlbum(self, **kwargs): if 'id' not in kwargs: