|
|
@ -61,10 +61,9 @@ class TVChaosUKProvider(generic.TorrentProvider): |
|
|
|
for search_string in search_params[mode]: |
|
|
|
search_string = isinstance(search_string, unicode) and unidecode(search_string) or search_string |
|
|
|
|
|
|
|
if 'Cache' != mode: |
|
|
|
kwargs = dict(post_data={'keywords': search_string, 'do': 'quick_sort', 'page': '0', |
|
|
|
'category': '0', 'search_type': 't_name', 'sort': 'added', |
|
|
|
'order': 'desc', 'daysprune': '-1'}) |
|
|
|
kwargs = dict(post_data={'keywords': search_string, 'do': 'quick_sort', 'page': '0', |
|
|
|
'category': '0', 'search_type': 't_name', 'sort': 'added', |
|
|
|
'order': 'desc', 'daysprune': '-1'}) |
|
|
|
|
|
|
|
html = self.get_url(self.urls['search'], **kwargs) |
|
|
|
|
|
|
@ -81,13 +80,15 @@ class TVChaosUKProvider(generic.TorrentProvider): |
|
|
|
if 2 > len(torrent_rows): |
|
|
|
raise generic.HaltParseException |
|
|
|
|
|
|
|
head = None |
|
|
|
for tr in torrent_rows[1:]: |
|
|
|
cells = tr.find_all('td') |
|
|
|
if 6 > len(cells): |
|
|
|
continue |
|
|
|
try: |
|
|
|
head = head if None is not head else self._header_row(tr) |
|
|
|
seeders, leechers, size = [tryInt(n, n) for n in [ |
|
|
|
cells[x].get_text().strip() for x in -3, -2, -5]] |
|
|
|
cells[head[x]].get_text().strip() for x in 'seed', 'leech', 'size']] |
|
|
|
if self._peers_fail(mode, seeders, leechers) \ |
|
|
|
or self.freeleech and None is cells[1].find('img', title=rc['fl']): |
|
|
|
continue |
|
|
@ -114,37 +115,7 @@ class TVChaosUKProvider(generic.TorrentProvider): |
|
|
|
get_detail = False |
|
|
|
|
|
|
|
try: |
|
|
|
has_series = re.findall('(?i)(.*?series[^\d]*?\d+)(.*)', title) |
|
|
|
if has_series: |
|
|
|
rc_xtras = re.compile('(?i)([. _-]|^)(special|extra)s?\w*([. _-]|$)') |
|
|
|
has_special = rc_xtras.findall(has_series[0][1]) |
|
|
|
if has_special: |
|
|
|
title = has_series[0][0] + rc_xtras.sub(list(set( |
|
|
|
list(has_special[0][0]) + list(has_special[0][2])))[0], has_series[0][1]) |
|
|
|
title = re.sub('(?i)series', r'Season', title) |
|
|
|
|
|
|
|
title_parts = re.findall( |
|
|
|
'(?im)^(.*?)(?:Season[^\d]*?(\d+).*?)?' + |
|
|
|
'(?:(?:pack|part|pt)\W*?)?(\d+)[^\d]*?of[^\d]*?(?:\d+)(.*?)$', title) |
|
|
|
if len(title_parts): |
|
|
|
new_parts = [tryInt(part, part.strip()) for part in title_parts[0]] |
|
|
|
if not new_parts[1]: |
|
|
|
new_parts[1] = 1 |
|
|
|
new_parts[2] = ('E%02d', ' Pack %d')[mode in 'Season'] % new_parts[2] |
|
|
|
title = '%s.S%02d%s.%s' % tuple(new_parts) |
|
|
|
|
|
|
|
dated = re.findall( |
|
|
|
'(?i)([(\s]*)((?:\d\d\s)?[adfjmnos]\w{2,}\s+(?:19|20)\d\d)([)\s]*)', title) |
|
|
|
if dated: |
|
|
|
title = title.replace(''.join(dated[0]), '%s%s%s' % ( |
|
|
|
('', ' ')[1 < len(dated[0][0])], parse(dated[0][1]).strftime('%Y-%m-%d'), |
|
|
|
('', ' ')[1 < len(dated[0][2])])) |
|
|
|
add_pad = re.findall('((?:19|20)\d\d[-]\d\d[-]\d\d)([\w\W])', title) |
|
|
|
if len(add_pad) and add_pad[0][1] not in [' ', '.']: |
|
|
|
title = title.replace(''.join( |
|
|
|
add_pad[0]), '%s %s' % (add_pad[0][0], add_pad[0][1])) |
|
|
|
title = re.sub(r'(?sim)(.*?)(?:Episode|Season).\d+.(.*)', r'\1\2', title) |
|
|
|
|
|
|
|
title = self.regulate_title(title, mode) |
|
|
|
if title and download_url: |
|
|
|
items[mode].append((title, download_url, seeders, self._bytesizer(size))) |
|
|
|
except (StandardError, Exception): |
|
|
@ -165,6 +136,84 @@ class TVChaosUKProvider(generic.TorrentProvider): |
|
|
|
|
|
|
|
return results |
|
|
|
|
|
|
|
@staticmethod |
|
|
|
def regulate_title(title, mode='-'): |
|
|
|
|
|
|
|
has_series = re.findall('(?i)(.*?series[^\d]*?\d+)(.*)', title) |
|
|
|
if has_series: |
|
|
|
rc_xtras = re.compile('(?i)([. _-]|^)(special|extra)s?\w*([. _-]|$)') |
|
|
|
has_special = rc_xtras.findall(has_series[0][1]) |
|
|
|
if has_special: |
|
|
|
title = has_series[0][0] + rc_xtras.sub(list(set( |
|
|
|
list(has_special[0][0]) + list(has_special[0][2])))[0], has_series[0][1]) |
|
|
|
title = re.sub('(?i)series', r'Season', title) |
|
|
|
|
|
|
|
years = re.findall('((?:19|20)\d\d)', title) |
|
|
|
title = re.sub('(19|20)\d\d', r'{{yr}}', title) |
|
|
|
title_parts = re.findall( |
|
|
|
'(?im)^(.*?)(?:Season[^\d]*?(\d+).*?)?' + |
|
|
|
'(?:(?:pack|part|pt)\W*?)?(\d+)[^\d]*?of[^\d]*?(?:\d+)(.*?)$', title) |
|
|
|
if len(title_parts): |
|
|
|
new_parts = [tryInt(part, part) for part in title_parts[0]] |
|
|
|
if not new_parts[1]: |
|
|
|
new_parts[1] = 1 |
|
|
|
new_parts[2] = ('E%02d', ' Pack %d')[any([re.search('(?i)season|series', title), |
|
|
|
mode in 'Season'])] % new_parts[2] |
|
|
|
title = '%s`S%02d%s`%s' % tuple(new_parts) |
|
|
|
for yr in years: |
|
|
|
title = re.sub('\{\{yr\}\}', yr, title, count=1) |
|
|
|
|
|
|
|
dated = re.findall('(?i)([(\s]*)((?:\d+\s)?)([adfjmnos]\w{2,}\s+)((?:19|20)\d\d)([)\s]*)', title) |
|
|
|
for d in dated: |
|
|
|
try: |
|
|
|
dout = parse(''.join(d[1:4])).strftime('%Y-%m-%d') |
|
|
|
title = title.replace(''.join(d), '%s%s%s' % ( |
|
|
|
('', ' ')[1 < len(d[0])], dout[0: not any(d[2]) and 4 or not any(d[1]) and 7 or len(dout)], |
|
|
|
('', ' ')[1 < len(d[4])])) |
|
|
|
except (StandardError, Exception): |
|
|
|
pass |
|
|
|
if dated: |
|
|
|
add_pad = re.findall('((?:19|20)\d\d[-]\d\d[-]\d\d)([\w\W])', title) |
|
|
|
if any(add_pad) and add_pad[0][1] not in [' ', '.']: |
|
|
|
title = title.replace(''.join( |
|
|
|
add_pad[0]), '%s %s' % (add_pad[0][0], add_pad[0][1])) |
|
|
|
title = re.sub(r'(?sim)(.*?)(?:Episode|Season).\d+.(.*)', r'\1\2', title) |
|
|
|
|
|
|
|
t = [''] |
|
|
|
bl = '[*\[({]+\s*' |
|
|
|
br = '\s*[})\]*]+' |
|
|
|
title = re.sub('(.*?)((?i)%sproper%s)(.*)' % (bl, br), r'\1\3\2', title) |
|
|
|
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 = ([title], t)[any(t)] |
|
|
|
|
|
|
|
tags = [re.findall(x, t[-1], 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) |
|
|
|
|
|
|
|
title = '%s%s-nogrp' % (('', t[0])[1 < len(t)], title) |
|
|
|
for r in [('\s+[-]?\s+|\s+`|`\s+', '`'), ('`+', '.')]: |
|
|
|
title = re.sub(r[0], r[1], title) |
|
|
|
|
|
|
|
return title |
|
|
|
|
|
|
|
def _season_strings(self, ep_obj, **kwargs): |
|
|
|
|
|
|
|
return generic.TorrentProvider._season_strings(self, ep_obj, scene=False, prefix='%', sp_detail=( |
|
|
@ -183,7 +232,7 @@ class TVChaosUKProvider(generic.TorrentProvider): |
|
|
|
def ui_string(key): |
|
|
|
|
|
|
|
return ('tvchaosuk_tip' == key |
|
|
|
and 'has missing quality data so you must add quality Custom/Unknown to any wanted show' or '') |
|
|
|
and 'releases are often "Air by date release names" - edit search settings of show if required' or '') |
|
|
|
|
|
|
|
|
|
|
|
provider = TVChaosUKProvider() |
|
|
|