Made nzbindex.nl more accurate
This commit is contained in:
@@ -10,7 +10,6 @@ config = [{
|
||||
'tab': 'providers',
|
||||
'name': 'nzbindex',
|
||||
'description': 'Free provider, but less accurate.',
|
||||
'advanced': True,
|
||||
'options': [
|
||||
{
|
||||
'name': 'enabled',
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
from couchpotato.core.event import fireEvent
|
||||
from couchpotato.core.helpers.encoding import simplifyString
|
||||
from couchpotato.core.helpers.encoding import toUnicode
|
||||
from couchpotato.core.helpers.rss import RSS
|
||||
from couchpotato.core.helpers.variable import tryInt
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.providers.nzb.base import NZBProvider
|
||||
from couchpotato.environment import Env
|
||||
from dateutil.parser import parse
|
||||
from urllib import urlencode
|
||||
import re
|
||||
import time
|
||||
import xml.etree.ElementTree as XMLTree
|
||||
|
||||
@@ -15,7 +18,7 @@ class NzbIndex(NZBProvider, RSS):
|
||||
|
||||
urls = {
|
||||
'download': 'http://www.nzbindex.nl/download/',
|
||||
'api': 'http://www.nzbindex.nl/rss/', #http://www.nzbindex.nl/rss/?q=due+date+720p&age=1000&sort=agedesc&minsize=3500&maxsize=10000
|
||||
'api': 'http://www.nzbindex.nl/rss/',
|
||||
}
|
||||
|
||||
http_time_between_calls = 1 # Seconds
|
||||
@@ -26,16 +29,21 @@ class NzbIndex(NZBProvider, RSS):
|
||||
if self.isDisabled() or not self.isAvailable(self.urls['api']):
|
||||
return results
|
||||
|
||||
q = '%s %s %s' % (movie['library']['titles'][0]['title'], movie['library']['year'], quality.get('identifier'))
|
||||
arguments = urlencode({
|
||||
'q': '%s %s' % (simplifyString(movie['library']['titles'][0]['title']), quality.get('identifier')),
|
||||
'q': q,
|
||||
'age': Env.setting('retention', 'nzb'),
|
||||
'sort': 'agedesc',
|
||||
'minsize': quality.get('size_min'),
|
||||
'maxsize': quality.get('size_max'),
|
||||
'rating': '1',
|
||||
'rating': 1,
|
||||
'max': 250,
|
||||
'more': 1,
|
||||
'complete': 1,
|
||||
})
|
||||
url = "%s?%s" % (self.urls['api'], arguments)
|
||||
|
||||
cache_key = 'nzbindex.%s.%s' % (movie['library'].get('identifier'), quality.get('identifier'))
|
||||
cache_key = 'nzbindex.%s' % q
|
||||
|
||||
data = self.getCache(cache_key, url)
|
||||
if data:
|
||||
@@ -49,20 +57,28 @@ class NzbIndex(NZBProvider, RSS):
|
||||
|
||||
for nzb in nzbs:
|
||||
|
||||
enclosure = self.getElements(nzb, 'enclosure')[0].attrib
|
||||
enclosure = self.getElement(nzb, 'enclosure').attrib
|
||||
|
||||
nzbindex_id = int(self.getTextElement(nzb, "link").split('/')[4])
|
||||
|
||||
try:
|
||||
description = self.getTextElement(nzb, "description")
|
||||
if ' nfo' in description.lower():
|
||||
nfo_url = re.search('href="(?P<nfo>.+)"', description).group('nfo')
|
||||
description = toUnicode(self.getCache('nzbindex.%s' % nzbindex_id, nfo_url, timeout = 25920000))
|
||||
except:
|
||||
pass
|
||||
|
||||
id = int(self.getTextElement(nzb, "link").split('/')[4])
|
||||
new = {
|
||||
'id': id,
|
||||
'id': nzbindex_id,
|
||||
'type': 'nzb',
|
||||
'provider': self.getName(),
|
||||
'name': self.getTextElement(nzb, "title"),
|
||||
'age': self.calculateAge(int(time.mktime(parse(self.getTextElement(nzb, "pubDate")).timetuple()))),
|
||||
'size': enclosure['length'],
|
||||
'size': tryInt(enclosure['length']) / 1024 / 1024,
|
||||
'url': enclosure['url'],
|
||||
'download': self.download,
|
||||
'detail_url': enclosure['url'].replace('/download/', '/release/'),
|
||||
'description': self.getTextElement(nzb, "description"),
|
||||
'description': description,
|
||||
'check_nzb': True,
|
||||
}
|
||||
new['score'] = fireEvent('score.calculate', new, movie, single = True)
|
||||
|
||||
Reference in New Issue
Block a user