You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.2 KiB

13 years ago
from couchpotato.core.helpers.encoding import tryUrlencode
from couchpotato.core.helpers.variable import tryInt
13 years ago
from couchpotato.core.logger import CPLog
from couchpotato.core.providers.nzb.base import NZBProvider
from couchpotato.environment import Env
13 years ago
log = CPLog(__name__)
class Nzbx(NZBProvider):
13 years ago
13 years ago
urls = {
'search': 'https://nzbx.co/api/search?%s',
13 years ago
'details': 'https://nzbx.co/api/details?guid=%s',
13 years ago
}
13 years ago
13 years ago
http_time_between_calls = 1 # Seconds
def _search(self, movie, quality, results):
# Get nbzs
13 years ago
arguments = tryUrlencode({
13 years ago
'q': movie['library']['identifier'].replace('tt', ''),
'sf': quality.get('size_min'),
13 years ago
})
nzbs = self.getJsonData(self.urls['search'] % arguments, headers = {'User-Agent': Env.getIdentifier()})
13 years ago
for nzb in nzbs:
13 years ago
results.append({
'id': nzb['guid'],
'url': nzb['nzb'],
'detail_url': self.urls['details'] % nzb['guid'],
'name': nzb['name'],
'age': self.calculateAge(int(nzb['postdate'])),
'size': tryInt(nzb['size']) / 1024 / 1024,
'score': 5 if nzb['votes']['upvotes'] > nzb['votes']['downvotes'] else 0
})