SickGear/sickbeard/providers/pretome.py

74 lines
2.5 KiB
Python
Raw Normal View History

2015-09-14 15:33:51 +00:00
# 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 sickbeard.rssfeeds import RSSFeeds
from lib.unidecode import unidecode
class PreToMeProvider(generic.TorrentProvider):
def __init__(self):
generic.TorrentProvider.__init__(self, 'PreToMe', cache_update_freq=6)
2015-09-14 15:33:51 +00:00
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',
2015-09-14 15:33:51 +00:00
'search': '&st=1&tf=all&search=%s'}
self.url = self.urls['config_provider_home_uri']
self.passkey = None
def _authorised(self, **kwargs):
2015-09-14 15:33:51 +00:00
return self._check_auth()
def _search_provider(self, search_params, **kwargs):
2015-09-14 15:33:51 +00:00
self._authorised()
2015-09-14 15:33:51 +00:00
results = []
items = {'Cache': [], 'Season': [], 'Episode': [], 'Propers': []}
2015-09-14 15:33:51 +00:00
url = self.urls['browse'] % self.passkey
2015-09-14 15:33:51 +00:00
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]
2015-09-14 15:33:51 +00:00
data = RSSFeeds(self).get_feed(search_url)
cnt = len(items[mode])
if data and 'entries' in data:
for entry in data['entries']:
try:
if entry['title'] and 'download' in entry['link']:
items[mode].append((entry['title'], entry['link'], None, None))
2015-09-14 15:33:51 +00:00
except KeyError:
continue
self._log_search(mode, len(items[mode]) - cnt, search_url)
2015-09-14 15:33:51 +00:00
results = list(set(results + items[mode]))
2015-09-14 15:33:51 +00:00
return results
provider = PreToMeProvider()