Merge branch 'master' into develop

This commit is contained in:
JackDandy 2018-05-08 00:53:34 +01:00
commit 0b7b0f1401
14 changed files with 63 additions and 54 deletions

View file

@ -8,6 +8,12 @@
### 0.16.5 (2018-05-07 21:15:00 UTC)
* Fix HTTP 422 error when using Plex Username and Password
* Change how show URLs are made for TV info sources
### 0.16.4 (2018-05-03 12:00:00 UTC)
* Fix PiSexy torrent provider

View file

@ -191,7 +191,7 @@
#continue
#end if
#if not $indexerApi($src_id).config.get('defunct')
<a class="service addQTip" href="$anon_url($indexerApi($src_id).config['show_url'], $show.ids[$src_id]['id'])" rel="noreferrer" onclick="window.open(this.href, '_blank'); return !1;" title="View $src_name info in new tab">
<a class="service addQTip" href="$anon_url($indexerApi($src_id).config['show_url'] % $show.ids[$src_id]['id'])" rel="noreferrer" onclick="window.open(this.href, '_blank'); return !1;" title="View $src_name info in new tab">
#else#
<a class="service addQTip" href="$sbRoot/home/editShow?show=$show.indexerid#core-component-group3" title="Edit related show IDs">
#end if#
@ -430,7 +430,7 @@
#if not len($seasons)
<div id="no-episode-data">
<h3>No episode details at TV info source
<a class="service" href="$anon_url($indexerApi($show.indexer).config['show_url'], $show.indexerid)" onclick="window.open(this.href, '_blank'); return !1;" title="View $indexerApi($show.indexer).name info in new tab">$indexerApi($show.indexer).name</a>
<a class="service" href="$anon_url($indexerApi($show.indexer).config['show_url'] % $show.indexerid)" onclick="window.open(this.href, '_blank'); return !1;" title="View $indexerApi($show.indexer).name info in new tab">$indexerApi($show.indexer).name</a>
</h3>
</div>
#else

View file

@ -317,7 +317,7 @@
#set $data_link = ''
#set $use_search_url = False
#end if
<a id="src-mid-$src_id" class="service" style="margin-right:6px" data-search="#if $use_search_url#y#else#n#end if#" #if $src_search_url#data-search-href="$anon_url($src_search_url % $search_name)" data-search-onclick="window.open(this.href, '_blank'); return !1;" data-search-title="Search for show at $src_name" #end if##if $use_search_url#href="$anon_url($src_search_url % $search_name)" onclick="window.open(this.href, '_blank'); return !1;" title="Search for show at $src_name" #end if#$(data_link)href="$anon_url(sickbeard.indexerApi($src_id).config['show_url'], ($show.ids[$src_id]['id'], $srcid)[$expand_ids and ($src_id == $tvsrc)])" $(data_link)onclick="window.open(this.href, '_blank'); return !1;" $(data_link)title="View $src_name info in new tab"><img alt="$src_name" height="16" width="16" src="$sbRoot/images/$sickbeard.indexerApi($src_id).config['icon']" /></a>
<a id="src-mid-$src_id" class="service" style="margin-right:6px" data-search="#if $use_search_url#y#else#n#end if#" #if $src_search_url#data-search-href="$anon_url($src_search_url % $search_name)" data-search-onclick="window.open(this.href, '_blank'); return !1;" data-search-title="Search for show at $src_name" #end if##if $use_search_url#href="$anon_url($src_search_url % $search_name)" onclick="window.open(this.href, '_blank'); return !1;" title="Search for show at $src_name" #end if#$(data_link)href="$anon_url(sickbeard.indexerApi($src_id).config['show_url'] % ($show.ids[$src_id]['id'], $srcid)[$expand_ids and ($src_id == $tvsrc)])" $(data_link)onclick="window.open(this.href, '_blank'); return !1;" $(data_link)title="View $src_name info in new tab"><img alt="$src_name" height="16" width="16" src="$sbRoot/images/$sickbeard.indexerApi($src_id).config['icon']" /></a>
#end if
$src_name
</span>

View file

@ -421,10 +421,10 @@
</td>
<td align="center" style="vertical-align:middle">
#if $sg_var('USE_IMDB_INFO') and $cur_result['imdb_id']
<a href="<%= anon_url('http://www.imdb.com/title/', cur_result['imdb_id']) %>" rel="noreferrer" onclick="window.open(this.href, '_blank'); return false" title="http://www.imdb.com/title/${cur_result['imdb_id']}"><img alt="[$sickbeard.indexerApi(INDEXER_IMDB).config.get('name')]" height="16" width="16" src="$sbRoot/images/$sickbeard.indexerApi(INDEXER_IMDB).config.get('icon')" /></a>
#if $sg_var('USE_IMDB_INFO') and $cur_result['imdb_url']
<a href="<%= anon_url(cur_result['imdb_url']) %>" rel="noreferrer" onclick="window.open(this.href, '_blank'); return false" title="${cur_result['imdb_url']}"><img alt="[$sickbeard.indexerApi(INDEXER_IMDB).config.get('name')]" height="16" width="16" src="$sbRoot/images/$sickbeard.indexerApi(INDEXER_IMDB).config.get('icon')" /></a>
#end if
<a href="<%= anon_url(sickbeard.indexerApi(cur_indexer).config['show_url'], cur_result['showid']) %>" rel="noreferrer" onclick="window.open(this.href, '_blank'); return false" title="$sickbeard.indexerApi($cur_indexer).config['show_url']${cur_result['showid']}"><img alt="$sickbeard.indexerApi($cur_indexer).name" height="16" width="16" src="$sbRoot/images/$sickbeard.indexerApi($cur_indexer).config['icon']" /></a>
<a href="<%= anon_url(sickbeard.indexerApi(cur_indexer).config['show_url'] % cur_result['showid']) %>" rel="noreferrer" onclick="window.open(this.href, '_blank'); return false" title="${sickbeard.indexerApi($cur_indexer).config['show_url'] % cur_result['showid']}"><img alt="$sickbeard.indexerApi($cur_indexer).name" height="16" width="16" src="$sbRoot/images/$sickbeard.indexerApi($cur_indexer).config['icon']" /></a>
</td>
<td align="center">
@ -610,10 +610,10 @@
</a></span>
<span class="tvshowTitleIcons">
#if $sg_var('USE_IMDB_INFO') and $cur_result['imdb_id']
<a href="<%= anon_url('http://www.imdb.com/title/', cur_result['imdb_id']) %>" rel="noreferrer" onclick="window.open(this.href, '_blank'); return false" title="http://www.imdb.com/title/${cur_result['imdb_id']}"><img alt="[$sickbeard.indexerApi(INDEXER_IMDB).name]" height="16" width="16" src="$sbRoot/images/$sickbeard.indexerApi(INDEXER_IMDB).config.get('icon')" /></a>
#if $sg_var('USE_IMDB_INFO') and $cur_result['imdb_url']
<a href="<%= anon_url(cur_result['imdb_url']) %>" rel="noreferrer" onclick="window.open(this.href, '_blank'); return false" title="${cur_result['imdb_url']}"><img alt="[$sickbeard.indexerApi(INDEXER_IMDB).name]" height="16" width="16" src="$sbRoot/images/$sickbeard.indexerApi(INDEXER_IMDB).config.get('icon')" /></a>
#end if
<a href="<%= anon_url(sickbeard.indexerApi(cur_indexer).config['show_url'], cur_result['showid']) %>" rel="noreferrer" onclick="window.open(this.href, '_blank'); return false" title="$sickbeard.indexerApi($cur_indexer).config['show_url']${cur_result['showid']}"><img alt="$sickbeard.indexerApi($cur_indexer).name" height="16" width="16" src="$sbRoot/images/$sickbeard.indexerApi($cur_indexer).config['icon']" /></a>
<a href="<%= anon_url(sickbeard.indexerApi(cur_indexer).config['show_url'] % cur_result['showid']) %>" rel="noreferrer" onclick="window.open(this.href, '_blank'); return false" title="${sickbeard.indexerApi($cur_indexer).config['show_url'] % cur_result['showid']}"><img alt="$sickbeard.indexerApi($cur_indexer).name" height="16" width="16" src="$sbRoot/images/$sickbeard.indexerApi($cur_indexer).config['icon']" /></a>
<span><a href="$sbRoot/home/searchEpisode?show=${cur_result['showid']}&amp;season=$cur_result['season']&amp;episode=$cur_result['episode']" title="Manual Search" id="forceUpdate-${cur_result['showid']}" class="epSearch forceUpdate"><img alt="[search]" height="16" width="16" src="$sbRoot/images/search16.png" id="forceUpdateImage-${cur_result['showid']}" /></a></span>
</span>
</div>

View file

@ -57,7 +57,7 @@
</td>
#if $curDir['existing_info'][1] and $indexer > 0
<td>
<a href="<%= anon_url(sickbeard.indexerApi(indexer).config['show_url'], curDir['existing_info'][0]) %>" target="_new">$curDir['existing_info'][1]</a>
<a href="<%= anon_url(sickbeard.indexerApi(indexer).config['show_url'] % curDir['existing_info'][0]) %>" target="_new">$curDir['existing_info'][1]</a>
</td>
#else
<td>?</td>

View file

@ -62,7 +62,7 @@
#if $use_provided_info
#set $provided_indexer_local = $provided_indexer
#set $provided_indexer_id_local = $provided_indexer_id
Show: <a href="<%= anon_url(sickbeard.indexerApi(provided_indexer_local).config['show_url'], provided_indexer_id_local) %>">$provided_indexer_name</a>
Show: <a href="<%= anon_url(sickbeard.indexerApi(provided_indexer_local).config['show_url'] % provided_indexer_id_local) %>">$provided_indexer_name</a>
<input type="hidden" name="indexerLang" value="en">
<input type="hidden" name="whichSeries" value="#echo '|'.join([str($provided_indexer), '', str($provided_indexer_id), $provided_indexer_name])#">
<input type="hidden" id="providedName" value="$provided_indexer_name">

View file

@ -123,7 +123,7 @@ $(document).ready(function () {
+ (0 < item[result.Overview].length ? '<p style=\'margin:0 0 2px\'>' + item[result.Overview] + '</p>' : '')
+ '<span style=\'float:right;clear:both\'>Click for more</span>'
+ '"'
+ ' href="' + anonURL + item[result.SrcUrl] + item[result.ShowID] + ((data.langid && '' != data.langid) ? '&lid=' + data.langid : '') + '"'
+ ' href="' + anonURL + item[result.SrcUrl] + ((data.langid && '' != data.langid) ? '&lid=' + data.langid : '') + '"'
+ ' onclick="window.open(this.href, \'_blank\'); return !1;"'
+ '>' + (config.sortArticle ? displayShowName : displayShowName.replace(/^((?:A(?!\s+to)n?)|The)(\s)+(.*)/i, '$3$2<span class="article">($1)</span>')) + '</a>'
+ showstartdate

View file

@ -132,7 +132,7 @@ class Plex:
'X-Plex-Username': user
},
json=True,
data=urlencode({b'user[login]': user, b'user[password]': passw}).encode('utf-8')
post_data=urlencode({b'user[login]': user, b'user[password]': passw}).encode('utf-8')
)['user']['authentication_token']
except IndexError:
self.log('Error getting Plex Token')
@ -181,8 +181,7 @@ class Plex:
if None is not home_users:
for user in home_users.findall('User'):
user_id = user.get('id')
# use empty byte data to force POST
switch_page = self.get_url_x('https://plex.tv/api/home/users/%s/switch' % user_id, data=b'')
switch_page = self.get_url_x('https://plex.tv/api/home/users/%s/switch' % user_id, post_data=True)
if None is not switch_page:
home_token = 'user' == switch_page.tag and switch_page.get('authenticationToken')
if home_token:

View file

@ -1164,6 +1164,9 @@ def getURL(url, post_data=None, params=None, headers=None, timeout=30, session=N
# decide if we get or post data to server
if post_data or 'post_json' in kwargs:
if True is post_data:
post_data = None
if post_data:
kwargs.setdefault('data', post_data)
@ -1697,8 +1700,6 @@ def path_mapper(search, replace, subject):
replace = re.sub(r'[\\]', delim, replace)
path = re.sub(r'[\\]', delim, subject)
result = re.sub('(?i)^%s' % search, replace, path)
if re.search(delim, path):
result = os.path.normpath(re.sub(delim, '/', result))
result = os.path.normpath(re.sub(delim, '/', result))
return result, result != subject

View file

@ -105,7 +105,7 @@ info_src = INDEXER_TVDB
indexerConfig[info_src].update(dict(
base_url=(indexerConfig[info_src]['main_url'] +
'api/%(apikey)s/series/' % indexerConfig[info_src]['api_params']),
show_url='%s?tab=series&id=' % indexerConfig[info_src]['main_url'],
show_url='%s?tab=series&id=%%d' % indexerConfig[info_src]['main_url'],
finder=(indexerConfig[info_src]['main_url'] +
'index.php?fieldlocation=2&language=7&order=translation&searching=Search&tab=advancedsearch&seriesname=%s'),
scene_url='https://midgetspy.github.io/sb_tvdb_scene_exceptions/exceptions.txt',
@ -116,7 +116,7 @@ info_src = INDEXER_TVDB_V1
indexerConfig[info_src].update(dict(
base_url=(indexerConfig[info_src]['main_url'] +
'api/%(apikey)s/series/' % indexerConfig[info_src]['api_params']),
show_url='%s?tab=series&id=' % indexerConfig[info_src]['main_url'],
show_url='%s?tab=series&id=%%d' % indexerConfig[info_src]['main_url'],
finder=(indexerConfig[info_src]['main_url'] +
'index.php?fieldlocation=2&language=7&order=translation&searching=Search&tab=advancedsearch&seriesname=%s'),
))
@ -125,7 +125,7 @@ info_src = INDEXER_TVRAGE
indexerConfig[info_src].update(dict(
base_url=(indexerConfig[info_src]['main_url'] +
'showinfo.php?key=%(apikey)s&sid=' % indexerConfig[info_src]['api_params']),
show_url='%sshows/id-' % indexerConfig[info_src]['main_url'],
show_url='%sshows/id-%%d' % indexerConfig[info_src]['main_url'],
scene_url='https://sickgear.github.io/sg_tvrage_scene_exceptions/exceptions.txt',
defunct=True,
))
@ -133,27 +133,27 @@ indexerConfig[info_src].update(dict(
info_src = INDEXER_TVMAZE
indexerConfig[info_src].update(dict(
base_url='https://api.tvmaze.com/',
show_url='%sshows/' % indexerConfig[info_src]['main_url'],
show_url='%sshows/%%d' % indexerConfig[info_src]['main_url'],
finder='%ssearch?q=%s' % (indexerConfig[info_src]['main_url'], '%s'),
))
info_src = INDEXER_IMDB
indexerConfig[info_src].update(dict(
base_url=indexerConfig[info_src]['main_url'],
show_url='%stitle/tt' % indexerConfig[info_src]['main_url'],
show_url='%stitle/tt%%07d' % indexerConfig[info_src]['main_url'],
finder='%sfind?q=%s&s=tt&ttype=tv&ref_=fn_tv' % (indexerConfig[info_src]['main_url'], '%s'),
))
info_src = INDEXER_TRAKT
indexerConfig[info_src].update(dict(
base_url=indexerConfig[info_src]['main_url'],
show_url='%sshows/' % indexerConfig[info_src]['main_url'],
show_url='%sshows/%%d' % indexerConfig[info_src]['main_url'],
finder='%ssearch/shows?query=%s' % (indexerConfig[info_src]['main_url'], '%s'),
))
info_src = INDEXER_TMDB
indexerConfig[info_src].update(dict(
base_url=indexerConfig[info_src]['main_url'],
show_url='%stv/' % indexerConfig[info_src]['main_url'],
show_url='%stv/%%d' % indexerConfig[info_src]['main_url'],
finder='%ssearch/tv?query=%s' % (indexerConfig[info_src]['main_url'], '%s'),
))

View file

@ -32,7 +32,8 @@ def getShowImage(url, imgNum=None, showName=None):
image_data = helpers.getURL(temp_url)
if None is image_data:
logger.log('There was an error trying to retrieve the image%s, aborting' % ('', ' for show: %s' % showName)[None is not showName], logger.ERROR)
logger.log('There was an error trying to retrieve the image%s, aborting' %
('', ' for show: %s' % showName)[None is not showName], logger.WARNING)
return
return image_data

View file

@ -51,8 +51,8 @@ class PiSexyProvider(generic.TorrentProvider):
items = {'Cache': [], 'Season': [], 'Episode': [], 'Propers': []}
rc = dict((k, re.compile('(?i)' + v)) for (k, v) in {
'info': 'download', 'get': 'info.php\?id', 'valid_cat': 'cat=(?:0|50[12])', 'filter': 'free',
'title': r'Download\s([^\s]+).*', 'seeders': r'(^\d+)', 'leechers': r'(\d+)$'}.items())
'get': 'info.php\?id', 'valid_cat': 'cat=(?:0|50[12])', 'filter': 'free',
'title': r'Download\s*([^\s]+).*', 'seeders': r'(^\d+)', 'leechers': r'(\d+)$'}.items())
for mode in search_params.keys():
for search_string in search_params[mode]:
search_string = isinstance(search_string, unicode) and unidecode(search_string) or search_string
@ -88,10 +88,10 @@ class PiSexyProvider(generic.TorrentProvider):
or (self.freeleech and not tr.find('img', src=rc['filter'])):
continue
info = tr.find('a', href=rc['info']) or tr.find('a', href=rc['get'])
title = (rc['title'].sub('', info.attrs.get('title', '')) or info.get_text()).strip()
info = tr.find('a', href=rc['get'])
title = (rc['title'].sub(r'\1', info.attrs.get('title', '')) or info.get_text()).strip()
size = cells[head['size']].get_text().strip()
download_url = self._link(tr.find('a', href=rc['get'])['href'])
download_url = self._link(info['href'])
except (AttributeError, TypeError, ValueError, KeyError, IndexError):
continue

View file

@ -2177,7 +2177,10 @@ class CMD_SickGearGetIndexers(ApiCall):
not indexer_config.indexerConfig[i].get('defunct')
else:
key = d
val = (v, '%s{INDEXER-ID}' % v)['show_url' == d]
if 'show_url' == d:
val = re.sub(r'%\d{,2}d', '{INDEXER-ID}', v, flags=re.I)
else:
val = v
result.setdefault(i, {}).update({key: val})
return _responds(RESULT_SUCCESS, result)

View file

@ -842,6 +842,18 @@ class MainHandler(WebHandler):
sql_results[index]['data_show_name'] = value_maybe_article(item['show_name'])
sql_results[index]['data_network'] = value_maybe_article(item['network'])
imdb_id = None
if item['imdb_id']:
try:
imdb_id = helpers.tryInt(re.search(r'(\d+)', item['imdb_id']).group(1))
except (StandardError, Exception):
pass
if imdb_id:
sql_results[index]['imdb_url'] = sickbeard.indexers.indexer_config.indexerConfig[
sickbeard.indexers.indexer_config.INDEXER_IMDB]['show_url'] % imdb_id
else:
sql_results[index]['imdb_url'] = ''
show_id = item['showid']
if show_id in t.fanart:
continue
@ -1719,14 +1731,6 @@ class Home(MainHandler):
return json.dumps({'success': t.respond()})
@staticmethod
def fix_imdb_id(obj):
try:
obj.ids[sickbeard.indexers.indexer_config.INDEXER_IMDB]['id'] = '%07d' % obj.ids[
sickbeard.indexers.indexer_config.INDEXER_IMDB]['id']
except (StandardError, Exception):
pass
def displayShow(self, show=None):
if show is None:
@ -1801,9 +1805,7 @@ class Home(MainHandler):
t.submenu.append(
{'title': 'Download Subtitles', 'path': 'home/subtitleShow?show=%d' % showObj.indexerid})
import copy
t.show = copy.deepcopy(showObj)
self.fix_imdb_id(t.show)
t.show = showObj
with BS4Parser('<html><body>%s</body></html>' % showObj.overview, features=['html5lib', 'permissive']) as soup:
try:
soup.a.replace_with(soup.new_tag(''))
@ -2233,9 +2235,7 @@ class Home(MainHandler):
t.groups.append(dict([('name', 'Did not initialise AniDB. Check debug log if reqd.'), ('rating', ''), ('range', '')]))
with showObj.lock:
import copy
t.show = copy.deepcopy(showObj)
self.fix_imdb_id(t.show)
t.show = showObj
t.show_has_scene_map = showObj.indexerid in sickbeard.scene_exceptions.xem_ids_list[showObj.indexer]
# noinspection PyTypeChecker
@ -3167,7 +3167,8 @@ class NewHomeAddShows(Home):
sickbeard.showList, {(iid, INDEXER_TVDB)[INDEXER_TVDB_X == iid]: int(show['id'])},
no_mapped_ids=False)]) and '/home/displayShow?show=%s' % int(show['id']),
iid, (iid, INDEXER_TVDB)[INDEXER_TVDB_X == iid],
sickbeard.indexerApi((iid, INDEXER_TVDB)[INDEXER_TVDB_X == iid]).config['show_url'], int(show['id']),
sickbeard.indexerApi((iid, INDEXER_TVDB)[INDEXER_TVDB_X == iid]).config['show_url'] % int(show['id']),
int(show['id']),
show['seriesname'], self.encode_html(show['seriesname']), show['firstaired'],
show.get('network', '') or '', show.get('genres', '') or '',
re.sub(r'([,.!][^,.!]*?)$', '...',
@ -3476,7 +3477,7 @@ class NewHomeAddShows(Home):
title=title.strip(),
images=images,
url_src_db='http://anidb.net/perl-bin/animedb.pl?show=anime&aid=%s' % ids['anidb'],
url_tvdb='%s%s' % (sickbeard.indexerApi(INDEXER_TVDB).config['show_url'], ids['tvdb']),
url_tvdb=sickbeard.indexerApi(INDEXER_TVDB).config['show_url'] % ids['tvdb'],
votes=votes, rating=rating,
genres='', overview=''
))
@ -3628,8 +3629,7 @@ class NewHomeAddShows(Home):
src = ((None, 'tvrage')[INDEXER_TVRAGE == indexer], 'tvdb')[INDEXER_TVDB == indexer]
if src:
filtered[-1]['ids'][src] = indexerid
filtered[-1]['url_' + src] = '%s%s' % (
sickbeard.indexerApi(indexer).config['show_url'], indexerid)
filtered[-1]['url_' + src] = sickbeard.indexerApi(indexer).config['show_url'] % indexerid
except (AttributeError, TypeError, KeyError, IndexError):
pass
@ -3712,8 +3712,8 @@ class NewHomeAddShows(Home):
src = ((None, 'tvrage')[INDEXER_TVRAGE == show.indexer], 'tvdb')[INDEXER_TVDB == show.indexer]
if src:
filtered[-1]['ids'][src] = show.indexerid
filtered[-1]['url_' + src] = '%s%s' % (
sickbeard.indexerApi(show.indexer).config['show_url'], show.indexerid)
filtered[-1]['url_' + src] = sickbeard.indexerApi(show.indexer).config['show_url'] % \
show.indexerid
except (AttributeError, TypeError, KeyError, IndexError):
continue
@ -3973,8 +3973,7 @@ class NewHomeAddShows(Home):
('%.2f' % (item['show'].get('rating') * 10)).replace('.00', '') or 0,
title=item['show']['title'].strip(),
url_src_db='https://trakt.tv/shows/%s' % item['show']['ids']['slug'],
url_tvdb=('', '%s%s' % (sickbeard.indexerApi(INDEXER_TVDB).config['show_url'],
item['show']['ids']['tvdb']))[
url_tvdb=('', sickbeard.indexerApi(INDEXER_TVDB).config['show_url'] % item['show']['ids']['tvdb'])[
isinstance(item['show']['ids']['tvdb'], (int, long))
and 0 < item['show']['ids']['tvdb']],
votes='0' if 'votes' not in item['show'] else item['show']['votes']))