From 1198d9b6e8eff83585757225d950671bf50880c5 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Thu, 13 Jun 2013 08:16:25 +0700 Subject: [PATCH 1/4] Fix for kat.ph - updated some of the parsing code --- headphones/searcher.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/headphones/searcher.py b/headphones/searcher.py index 7b4bda83..9af83ff0 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -789,7 +789,7 @@ def searchTorrent(albumid=None, new=False, losslessOnly=False): searchURL = providerurl + "/?%s" % urllib.urlencode(params) try: - data = urllib2.urlopen(searchURL, timeout=20).read() + data = urllib2.urlopen(searchURL, timeout=20) except urllib2.URLError, e: logger.warn('Error fetching data from %s: %s' % (provider, e)) data = False @@ -799,6 +799,7 @@ def searchTorrent(albumid=None, new=False, losslessOnly=False): logger.info(u'Parsing results from KAT' % searchURL) d = feedparser.parse(data) + if not len(d.entries): logger.info(u"No results found from %s for %s" % (provider, term)) pass @@ -807,10 +808,10 @@ def searchTorrent(albumid=None, new=False, losslessOnly=False): for item in d.entries: try: rightformat = True - title = item.title - seeders = item.seeds - url = item.links[1]['url'] - size = int(item.links[1]['length']) + title = item['title'] + seeders = item['torrent_seeds'] + url = item['links'][1]['href'] + size = int(item['links'][1]['length']) try: if format == "2": request = urllib2.Request(url) From 3d36e78228984be161918c134666e77592aef2ee Mon Sep 17 00:00:00 2001 From: rembo10 Date: Thu, 13 Jun 2013 08:45:34 +0700 Subject: [PATCH 2/4] Fix for nzbsrus hanging while parsing results --- headphones/searcher.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headphones/searcher.py b/headphones/searcher.py index 9af83ff0..05f7506f 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -348,7 +348,7 @@ def searchNZB(albumid=None, new=False, losslessOnly=False): if data: - d = json.loads(data.replace('null','None')) + d = json.loads(data) if d['matches'] <= 0: logger.info(u"No results found from NZBsRus for %s" % term) From faac6e4c983f681f934f9a1389ee0c8235661cd8 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Tue, 18 Jun 2013 13:25:19 +0700 Subject: [PATCH 3/4] 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: From cef169331526a38efbcf220b7fb9e72e199e9acf Mon Sep 17 00:00:00 2001 From: rembo10 Date: Fri, 21 Jun 2013 21:38:24 +0700 Subject: [PATCH 4/4] Update ip to new vip server --- headphones/mb.py | 2 +- lib/musicbrainzngs/musicbrainz.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/headphones/mb.py b/headphones/mb.py index f61ef991..18f60e17 100644 --- a/headphones/mb.py +++ b/headphones/mb.py @@ -44,7 +44,7 @@ def startmb(): mbport = int(headphones.CUSTOMPORT) sleepytime = int(headphones.CUSTOMSLEEP) elif headphones.MIRROR == "headphones": - mbhost = "192.30.34.130" + mbhost = "176.58.107.206" mbport = 8181 mbuser = headphones.HPUSER mbpass = headphones.HPPASS diff --git a/lib/musicbrainzngs/musicbrainz.py b/lib/musicbrainzngs/musicbrainz.py index 0dcdaf2a..c62fe8ab 100644 --- a/lib/musicbrainzngs/musicbrainz.py +++ b/lib/musicbrainzngs/musicbrainz.py @@ -497,7 +497,7 @@ def _mb_request(path, method='GET', auth_required=False, client_required=False, req.add_header('User-Agent', _useragent) # Add headphones credentials - if hostname == '192.30.34.130:8181': + if hostname == '176.58.107.206:8181': base64string = base64.encodestring('%s:%s' % (hpuser, hppassword)).replace('\n', '') req.add_header("Authorization", "Basic %s" % base64string)