Merge branch 'hotfix/0.17.2'

This commit is contained in:
JackDandy 2018-08-30 15:07:39 +01:00
commit 8c85e7a9e3
4 changed files with 38 additions and 16 deletions

View file

@ -1,4 +1,9 @@
### 0.17.1 (2018-08-29 23:40:00 UTC)
### 0.17.2 (2018-08-30 15:06:00 UTC)
* Fix Blutopia, Skytorrents, and SpeedCD torrent providers
### 0.17.1 (2018-08-29 17:37:00 UTC)
* Change replace imdb lib with imdb-pie 5.6.3 (df7411d1)
* Change handle if BTS returns no data

View file

@ -35,7 +35,7 @@ class BlutopiaProvider(generic.TorrentProvider):
self.url_base = 'https://blutopia.xyz/'
self.urls = {'config_provider_home_uri': self.url_base,
'login': self.url_base + 'torrents',
'search': self.url_base + 'filter?%s' % '&'.join(
'search': self.url_base + 'filterTorrents?%s' % '&'.join(
['_token=%s', 'search=%s', 'categories[]=%s', 'freeleech=%s', 'doubleupload=%s', 'featured=%s',
'username=', 'imdb=', 'tvdb=', 'tmdb=', 'sorting=created_at', 'qty=50', 'direction=desc'])}
@ -52,7 +52,9 @@ class BlutopiaProvider(generic.TorrentProvider):
def logged_in(self, resp):
try:
self.token = re.findall('csrf\s*=\s*"([^"]+)', resp)[0]
self.resp = re.findall('(?sim)(<table.*?Result.*?</table>)', resp)[0]
resp = re.findall('(?sim)(<table.*?Result.*?</table>)', resp)
if resp:
self.resp = resp[0]
except (IndexError, TypeError):
return False
return self.has_all_cookies('XSRF-TOKEN')
@ -71,7 +73,7 @@ class BlutopiaProvider(generic.TorrentProvider):
items = {'Cache': [], 'Season': [], 'Episode': [], 'Propers': []}
rc = dict((k, re.compile('(?i)' + v))
for (k, v) in {'info': 'torrents', 'get': '(.*?download)_check(.*)'}.items())
for (k, v) in {'info': 'torrents', 'get': '(.*?download)(?:_check)?(.*)'}.items())
log = ''
if self.filter:
non_marked = 'f0' in self.filter
@ -102,17 +104,26 @@ class BlutopiaProvider(generic.TorrentProvider):
search_url = self.urls['search'] % (
self.token, '+'.join(search_string.split()), self._categories_string(mode, ''), '', '', '')
resp = self.get_url(search_url, json=True)
resp = self.get_url(search_url)
if self.should_skip():
return results
resp_json = None
if None is not self.resp:
try:
from lib import simplejson as json
resp_json = json.loads(resp)
except (StandardError, Exception):
pass
cnt = len(items[mode])
try:
if not resp or not resp.get('rows'):
if not resp or (resp_json and not resp_json.get('rows')):
raise generic.HaltParseException
html = '<html><body>%s</body></html>' % \
self.resp.replace('</tbody>', '%s</tbody>' % ''.join(resp.get('result', [])))
(resp if None is self.resp else
self.resp.replace('</tbody>', '%s</tbody>' % ''.join(resp_json.get('result', []))))
with BS4Parser(html, features=['html5lib', 'permissive']) as soup:
torrent_table = soup.find('table', class_='table')
torrent_rows = [] if not torrent_table else torrent_table.find_all('tr')
@ -141,8 +152,10 @@ class BlutopiaProvider(generic.TorrentProvider):
if self._peers_fail(mode, seeders, leechers):
continue
title = tr.find('a', href=rc['info'])['data-original-title']
download_url = self._link(rc['get'].sub(r'\1\2', tr.find('a', href=rc['get'])['href']))
title = tr.find('a', href=rc['info'])
title = title.get_text().strip() if None is self.resp else title['data-original-title']
download_url = self._link(''.join(rc['get'].findall(
tr.find('a', href=rc['get'])['href'])[0]))
except (AttributeError, TypeError, ValueError, IndexError):
continue

View file

@ -45,7 +45,7 @@ class SkytorrentsProvider(generic.TorrentProvider):
items = {'Cache': [], 'Season': [], 'Episode': [], 'Propers': []}
rc = dict((k, re.compile('(?i)' + v)) for (k, v) in {
'info': '^(info|torrent)/', 'get': '^magnet:'}.items())
'info': '(^(info|torrent)/|/[\w+]{40,}\s*$)', 'get': '^magnet:'}.items())
for mode in search_params.keys():
for search_string in search_params[mode]:
@ -83,8 +83,11 @@ class SkytorrentsProvider(generic.TorrentProvider):
if self._peers_fail(mode, seeders, leechers):
continue
info = tr.find('a', href=rc['info'])
title = (info.attrs.get('title') or info.get_text()).strip()
info = tr.select(
'[alt*="magnet"], [title*="magnet"], [alt*="torrent"], [title*="torrent"]')[0] \
or tr.find('a', href=rc['info'])
title = re.sub('\s(using|use|magnet|link)', '', (
info.attrs.get('title') or info.attrs.get('alt') or info.get_text())).strip()
download_url = self._link(tr.find('a', href=rc['get'])['href'])
except (AttributeError, TypeError, ValueError, KeyError):
continue

View file

@ -96,10 +96,11 @@ class SpeedCDProvider(generic.TorrentProvider):
items = {'Cache': [], 'Season': [], 'Episode': [], 'Propers': []}
rc = dict((k, re.compile('(?i)' + v)) for (k, v) in {'get': 'download', 'fl': '\[freeleech\]'}.items())
rc = dict((k, re.compile('(?i)' + v)) for (k, v) in {
'info': '/t/', 'get': 'download', 'fl': '\[freeleech\]'}.items())
for mode in search_params.keys():
rc['cats'] = re.compile('(?i)cat=(?:%s)' % self._categories_string(mode, template='', delimiter='|'))
rc['cats'] = re.compile('(?i)(cat|c\[\])=(?:%s)' % self._categories_string(mode, template='', delimiter='|'))
for search_string in search_params[mode]:
post_data = dict((x.split('=') for x in self._categories_string(mode).split('&')),
search=search_string.replace('.', ' ').replace('^@^', '.'),
@ -116,7 +117,7 @@ class SpeedCDProvider(generic.TorrentProvider):
raise generic.HaltParseException
with BS4Parser(html, features=['html5lib', 'permissive']) as soup:
torrent_table = soup.find('table', attrs={'cellspacing': 0})
torrent_table = soup.find('table', attrs={'cellspacing': 0}) or soup.find('table')
torrent_rows = [] if not torrent_table else torrent_table.find_all('tr')
if 2 > len(torrent_rows):
@ -136,7 +137,7 @@ class SpeedCDProvider(generic.TorrentProvider):
or self._peers_fail(mode, seeders, leechers):
continue
info = tr.find('a', 'torrent')
info = tr.find('a', 'torrent') or tr.find('a', href=rc['info'])
title = (info.attrs.get('title') or info.get_text()).strip()
download_url = self._link(tr.find('a', href=rc['get'])['href'])
except (AttributeError, TypeError, ValueError):