NZBx provider

This commit is contained in:
Ruud
2012-12-20 15:45:04 +01:00
parent 031a186d71
commit b8e86b378f
2 changed files with 13 additions and 23 deletions
@@ -9,8 +9,8 @@ config = [{
{ {
'tab': 'searcher', 'tab': 'searcher',
'subtab': 'nzb_providers', 'subtab': 'nzb_providers',
'name': 'nzbx', 'name': 'nzbX',
'description': 'Free provider, less accurate. See <a href="https://www.nzbx.co/">nzbx</a>', 'description': 'Free provider, less accurate. See <a href="https://www.nzbx.co/">nzbX</a>',
'options': [ 'options': [
{ {
'name': 'enabled', 'name': 'enabled',
+11 -21
View File
@@ -1,23 +1,18 @@
from couchpotato.core.event import fireEvent from couchpotato.core.event import fireEvent
from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode, \ from couchpotato.core.helpers.encoding import tryUrlencode
simplifyString
from couchpotato.core.helpers.rss import RSS from couchpotato.core.helpers.rss import RSS
from couchpotato.core.helpers.variable import tryInt, getTitle from couchpotato.core.helpers.variable import tryInt
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog
from couchpotato.core.providers.nzb.base import NZBProvider from couchpotato.core.providers.nzb.base import NZBProvider
from couchpotato.environment import Env
from dateutil.parser import parse
import re
import time
import traceback
import json import json
import traceback
log = CPLog(__name__) log = CPLog(__name__)
class Nzbx(NZBProvider, RSS): class Nzbx(NZBProvider, RSS):
endpoint = 'https://nzbx.co/api/' endpoint = 'https://nzbx.co/api/'
urls = { urls = {
'search': 'https://nzbx.co/api/search', 'search': 'https://nzbx.co/api/search',
'details': 'https://nzbx.co/api/details?guid=%s', 'details': 'https://nzbx.co/api/details?guid=%s',
@@ -27,27 +22,25 @@ class Nzbx(NZBProvider, RSS):
'categories': 'https://nzbx.co/api/categories', 'categories': 'https://nzbx.co/api/categories',
'groups': 'https://nzbx.co/api/groups', 'groups': 'https://nzbx.co/api/groups',
} }
http_time_between_calls = 1 # Seconds http_time_between_calls = 1 # Seconds
def search(self, movie, quality): def search(self, movie, quality):
results = [] results = []
if self.isDisabled(): if self.isDisabled():
return results return results
q = '"%s %s" %s' % (simplifyString(getTitle(movie['library'])), movie['library']['year'], quality.get('identifier'))
arguments = tryUrlencode({ arguments = tryUrlencode({
'q': q, 'q': movie['library']['identifier'].replace('tt', ''),
'l': 250, # Limit on number of files returned 'sf': quality.get('size_min'),
#'i': '', # index of file
#'sf': '' # size filter
}) })
url = "%s?%s" % (self.urls['search'], arguments) url = "%s?%s" % (self.urls['search'], arguments)
cache_key = 'nzbx.%s.%s' % (movie['library']['identifier'], quality.get('identifier')) cache_key = 'nzbx.%s.%s' % (movie['library']['identifier'], quality.get('identifier'))
data = self.getCache(cache_key, url) data = self.getCache(cache_key, url)
if data: if data:
try: try:
try: try:
@@ -59,14 +52,13 @@ class Nzbx(NZBProvider, RSS):
for nzb in nzbs: for nzb in nzbs:
nzbx_guid = nzb['guid'] nzbx_guid = nzb['guid']
def extra_score(item): def extra_score(item):
score = 0 score = 0
if item['votes']['upvotes'] > item['votes']['downvotes']: if item['votes']['upvotes'] > item['votes']['downvotes']:
score += 5 score += 5
return score return score
new = { new = {
'guid': nzbx_guid, 'guid': nzbx_guid,
'type': 'nzb', 'type': 'nzb',
@@ -97,5 +89,3 @@ class Nzbx(NZBProvider, RSS):
return results return results
def isEnabled(self):
return NZBProvider.isEnabled(self) and self.conf('enabled')