Browse Source

Merge branch 'hotfix/0.24.4'

tags/release_0.24.4^0 release_0.24.4
JackDandy 4 years ago
parent
commit
7f8040a846
  1. 8
      CHANGES.md
  2. BIN
      gui/slick/images/providers/speedapp.png
  3. 2
      gui/slick/interfaces/default/config_providers.tmpl
  4. 20
      sickbeard/piper.py
  5. 2
      sickbeard/providers/__init__.py
  6. 4
      sickbeard/providers/generic.py
  7. 118
      sickbeard/providers/speedapp.py

8
CHANGES.md

@ -1,4 +1,10 @@
### 0.24.3 (2021-06-17 23:00:00 UTC)
### 0.24.4 (2021-06-25 03:00:00 UTC)
* Fix issue on certain py2 setups that created mishandling of 404's
* Add SpeedApp torrent provider
### 0.24.3 (2021-06-17 23:00:00 UTC)
* Fix view-show poster click zoom area is only accessible from top of poster image
* Move view-show paused "II" indicator as it wasn't in a good spot anyway

BIN
gui/slick/images/providers/speedapp.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 B

2
gui/slick/interfaces/default/config_providers.tmpl

@ -745,7 +745,9 @@ name = '' if not client else get_client_instance(sickbeard.TORRENT_METHOD)().nam
<span>$cur_fname</span>
</label>
#end for
#if $cur_torrent_provider.may_filter
<span>(see $cur_torrent_provider.name)</span>
#end if
</div>
#end if
#if $hasattr($cur_torrent_provider, 'reject_m2ts'):

20
sickbeard/piper.py

@ -34,18 +34,17 @@ def is_pip_ok():
"""
pip_ok = '/' != ek.ek(os.path.expanduser, '~')
if pip_ok:
try:
# noinspection PyPackageRequirements,PyProtectedMember
import pip
except ImportError:
try:
import ensurepip
ensurepip.bootstrap()
except (BaseException, Exception):
pip_ok = False
pip_version, _, _ = _get_pip_version()
if not pip_version:
pip_ok = False
cmdline_runner([sys.executable, '-c', '"import ensurepip;ensurepip.bootstrap()"'], suppress_stderr=True)
return pip_ok
def _get_pip_version():
return cmdline_runner([sys.executable, '-c', '"from pip import __version__ as v; print(v)"'], suppress_stderr=True)
def run_pip(pip_cmd, suppress_stderr=False):
# type: (List[AnyStr], bool) -> Tuple[AnyStr, Optional[AnyStr], int]
"""Run pip command
@ -61,8 +60,7 @@ def run_pip(pip_cmd, suppress_stderr=False):
new_pip_arg = ['--no-python-version-warning']
if PY2:
# noinspection PyCompatibility, PyPackageRequirements
from pip import __version__ as pip_version
pip_version, _, _ = _get_pip_version()
if pip_version and 20 > int(pip_version.split('.')[0]):
new_pip_arg = []

2
sickbeard/providers/__init__.py

@ -42,7 +42,7 @@ __all__ = [
'hdbits', 'hdme', 'hdspace', 'hdtorrents',
'immortalseed', 'iptorrents', 'limetorrents', 'magnetdl', 'milkie', 'morethan', 'nebulance', 'ncore', 'nyaa',
'pretome', 'privatehd', 'ptf',
'rarbg', 'revtt', 'scenehd', 'scenetime', 'shazbat', 'showrss', 'skytorrents', 'snowfl', 'speedcd',
'rarbg', 'revtt', 'scenehd', 'scenetime', 'shazbat', 'showrss', 'skytorrents', 'snowfl', 'speedapp', 'speedcd',
'thepiratebay', 'torlock', 'torrentday', 'torrenting', 'torrentleech', 'tvchaosuk',
'xspeeds', 'zooqle',
# anime

4
sickbeard/providers/generic.py

@ -54,7 +54,7 @@ import requests
import requests.cookies
from _23 import decode_bytes, filter_list, filter_iter, make_btih, map_list, quote, quote_plus, urlparse
from six import iteritems, iterkeys, itervalues, PY2
from six import iteritems, iterkeys, itervalues, PY2, string_types
from sg_helpers import try_int
# noinspection PyUnreachableCode
@ -1927,7 +1927,7 @@ class TorrentProvider(GenericProvider):
def _authorised(self, logged_in=None, post_params=None, failed_msg=None, url=None, timeout=30, **kwargs):
maxed_out = (lambda y: re.search(
maxed_out = (lambda y: isinstance(y, string_types) and re.search(
r'(?i)([1-3]((<[^>]+>)|\W)*(attempts|tries|remain)[\W\w]{,40}?(remain|left|attempt)|last[^<]+?attempt)', y))
logged_in, failed_msg = [None is not a and a or b for (a, b) in (
(logged_in, (lambda y=None: self.has_all_cookies())),

118
sickbeard/providers/speedapp.py

@ -0,0 +1,118 @@
# coding=utf-8
#
# Author: SickGear
#
# 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 ..helpers import try_int
from six import string_types
from _23 import filter_list, map_list, unidecode
class SpeedAppProvider(generic.TorrentProvider):
def __init__(self):
generic.TorrentProvider.__init__(self, 'SpeedApp')
self.url_base = 'https://speedapp.io/'
self.api = self.url_base + 'api/'
self.urls = dict(
config_provider_home_uri=self.url_base,
login=self.api + 'test',
search=self.api + 'torrent?itemsPerPage=50&search=%s&%s', cats=self.api + 'category',
get=self.api + 'torrent/%s/download'
)
self.perms_needed = self.perms = ('torrent.read', 'torrent.download', 'snatch.read')
self.api_key, self._authd, self.minseed, self.minleech, self.cats = 5 * [None]
def _authorised(self, **kwargs):
return super(SpeedAppProvider, self)._authorised(
logged_in=self.logged_in, parse_json=True, headers=self.auth_header(),
failed_msg=(lambda y=None: u'Invalid token or permissions for %s. Check settings'))
def logged_in(self, resp=None):
self._authd = None
self.perms_needed = self.perms
if isinstance(resp, dict) and isinstance(resp.get('scopes'), list):
self._authd = True
self.perms_needed = filter_list(lambda x: True is not x, [p in resp.get('scopes') or p for p in self.perms])
if not self.perms_needed:
self.categories = None
resp = self.get_url(self.urls['cats'], skip_auth=True, parse_json=True, headers=self.auth_header())
if isinstance(resp, list):
categories = [category['id'] for category in filter_list(
lambda c: isinstance(c.get('id'), int) and isinstance(c.get('name'), string_types)
and c.get('name').upper() in ('TV PACKS', 'TV HD', 'TV SD'), resp)]
self.categories = {'Cache': categories, 'Episode': categories, 'Season': categories}
return not any(self.perms_needed)
def auth_header(self):
return {'X-Client-Id': '328b70a3f869e26de994', 'Authorization': 'Bearer %s' % self.api_key}
def _search_provider(self, search_params, **kwargs):
results = []
if not self._authorised() or not self.categories:
return results
items = {'Cache': [], 'Season': [], 'Episode': [], 'Propers': []}
for mode in search_params:
for search_string in search_params[mode]:
search_url = self.urls['search'] % (
unidecode(search_string), self._categories_string(mode, template='categories[]=%s'))
data_json = self.get_url(search_url, skip_auth=True, parse_json=True, headers=self.auth_header())
if self.should_skip():
return results
cnt = len(items[mode])
if isinstance(data_json, list):
for tr in data_json or []:
seeders, leechers, size, title, tid = (try_int(n, n) for n in [
tr.get(x) for x in ('seeders', 'leechers', 'size', 'name', 'id')])
if not self._reject_item(seeders, leechers) and title and tid:
items[mode].append((title, self._link(tid), seeders, self._bytesizer(size)))
self._log_search(mode, len(items[mode]) - cnt, search_url)
results = self._sort_seeding(mode, results + items[mode])
return results
def ui_string(self, key):
return ('%s_api_key' % self.get_id()) == key and 'API Token' or \
('%s_api_key_tip' % self.get_id()) == key and \
((not self._authd and not self._authorised() or self.perms_needed)
and ('create token at <a href="%sprofile/api-tokens">%s site</a><br>'
'with perms %s' % (self.url_base, self.name, map_list(
lambda p: 't.read' in p and 'Read torrents'
or 't.down' in p and 'Download torrents'
or 'ch.read' in p and 'Read snatches', self.perms_needed)))
.replace('[', '').replace(']', '')
or 'token is valid and required permissions are enabled') \
or ''
provider = SpeedAppProvider()
Loading…
Cancel
Save