2015-07-06 11:14:37 +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/>.
|
|
|
|
|
2015-07-13 09:39:20 +00:00
|
|
|
import re
|
2015-07-06 11:14:37 +00:00
|
|
|
import time
|
|
|
|
|
|
|
|
from . import generic
|
Change validate and improve specific Torrent provider connections, IPT, KAT, SCC, TPB, TB, TD, TT.
Change refactor cache for torrent providers to reduce code.
Change improve search category selection BMTV, FSH, FF, TB.
Change identify more SD release qualities.
Change update SpeedCD, MoreThan, TVChaosuk.
Add torrent provider HD4Free.
Remove torrent provider BitSoup.
Change only create threads for providers needing a recent search instead of for all enabled.
Add 4489 as experimental value to "Recent search frequency" to use provider freqs instead of fixed width for all.
Fix searching nzb season packs.
Change remove some logging cruft.
2016-03-24 18:24:14 +00:00
|
|
|
from sickbeard import logger
|
2015-07-06 11:14:37 +00:00
|
|
|
from sickbeard.exceptions import AuthException
|
|
|
|
from lib.unidecode import unidecode
|
|
|
|
|
|
|
|
|
|
|
|
class BeyondHDProvider(generic.TorrentProvider):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
generic.TorrentProvider.__init__(self, 'BeyondHD')
|
|
|
|
|
2016-07-25 02:12:23 +00:00
|
|
|
self.url_base = 'https://beyond-hd.me/'
|
2015-07-06 11:14:37 +00:00
|
|
|
self.urls = {'config_provider_home_uri': self.url_base,
|
2015-09-18 00:06:34 +00:00
|
|
|
'browse': self.url_base + 'api_tv.php?passkey=%s&cats=%s',
|
|
|
|
'search': '&search=%s'}
|
2015-07-06 11:14:37 +00:00
|
|
|
|
2016-09-30 22:20:28 +00:00
|
|
|
self.categories = {'Season': '89', 'Episode': '40,44,48,46,45'}
|
|
|
|
self.categories['Cache'] = '%s,%s' % (self.categories['Episode'], self.categories['Season'])
|
2015-07-06 11:14:37 +00:00
|
|
|
|
|
|
|
self.url = self.urls['config_provider_home_uri']
|
|
|
|
|
2017-12-04 15:11:18 +00:00
|
|
|
self.passkey, self.scene, self.minseed, self.minleech = 4 * [None]
|
2015-07-06 11:14:37 +00:00
|
|
|
|
|
|
|
def _check_auth_from_data(self, data_json):
|
|
|
|
|
|
|
|
if 'error' not in data_json:
|
|
|
|
return True
|
|
|
|
|
|
|
|
logger.log(u'Incorrect authentication credentials for %s : %s' % (self.name, data_json['error']), logger.DEBUG)
|
|
|
|
raise AuthException('Authentication credentials for %s are incorrect, check your config' % self.name)
|
|
|
|
|
2015-09-18 00:06:34 +00:00
|
|
|
def _search_provider(self, search_params, **kwargs):
|
2015-07-06 11:14:37 +00:00
|
|
|
|
|
|
|
results = []
|
2015-07-13 09:39:20 +00:00
|
|
|
if not self._check_auth():
|
2015-07-06 11:14:37 +00:00
|
|
|
return results
|
|
|
|
|
2015-09-18 00:06:34 +00:00
|
|
|
items = {'Cache': [], 'Season': [], 'Episode': [], 'Propers': []}
|
|
|
|
|
2015-07-06 11:14:37 +00:00
|
|
|
for mode in search_params.keys():
|
2015-09-18 00:06:34 +00:00
|
|
|
if mode in ['Season', 'Episode']:
|
2015-07-06 11:14:37 +00:00
|
|
|
show_type = self.show.air_by_date and 'Air By Date' \
|
2015-08-14 23:02:05 +00:00
|
|
|
or self.show.is_sports and 'Sports' or self.show.is_anime and 'Anime' or None
|
2015-07-06 11:14:37 +00:00
|
|
|
if show_type:
|
|
|
|
logger.log(u'Provider does not carry shows of type: [%s], skipping' % show_type, logger.DEBUG)
|
|
|
|
return results
|
|
|
|
|
2015-09-18 00:06:34 +00:00
|
|
|
mode_cats = (mode, 'Cache')['Propers' == mode]
|
2015-07-06 11:14:37 +00:00
|
|
|
for search_string in search_params[mode]:
|
2015-09-18 00:06:34 +00:00
|
|
|
search_string = isinstance(search_string, unicode) and unidecode(search_string) or search_string
|
|
|
|
search_url = self.urls['browse'] % (self.passkey, self.categories[mode_cats])
|
2015-07-06 11:14:37 +00:00
|
|
|
if 'Cache' != mode:
|
2016-08-26 23:36:01 +00:00
|
|
|
search_url += self.urls['search'] % re.sub('[.\s]+', ' ', search_string)
|
2015-07-06 11:14:37 +00:00
|
|
|
|
2015-07-13 09:39:20 +00:00
|
|
|
data_json = self.get_url(search_url, json=True)
|
2018-01-15 17:54:36 +00:00
|
|
|
if self.should_skip():
|
|
|
|
return results
|
2015-07-06 11:14:37 +00:00
|
|
|
|
2015-09-18 00:06:34 +00:00
|
|
|
cnt = len(items[mode])
|
2015-07-06 11:14:37 +00:00
|
|
|
if data_json and 'results' in data_json and self._check_auth_from_data(data_json):
|
|
|
|
for item in data_json['results']:
|
|
|
|
|
2015-09-18 00:06:34 +00:00
|
|
|
seeders, leechers = item.get('seeders', 0), item.get('leechers', 0)
|
|
|
|
if self._peers_fail(mode, seeders, leechers):
|
2015-07-06 11:14:37 +00:00
|
|
|
continue
|
2016-08-26 23:36:01 +00:00
|
|
|
title, download_url = item.get('file'), self._link(item.get('get'))
|
2015-07-06 11:14:37 +00:00
|
|
|
if title and download_url:
|
2015-09-18 00:06:34 +00:00
|
|
|
items[mode].append((title, download_url, seeders, self._bytesizer(item.get('size'))))
|
2015-07-06 11:14:37 +00:00
|
|
|
|
|
|
|
time.sleep(1.1)
|
2015-09-18 00:06:34 +00:00
|
|
|
self._log_search(mode, len(items[mode]) - cnt, search_url)
|
2015-07-06 11:14:37 +00:00
|
|
|
|
2016-08-26 23:36:01 +00:00
|
|
|
results = self._sort_seeding(mode, results + items[mode])
|
2015-07-06 11:14:37 +00:00
|
|
|
|
2015-09-18 00:06:34 +00:00
|
|
|
return results
|
|
|
|
|
2015-07-06 11:14:37 +00:00
|
|
|
|
|
|
|
provider = BeyondHDProvider()
|