mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-01 00:43:37 +00:00
Pep8 and tweaks to newznab logging.
This commit is contained in:
parent
48032005fd
commit
9d8f397d41
6 changed files with 35 additions and 35 deletions
|
@ -210,6 +210,8 @@
|
|||
* Change make sure avi files are closed if an error occurs
|
||||
* Change refactor hachoir scan_index for non RIFF file processing
|
||||
* Change ensure sbdatetime functions return formatted string instead of tuple
|
||||
* Change image cache processing for browse Trakt page
|
||||
* Change logging for newznab response code 910 and add check for empty response data
|
||||
|
||||
|
||||
### 0.11.16 (2016-10-16 17:30:00 UTC)
|
||||
|
|
|
@ -193,7 +193,7 @@ class ProcessTVShow(object):
|
|||
self._log_helper(u'Unable to figure out what folder to process. ' +
|
||||
u'If your downloader and SickGear aren\'t on the same PC then make sure ' +
|
||||
u'you fill out your completed TV download folder in the PP config.')
|
||||
return self.result
|
||||
return self.result
|
||||
|
||||
path, dirs, files = self._get_path_dir_files(dir_name, nzb_name, pp_type)
|
||||
|
||||
|
|
|
@ -904,7 +904,7 @@ class TorrentProvider(object, GenericProvider):
|
|||
self.urls[k] = v % {'home': cur_url, 'vars': getattr(self, 'url_vars', {}).get(k, '')}
|
||||
|
||||
if last_url != cur_url or (expire and not (expire > int(time.time()))):
|
||||
sickbeard.PROVIDER_HOMES[self.get_id()] = (cur_url, int(time.time()) + (15*60))
|
||||
sickbeard.PROVIDER_HOMES[self.get_id()] = (cur_url, int(time.time()) + (60*60))
|
||||
sickbeard.save_config()
|
||||
return cur_url
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class IPTorrentsProvider(generic.TorrentProvider):
|
|||
generic.TorrentProvider.__init__(self, 'IPTorrents')
|
||||
|
||||
self.url_home = (['https://iptorrents.%s/' % u for u in 'eu', 'com', 'me', 'ru'] +
|
||||
['http://11111.workisboring.com/'])
|
||||
['http://11111.workisboring.com/', 'https://ipt-update.com'])
|
||||
|
||||
self.url_vars = {'login': 'getrss.php', 'search': 't?%s;q=%s;qf=ti%s%s#torrents', 'get': '%s'}
|
||||
self.url_tmpl = {'config_provider_home_uri': '%(home)s', 'login': '%(home)s%(vars)s',
|
||||
|
|
|
@ -145,10 +145,10 @@ class NewznabProvider(generic.NZBProvider):
|
|||
if not self._last_recent_search:
|
||||
try:
|
||||
my_db = db.DBConnection('cache.db')
|
||||
res = my_db.select('SELECT "datetime" FROM "lastrecentsearch" WHERE "name"=?', [self.get_id()])
|
||||
res = my_db.select('SELECT' + ' "datetime" FROM "lastrecentsearch" WHERE "name"=?', [self.get_id()])
|
||||
if res:
|
||||
self._last_recent_search = datetime.datetime.fromtimestamp(int(res[0]['datetime']))
|
||||
except:
|
||||
except (StandardError, Exception):
|
||||
pass
|
||||
return self._last_recent_search
|
||||
|
||||
|
@ -157,8 +157,8 @@ class NewznabProvider(generic.NZBProvider):
|
|||
try:
|
||||
my_db = db.DBConnection('cache.db')
|
||||
my_db.action('INSERT OR REPLACE INTO "lastrecentsearch" (name, datetime) VALUES (?,?)',
|
||||
[self.get_id(), sbdatetime.totimestamp(value, default=0)])
|
||||
except:
|
||||
[self.get_id(), sbdatetime.totimestamp(value, default=0)])
|
||||
except (StandardError, Exception):
|
||||
pass
|
||||
self._last_recent_search = value
|
||||
|
||||
|
@ -212,7 +212,7 @@ class NewznabProvider(generic.NZBProvider):
|
|||
for s, v in NewznabConstants.catSearchStrings.iteritems():
|
||||
if None is not re.search(s, cat_name, re.IGNORECASE):
|
||||
cats.setdefault(v, []).append(cat_id)
|
||||
except:
|
||||
except (StandardError, Exception):
|
||||
continue
|
||||
elif category.get('name', '').upper() in ['XXX', 'OTHER', 'MISC']:
|
||||
for subcat in category.findall('subcat'):
|
||||
|
@ -220,9 +220,9 @@ class NewznabProvider(generic.NZBProvider):
|
|||
if None is not re.search(r'^Anime$', subcat.attrib['name'], re.IGNORECASE):
|
||||
cats.setdefault(NewznabConstants.CAT_ANIME, []).append(subcat.attrib['id'])
|
||||
break
|
||||
except:
|
||||
except (StandardError, Exception):
|
||||
continue
|
||||
except:
|
||||
except (StandardError, Exception):
|
||||
logger.log('Error parsing result for [%s]' % self.name, logger.DEBUG)
|
||||
|
||||
if not caps and self._caps and not all_cats and self._caps_all_cats and not cats and self._caps_cats:
|
||||
|
@ -280,9 +280,10 @@ class NewznabProvider(generic.NZBProvider):
|
|||
elif '102' == code:
|
||||
raise AuthException('Your account isn\'t allowed to use the API on %s, contact the admin.' % self.name)
|
||||
elif '910' == code:
|
||||
logger.log('%s %s, please check with provider.' %
|
||||
(self.name, ('currently has their API disabled', description)[description not in (None, '')]),
|
||||
logger.WARNING)
|
||||
logger.log(
|
||||
'%s %s, please check with provider.' %
|
||||
(self.name, ('currently has their API disabled', description)[description not in (None, '')]),
|
||||
logger.WARNING)
|
||||
else:
|
||||
logger.log('Unknown error given from %s: %s' % (self.name, data.get('description', '')),
|
||||
logger.ERROR)
|
||||
|
@ -412,7 +413,7 @@ class NewznabProvider(generic.NZBProvider):
|
|||
try:
|
||||
title = item.findtext('title')
|
||||
url = item.findtext('link')
|
||||
except Exception:
|
||||
except (StandardError, Exception):
|
||||
pass
|
||||
|
||||
title = title and re.sub(r'\s+', '.', '%s' % title)
|
||||
|
@ -544,11 +545,11 @@ class NewznabProvider(generic.NZBProvider):
|
|||
p = parser.parse(p, fuzzy=True)
|
||||
try:
|
||||
p = p.astimezone(sb_timezone)
|
||||
except:
|
||||
except (StandardError, Exception):
|
||||
pass
|
||||
if isinstance(p, datetime.datetime):
|
||||
parsed_date = p.replace(tzinfo=None)
|
||||
except:
|
||||
except (StandardError, Exception):
|
||||
pass
|
||||
|
||||
return parsed_date
|
||||
|
@ -569,7 +570,7 @@ class NewznabProvider(generic.NZBProvider):
|
|||
base_params['apikey'] = api_key
|
||||
|
||||
results, n_spaces = [], {}
|
||||
total, cnt, search_url, exit_log = 0, len(results), '', False
|
||||
total, cnt, search_url, exit_log = 0, len(results), '', True
|
||||
|
||||
cat_sport = self.cats.get(NewznabConstants.CAT_SPORT, ['5060'])
|
||||
cat_anime = self.cats.get(NewznabConstants.CAT_ANIME, ['5070'])
|
||||
|
@ -584,9 +585,9 @@ class NewznabProvider(generic.NZBProvider):
|
|||
cat = []
|
||||
if 'Episode' == mode or 'Season' == mode:
|
||||
if not (any(x in params for x in [v for c, v in self.caps.iteritems()
|
||||
if c not in [NewznabConstants.SEARCH_EPISODE, NewznabConstants.SEARCH_SEASON]]) or
|
||||
not self.supports_tvdbid()):
|
||||
logger.log('Error no id or search term available for search.')
|
||||
if c not in [NewznabConstants.SEARCH_EPISODE, NewznabConstants.SEARCH_SEASON]])
|
||||
or not self.supports_tvdbid()):
|
||||
logger.log('Show is missing either an id or search term for search')
|
||||
continue
|
||||
|
||||
if need_anime:
|
||||
|
@ -637,7 +638,7 @@ class NewznabProvider(generic.NZBProvider):
|
|||
try:
|
||||
parsed_xml, n_spaces = self.cache.parse_and_get_ns(data)
|
||||
items = parsed_xml.findall('channel/item')
|
||||
except Exception:
|
||||
except (StandardError, Exception):
|
||||
logger.log('Error trying to load %s RSS feed' % self.name, logger.ERROR)
|
||||
break
|
||||
|
||||
|
@ -682,7 +683,6 @@ class NewznabProvider(generic.NZBProvider):
|
|||
last_date = self._parse_pub_date(items[-1])
|
||||
if not first_date or not last_date or not self._last_recent_search or \
|
||||
last_date <= self.last_recent_search:
|
||||
exit_log = True
|
||||
break
|
||||
|
||||
if offset != request_params['offset']:
|
||||
|
@ -691,9 +691,6 @@ class NewznabProvider(generic.NZBProvider):
|
|||
|
||||
request_params['offset'] += request_params['limit']
|
||||
if total <= request_params['offset']:
|
||||
exit_log = True
|
||||
logger.log('%s item%s found for episode matching' % (total, helpers.maybe_plural(total)),
|
||||
logger.DEBUG)
|
||||
break
|
||||
|
||||
# there are more items available than the amount given in one call, grab some more
|
||||
|
@ -702,17 +699,18 @@ class NewznabProvider(generic.NZBProvider):
|
|||
% (items, helpers.maybe_plural(items), request_params['limit']), logger.DEBUG)
|
||||
|
||||
batch_count = self._log_result(results, mode, cnt, search_url)
|
||||
exit_log = False
|
||||
|
||||
if 'Cache' == mode and first_date:
|
||||
self.last_recent_search = first_date
|
||||
|
||||
if exit_log:
|
||||
self._log_result(results, mode, cnt, search_url)
|
||||
exit_log = False
|
||||
self._log_search(mode, total, search_url)
|
||||
|
||||
if not try_all_searches and any(x in request_params for x in [v for c, v in self.caps.iteritems()
|
||||
if c not in [NewznabConstants.SEARCH_EPISODE, NewznabConstants.SEARCH_SEASON,
|
||||
NewznabConstants.SEARCH_TEXT]]) and len(results):
|
||||
if not try_all_searches and any(x in request_params for x in [
|
||||
v for c, v in self.caps.iteritems()
|
||||
if c not in [NewznabConstants.SEARCH_EPISODE, NewznabConstants.SEARCH_SEASON,
|
||||
NewznabConstants.SEARCH_TEXT]]) and len(results):
|
||||
break
|
||||
|
||||
return results, n_spaces
|
||||
|
@ -814,7 +812,7 @@ class NewznabCache(tvcache.TVCache):
|
|||
self._checkAuth()
|
||||
(items, n_spaces) = self.provider.cache_data(need_anime=need_anime, need_sports=need_sports,
|
||||
need_sd=need_sd, need_hd=need_hd, need_uhd=need_uhd)
|
||||
except Exception as e:
|
||||
except (StandardError, Exception):
|
||||
items = None
|
||||
|
||||
if items:
|
||||
|
|
|
@ -36,12 +36,12 @@ class OmgwtfnzbsProvider(generic.NZBProvider):
|
|||
def __init__(self):
|
||||
generic.NZBProvider.__init__(self, 'omgwtfnzbs')
|
||||
|
||||
self.url = 'https://omgwtfnzbs.org/'
|
||||
self.url = 'https://omgwtfnzbs.me/'
|
||||
|
||||
self.url_base = 'https://omgwtfnzbs.org/'
|
||||
self.url_api = 'https://api.omgwtfnzbs.org/'
|
||||
self.url_base = 'https://omgwtfnzbs.me/'
|
||||
self.url_api = 'https://api.omgwtfnzbs.me/'
|
||||
self.urls = {'config_provider_home_uri': self.url_base,
|
||||
'cache': 'https://rss.omgwtfnzbs.org/rss-download.php?%s',
|
||||
'cache': 'https://rss.omgwtfnzbs.me/rss-download.php?%s',
|
||||
'search': self.url_api + 'json/?%s',
|
||||
'get': self.url_base + '%s',
|
||||
'cache_html': self.url_base + 'browse.php?cat=tv%s',
|
||||
|
|
Loading…
Reference in a new issue