2015-07-08 00:02:29 +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/>.
|
|
|
|
|
|
|
|
import re
|
|
|
|
import traceback
|
|
|
|
|
|
|
|
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 common, helpers, logger
|
|
|
|
from sickbeard.bs4_parser import BS4Parser
|
2015-09-18 00:06:34 +00:00
|
|
|
from sickbeard.helpers import tryInt
|
2015-07-08 00:02:29 +00:00
|
|
|
from lib.unidecode import unidecode
|
|
|
|
|
|
|
|
|
2017-05-02 16:08:28 +00:00
|
|
|
class NebulanceProvider(generic.TorrentProvider):
|
2015-07-08 00:02:29 +00:00
|
|
|
|
|
|
|
def __init__(self):
|
2017-05-02 16:08:28 +00:00
|
|
|
generic.TorrentProvider.__init__(self, 'Nebulance', cache_update_freq=17)
|
2015-07-08 00:02:29 +00:00
|
|
|
|
2017-05-02 16:08:28 +00:00
|
|
|
self.url_base = 'https://nebulance.io/'
|
2015-07-08 00:02:29 +00:00
|
|
|
self.urls = {'config_provider_home_uri': self.url_base,
|
2015-09-18 00:06:34 +00:00
|
|
|
'login_action': self.url_base + 'login.php',
|
|
|
|
'user': self.url_base + 'ajax.php?action=index',
|
|
|
|
'browse': self.url_base + 'ajax.php?action=browse&auth=%s&passkey=%s',
|
|
|
|
'search': '&searchstr=%s',
|
|
|
|
'get': self.url_base + 'torrents.php?action=download&authkey=%s&torrent_pass=%s&id=%s'}
|
2015-07-08 00:02:29 +00:00
|
|
|
|
|
|
|
self.url = self.urls['config_provider_home_uri']
|
2015-09-18 00:06:34 +00:00
|
|
|
self.user_authkey, self.user_passkey = 2 * [None]
|
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
|
|
|
self.chk_td = True
|
2015-07-08 00:02:29 +00:00
|
|
|
|
2017-12-04 15:11:18 +00:00
|
|
|
self.username, self.password, self.freeleech, self.scene, self.minseed, self.minleech = 6 * [None]
|
2015-07-08 00:02:29 +00:00
|
|
|
|
2015-09-18 00:06:34 +00:00
|
|
|
def _authorised(self, **kwargs):
|
2015-07-08 00:02:29 +00:00
|
|
|
|
2017-05-02 16:08:28 +00:00
|
|
|
if not super(NebulanceProvider, self)._authorised(
|
2016-08-26 23:36:01 +00:00
|
|
|
logged_in=(lambda y=None: self.has_all_cookies('session')),
|
|
|
|
post_params={'keeplogged': '1', 'form_tmpl': True}):
|
2015-09-18 00:06:34 +00:00
|
|
|
return False
|
|
|
|
if not self.user_authkey:
|
2018-01-15 17:54:36 +00:00
|
|
|
response = self.get_url(self.urls['user'], skip_auth=True, json=True)
|
|
|
|
if self.should_skip():
|
|
|
|
return False
|
2015-09-18 00:06:34 +00:00
|
|
|
if 'response' in response:
|
|
|
|
self.user_authkey, self.user_passkey = [response['response'].get(v) for v in 'authkey', 'passkey']
|
|
|
|
return self.user_authkey
|
2015-07-08 00:02:29 +00:00
|
|
|
|
2015-09-18 00:06:34 +00:00
|
|
|
def _search_provider(self, search_params, **kwargs):
|
2015-07-08 00:02:29 +00:00
|
|
|
|
|
|
|
results = []
|
2015-09-18 00:06:34 +00:00
|
|
|
if not self._authorised():
|
2015-07-08 00:02:29 +00:00
|
|
|
return results
|
|
|
|
|
2015-09-18 00:06:34 +00:00
|
|
|
items = {'Cache': [], 'Season': [], 'Episode': [], 'Propers': []}
|
2015-07-08 00:02:29 +00:00
|
|
|
|
2015-09-18 00:06:34 +00:00
|
|
|
rc = dict((k, re.compile('(?i)' + v)) for (k, v) in {'nodots': '[\.\s]+'}.items())
|
2015-07-08 00:02:29 +00:00
|
|
|
for mode in search_params.keys():
|
|
|
|
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
|
2015-07-08 00:02:29 +00:00
|
|
|
|
2015-09-18 00:06:34 +00:00
|
|
|
search_url = self.urls['browse'] % (self.user_authkey, self.user_passkey)
|
2015-07-08 00:02:29 +00:00
|
|
|
if 'Cache' != mode:
|
2015-09-18 00:06:34 +00:00
|
|
|
search_url += self.urls['search'] % rc['nodots'].sub('+', search_string)
|
2015-07-08 00:02:29 +00:00
|
|
|
|
2015-09-18 00:06:34 +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-08 00:02:29 +00:00
|
|
|
|
|
|
|
cnt = len(items[mode])
|
|
|
|
try:
|
2017-02-17 03:16:51 +00:00
|
|
|
for item in data_json.get('response', {}).get('results', []):
|
2015-09-18 00:06:34 +00:00
|
|
|
if self.freeleech and not item.get('isFreeleech'):
|
|
|
|
continue
|
|
|
|
|
|
|
|
seeders, leechers, group_name, torrent_id, size = [tryInt(n, n) for n in [item.get(x) for x in [
|
|
|
|
'seeders', 'leechers', 'groupName', 'torrentId', 'size']]]
|
|
|
|
if self._peers_fail(mode, seeders, leechers):
|
|
|
|
continue
|
|
|
|
|
|
|
|
try:
|
|
|
|
title_parts = group_name.split('[')
|
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
|
|
|
maybe_res = re.findall('((?:72|108|216)0\w)', title_parts[1])
|
|
|
|
maybe_ext = re.findall('(?i)(%s)' % '|'.join(common.mediaExtensions), title_parts[1])
|
2015-09-18 00:06:34 +00:00
|
|
|
detail = title_parts[1].split('/')
|
|
|
|
detail[1] = detail[1].strip().lower().replace('mkv', 'x264')
|
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
|
|
|
title = '%s.%s' % (BS4Parser(title_parts[0].strip(), 'html.parser').soup.string, '.'.join(
|
|
|
|
(maybe_res and [maybe_res[0]] or []) +
|
|
|
|
[detail[0].strip(), detail[1], maybe_ext and maybe_ext[0].lower() or 'mkv']))
|
2015-09-18 00:06:34 +00:00
|
|
|
except (IndexError, KeyError):
|
2017-02-17 03:16:51 +00:00
|
|
|
title = self.regulate_title(item, group_name)
|
2015-09-18 00:06:34 +00:00
|
|
|
download_url = self.urls['get'] % (self.user_authkey, self.user_passkey, torrent_id)
|
|
|
|
|
|
|
|
if title and download_url:
|
|
|
|
items[mode].append((title, download_url, seeders, self._bytesizer(size)))
|
|
|
|
|
2016-08-26 23:36:01 +00:00
|
|
|
except (StandardError, Exception):
|
2015-07-08 00:02:29 +00:00
|
|
|
logger.log(u'Failed to parse. Traceback: %s' % traceback.format_exc(), logger.ERROR)
|
2015-09-18 00:06:34 +00:00
|
|
|
self._log_search(mode, len(items[mode]) - cnt, search_url)
|
2015-07-08 00:02:29 +00:00
|
|
|
|
2016-08-26 23:36:01 +00:00
|
|
|
results = self._sort_seeding(mode, results + items[mode])
|
2015-07-08 00:02:29 +00:00
|
|
|
|
|
|
|
return results
|
|
|
|
|
2017-02-17 03:16:51 +00:00
|
|
|
@staticmethod
|
|
|
|
def regulate_title(item, t_param):
|
|
|
|
|
|
|
|
if 'tags' not in item or not any(item['tags']):
|
|
|
|
return t_param
|
|
|
|
|
|
|
|
t = ['']
|
|
|
|
bl = '[*\[({]+\s*'
|
|
|
|
br = '\s*[})\]*]+'
|
|
|
|
title = re.sub('(.*?)((?i)%sproper%s)(.*)' % (bl, br), r'\1\3\2', item['groupName'])
|
|
|
|
for r in '\s+-\s+', '(?:19|20)\d\d(?:\-\d\d\-\d\d)?', 'S\d\d+(?:E\d\d+)?':
|
|
|
|
m = re.findall('(.*%s)(.*)' % r, title)
|
|
|
|
if any(m) and len(m[0][0]) > len(t[0]):
|
|
|
|
t = m[0]
|
|
|
|
t = (tuple(title), t)[any(t)]
|
|
|
|
|
|
|
|
tag_str = '_'.join(item['tags'])
|
|
|
|
tags = [re.findall(x, tag_str, flags=re.X) for x in
|
|
|
|
('(?i)%sProper%s|\bProper\b$' % (bl, br),
|
|
|
|
'(?i)\d{3,4}(?:[pi]|hd)',
|
|
|
|
'''
|
|
|
|
(?i)(hr.ws.pdtv|blu.?ray|hddvd|
|
|
|
|
pdtv|hdtv|dsr|tvrip|web.?(?:dl|rip)|dvd.?rip|b[r|d]rip|mpeg-?2)
|
|
|
|
''', '''
|
|
|
|
(?i)([hx].?26[45]|divx|xvid)
|
|
|
|
''', '''
|
|
|
|
(?i)(avi|mkv|mp4|sub(?:b?ed|pack|s))
|
|
|
|
''')]
|
|
|
|
|
|
|
|
title = ('%s`%s' % (
|
|
|
|
re.sub('|'.join(['|'.join([re.escape(y) for y in x]) for x in tags if x]).strip('|'), '', t[-1]),
|
|
|
|
re.sub('(?i)(\d{3,4})hd', r'\1p', '`'.join(['`'.join(x) for x in tags[:-1]]).rstrip('`')) +
|
|
|
|
('', '`hdtv')[not any(tags[2])] + ('', '`x264')[not any(tags[3])]))
|
|
|
|
for r in [('(?i)(?:\W(?:Series|Season))?\W(Repack)\W', r'`\1`'),
|
|
|
|
('(?i)%s(Proper)%s' % (bl, br), r'`\1`'), ('%s\s*%s' % (bl, br), '`')]:
|
|
|
|
title = re.sub(r[0], r[1], title)
|
|
|
|
|
|
|
|
grp = filter(lambda rn: '.release' in rn.lower(), item['tags'])
|
|
|
|
title = '%s%s-%s' % (('', t[0])[1 < len(t)], title,
|
|
|
|
(any(grp) and grp[0] or 'nogrp').upper().replace('.RELEASE', ''))
|
|
|
|
|
|
|
|
for r in [('\s+[-]?\s+|\s+`|`\s+', '`'), ('`+', '.')]:
|
|
|
|
title = re.sub(r[0], r[1], title)
|
|
|
|
|
|
|
|
title += + any(tags[4]) and ('.%s' % tags[4][0]) or ''
|
|
|
|
return title
|
|
|
|
|
2015-07-08 00:02:29 +00:00
|
|
|
|
2017-05-02 16:08:28 +00:00
|
|
|
provider = NebulanceProvider()
|