NZBx fixes

This commit is contained in:
Ruud
2012-12-20 15:19:40 +01:00
parent 3c04eed218
commit 031a186d71
+22 -13
View File
@@ -16,16 +16,16 @@ log = CPLog(__name__)
class Nzbx(NZBProvider, RSS): class Nzbx(NZBProvider, RSS):
endpoint = 'https://nzbx.co/api/' endpoint = 'https://nzbx.co/api/'
urls = { urls = {
'search': endpoint + 'search', 'search': 'https://nzbx.co/api/search',
'details': endpoint + 'details?guid=%s', 'details': 'https://nzbx.co/api/details?guid=%s',
'comments': endpoint + 'get-comments?guid=%s', 'comments': 'https://nzbx.co/api/get-comments?guid=%s',
'ratings': endpoint + 'get-votes?guid=%s', 'ratings': 'https://nzbx.co/api/get-votes?guid=%s',
'downloads': endpoint + 'get-downloads-count?guid=%s', 'downloads': 'https://nzbx.co/api/get-downloads-count?guid=%s',
'categories': endpoint + 'categories', 'categories': 'https://nzbx.co/api/categories',
'groups': endpoint + 'groups', 'groups': 'https://nzbx.co/api/groups',
} }
http_time_between_calls = 1 # Seconds http_time_between_calls = 1 # Seconds
@@ -39,9 +39,9 @@ class Nzbx(NZBProvider, RSS):
q = '"%s %s" %s' % (simplifyString(getTitle(movie['library'])), movie['library']['year'], quality.get('identifier')) q = '"%s %s" %s' % (simplifyString(getTitle(movie['library'])), movie['library']['year'], quality.get('identifier'))
arguments = tryUrlencode({ arguments = tryUrlencode({
'q': q, 'q': q,
'l': 250, # Limit on number of files returned 'l': 250, # Limit on number of files returned
#'i': '', # index of file #'i': '', # index of file
#'sf': '' # size filter #'sf': '' # size filter
}) })
url = "%s?%s" % (self.urls['search'], arguments) url = "%s?%s" % (self.urls['search'], arguments)
@@ -60,16 +60,25 @@ class Nzbx(NZBProvider, RSS):
nzbx_guid = nzb['guid'] nzbx_guid = nzb['guid']
# need to filter by completed def extra_score(item):
score = 0
if item['votes']['upvotes'] > item['votes']['downvotes']:
score += 5
return score
new = { new = {
'guid': nzbx_guid, 'guid': nzbx_guid,
'type': 'nzb', 'type': 'nzb',
'provider': self.getName(), 'provider': self.getName(),
'download': nzb['nzb'], 'download': self.download,
'url': nzb['nzb'],
'name': nzb['name'], 'name': nzb['name'],
'age': self.calculateAge(int(nzb['postdate'])), 'age': self.calculateAge(int(nzb['postdate'])),
'size': tryInt(nzb['size']) / 1024 / 1024, 'size': tryInt(nzb['size']) / 1024 / 1024,
'description': '',
'extra_score': extra_score,
'votes': nzb['votes'],
'check_nzb': True, 'check_nzb': True,
} }