diff --git a/couchpotato/core/media/_base/providers/nzb/nzbindex.py b/couchpotato/core/media/_base/providers/nzb/nzbindex.py deleted file mode 100644 index 58f4b23..0000000 --- a/couchpotato/core/media/_base/providers/nzb/nzbindex.py +++ /dev/null @@ -1,126 +0,0 @@ -import re -import time - -from bs4 import BeautifulSoup -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.event import fireEvent -from couchpotato.core.media._base.providers.nzb.base import NZBProvider -from dateutil.parser import parse - - -log = CPLog(__name__) - - -class Base(NZBProvider, RSS): - - urls = { - 'download': 'https://www.nzbindex.com/download/', - 'search': 'https://www.nzbindex.com/rss/?%s', - } - - http_time_between_calls = 1 # Seconds - - def _search(self, media, quality, results): - - nzbs = self.getRSSData(self.urls['search'] % self.buildUrl(media, quality)) - - for nzb in nzbs: - - enclosure = self.getElement(nzb, 'enclosure').attrib - nzbindex_id = int(self.getTextElement(nzb, "link").split('/')[4]) - - title = self.getTextElement(nzb, "title") - - match = fireEvent('matcher.parse', title, parser='usenet', single = True) - if not match.chains: - log.info('Unable to parse release with title "%s"', title) - continue - - # TODO should we consider other lower-weight chains here? - info = fireEvent('matcher.flatten_info', match.chains[0].info, single = True) - - release_name = fireEvent('matcher.construct_from_raw', info.get('release_name'), single = True) - - file_name = info.get('detail', {}).get('file_name') - file_name = file_name[0] if file_name else None - - title = release_name or file_name - - # Strip extension from parsed title (if one exists) - ext_pos = title.rfind('.') - - # Assume extension if smaller than 4 characters - # TODO this should probably be done a better way - if len(title[ext_pos + 1:]) <= 4: - title = title[:ext_pos] - - if not title: - log.info('Unable to find release name from match') - continue - - try: - description = self.getTextElement(nzb, "description") - except: - description = '' - - def extra_check(item): - if '#c20000' in item['description'].lower(): - log.info('Wrong: Seems to be passworded: %s', item['name']) - return False - - return True - - results.append({ - 'id': nzbindex_id, - 'name': title, - 'age': self.calculateAge(int(time.mktime(parse(self.getTextElement(nzb, "pubDate")).timetuple()))), - 'size': tryInt(enclosure['length']) / 1024 / 1024, - 'url': enclosure['url'], - 'detail_url': enclosure['url'].replace('/download/', '/release/'), - 'description': description, - 'get_more_info': self.getMoreInfo, - 'extra_check': extra_check, - }) - - def getMoreInfo(self, item): - try: - if '/nfo/' in item['description'].lower(): - nfo_url = re.search('href=\"(?P.+)\" ', item['description']).group('nfo') - full_description = self.getCache('nzbindex.%s' % item['id'], url = nfo_url, cache_timeout = 25920000) - html = BeautifulSoup(full_description) - item['description'] = toUnicode(html.find('pre', attrs = {'id': 'nfo0'}).text) - except: - pass - - -config = [{ - 'name': 'nzbindex', - 'groups': [ - { - 'tab': 'searcher', - 'list': 'nzb_providers', - 'name': 'nzbindex', - 'description': 'Free provider, less accurate. See NZBIndex', - 'wizard': True, - 'icon': 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAo0lEQVR42t2SQQ2AMBAEcUCwUAv94QMLfHliAQtYqIVawEItYAG6yZFMLkUANNlk79Kbbtp2P1j9uKxVV9VWFeStl+Wh3fWK9hNwEoADZkJtMD49AqS5AUjWGx6A+m+ARICGrM5W+wSTB0gETKzdHZwCEZAJ8PGZQN4AiQAmkR9s06EBAugJiBoAAPFfAQcBgZcIHzwA6TYP4JsXeSg3P9L31w3eksbH3zMb/wAAAABJRU5ErkJggg==', - 'options': [ - { - 'name': 'enabled', - 'type': 'enabler', - 'default': True, - }, - { - 'name': 'extra_score', - 'advanced': True, - 'label': 'Extra Score', - 'type': 'int', - 'default': 0, - 'description': 'Starting score for each release found via this provider.', - } - ], - }, - ], -}] diff --git a/couchpotato/core/media/movie/providers/nzb/nzbindex.py b/couchpotato/core/media/movie/providers/nzb/nzbindex.py deleted file mode 100644 index 70e939d..0000000 --- a/couchpotato/core/media/movie/providers/nzb/nzbindex.py +++ /dev/null @@ -1,30 +0,0 @@ -from couchpotato.core.helpers.encoding import tryUrlencode -from couchpotato.core.logger import CPLog -from couchpotato.core.event import fireEvent -from couchpotato.core.media._base.providers.nzb.nzbindex import Base -from couchpotato.core.media.movie.providers.base import MovieProvider -from couchpotato.environment import Env - -log = CPLog(__name__) - -autoload = 'NzbIndex' - - -class NzbIndex(MovieProvider, Base): - - def buildUrl(self, media, quality): - title = fireEvent('library.query', media, include_year = False, single = True) - year = media['info']['year'] - - query = tryUrlencode({ - 'q': '"%s %s" | "%s (%s)"' % (title, year, title, year), - 'age': Env.setting('retention', 'nzb'), - 'sort': 'agedesc', - 'minsize': quality.get('size_min'), - 'maxsize': quality.get('size_max'), - 'rating': 1, - 'max': 250, - 'more': 1, - 'complete': 1, - }) - return query diff --git a/couchpotato/core/plugins/base.py b/couchpotato/core/plugins/base.py index 73bc935..8a4cada 100644 --- a/couchpotato/core/plugins/base.py +++ b/couchpotato/core/plugins/base.py @@ -231,8 +231,9 @@ class Plugin(object): try: # To many requests - if status_code == 429: - self.http_failed_request[host] = time.time() + if status_code in [429]: + self.http_failed_request[host] = 1 + self.http_failed_disabled[host] = time.time() if not self.http_failed_request.get(host): self.http_failed_request[host] = 1 diff --git a/couchpotato/core/plugins/renamer.py b/couchpotato/core/plugins/renamer.py index fdc4329..9decf08 100755 --- a/couchpotato/core/plugins/renamer.py +++ b/couchpotato/core/plugins/renamer.py @@ -526,7 +526,7 @@ class Renamer(Plugin): # Remove leftover files if not remove_leftovers: # Don't remove anything - break + continue log.debug('Removing leftover files') for current_file in group['files']['leftover']: diff --git a/libs/axl/axel.py b/libs/axl/axel.py index 64d2977..2abf12a 100644 --- a/libs/axl/axel.py +++ b/libs/axl/axel.py @@ -235,12 +235,12 @@ class Event(object): self.error_handler(sys.exc_info()) finally: - if not self.asynchronous: - self.queue.task_done() - if order_lock: order_lock.release() + if not self.asynchronous: + self.queue.task_done() + if self.queue.empty(): raise Empty