mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-05 02:43:37 +00:00
0ead7771de
Add the improved error handling to torrent providers. Change cache_db to always include db upgrade statements when running SG for the first time. Change split newznab limit logic into a reusable function, hit_limit_update() and use in BTN prov. Change tweak CSS to make things a little neater with button spacings. Add the actual time when current limit will expire to the UI. Change instead of terminology "errors", use "failures". Change improve BTN error handling. Change ensure provider name is output to log at times where it wasn't. Change ensure failed request URLs and POST params are output to log. Add time of last failure + type to should_skip log message. Change code DRY and simplification for improved readability. Change occurrences of "error" to "fail" for consistency. Add tmr limit handling to omg and change log_failure_url level to warning. Change log the failed URL when an API hit limit is reached. Change "hit" to the more universally generic "tmr" - Too Many Requests. Change Db columns containing "hit_" are renamed "tmr_"
72 lines
2.5 KiB
Python
72 lines
2.5 KiB
Python
# coding=utf-8
|
|
#
|
|
# This file is part of SickGear.
|
|
#
|
|
# SickGear is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# SickGear is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
from . import generic
|
|
from lib.unidecode import unidecode
|
|
|
|
|
|
class PreToMeProvider(generic.TorrentProvider):
|
|
|
|
def __init__(self):
|
|
generic.TorrentProvider.__init__(self, 'PreToMe', cache_update_freq=6)
|
|
|
|
self.url_base = 'https://pretome.info/'
|
|
|
|
self.urls = {'config_provider_home_uri': self.url_base,
|
|
'browse': self.url_base + 'rss.php?cat[]=7&sort=0&type=d&key=%s',
|
|
'search': '&st=1&tf=all&search=%s'}
|
|
|
|
self.url = self.urls['config_provider_home_uri']
|
|
|
|
self.passkey = None
|
|
|
|
def _authorised(self, **kwargs):
|
|
|
|
return self._check_auth()
|
|
|
|
def _search_provider(self, search_params, **kwargs):
|
|
|
|
self._authorised()
|
|
results = []
|
|
|
|
items = {'Cache': [], 'Season': [], 'Episode': [], 'Propers': []}
|
|
|
|
url = self.urls['browse'] % self.passkey
|
|
for mode in search_params.keys():
|
|
for search_string in search_params[mode]:
|
|
search_string = isinstance(search_string, unicode) and unidecode(search_string) or search_string
|
|
search_url = url + (self.urls['search'] % search_string, '')['Cache' == mode]
|
|
|
|
xml_data = self.cache.get_rss(search_url)
|
|
|
|
cnt = len(items[mode])
|
|
if xml_data and 'entries' in xml_data:
|
|
for entry in xml_data['entries']:
|
|
try:
|
|
if entry['title'] and 'download' in entry['link']:
|
|
items[mode].append((entry['title'], entry['link'], None, None))
|
|
except KeyError:
|
|
continue
|
|
|
|
self._log_search(mode, len(items[mode]) - cnt, search_url)
|
|
|
|
results = list(set(results + items[mode]))
|
|
|
|
return results
|
|
|
|
|
|
provider = PreToMeProvider()
|