Merge branch 'master' into develop

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

View file

@ -4,7 +4,12 @@
[develop changelog] [develop changelog]
### 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 replace imdb lib with imdb-pie 5.6.3 (df7411d1)
* Change handle if BTS returns no data * Change handle if BTS returns no data

View file

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

View file

@ -45,7 +45,7 @@ class SkytorrentsProvider(generic.TorrentProvider):
items = {'Cache': [], 'Season': [], 'Episode': [], 'Propers': []} items = {'Cache': [], 'Season': [], 'Episode': [], 'Propers': []}
rc = dict((k, re.compile('(?i)' + v)) for (k, v) in { 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 mode in search_params.keys():
for search_string in search_params[mode]: for search_string in search_params[mode]:
@ -83,8 +83,11 @@ class SkytorrentsProvider(generic.TorrentProvider):
if self._peers_fail(mode, seeders, leechers): if self._peers_fail(mode, seeders, leechers):
continue continue
info = tr.find('a', href=rc['info']) info = tr.select(
title = (info.attrs.get('title') or info.get_text()).strip() '[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']) download_url = self._link(tr.find('a', href=rc['get'])['href'])
except (AttributeError, TypeError, ValueError, KeyError): except (AttributeError, TypeError, ValueError, KeyError):
continue continue

View file

@ -96,10 +96,11 @@ class SpeedCDProvider(generic.TorrentProvider):
items = {'Cache': [], 'Season': [], 'Episode': [], 'Propers': []} 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(): 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]: for search_string in search_params[mode]:
post_data = dict((x.split('=') for x in self._categories_string(mode).split('&')), post_data = dict((x.split('=') for x in self._categories_string(mode).split('&')),
search=search_string.replace('.', ' ').replace('^@^', '.'), search=search_string.replace('.', ' ').replace('^@^', '.'),
@ -116,7 +117,7 @@ class SpeedCDProvider(generic.TorrentProvider):
raise generic.HaltParseException raise generic.HaltParseException
with BS4Parser(html, features=['html5lib', 'permissive']) as soup: 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') torrent_rows = [] if not torrent_table else torrent_table.find_all('tr')
if 2 > len(torrent_rows): if 2 > len(torrent_rows):
@ -136,7 +137,7 @@ class SpeedCDProvider(generic.TorrentProvider):
or self._peers_fail(mode, seeders, leechers): or self._peers_fail(mode, seeders, leechers):
continue 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() title = (info.attrs.get('title') or info.get_text()).strip()
download_url = self._link(tr.find('a', href=rc['get'])['href']) download_url = self._link(tr.find('a', href=rc['get'])['href'])
except (AttributeError, TypeError, ValueError): except (AttributeError, TypeError, ValueError):