diff --git a/CHANGES.md b/CHANGES.md index 37e0373b..14ce99ba 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 diff --git a/gui/slick/interfaces/default/displayShow.tmpl b/gui/slick/interfaces/default/displayShow.tmpl index e3a0883c..baab0090 100644 --- a/gui/slick/interfaces/default/displayShow.tmpl +++ b/gui/slick/interfaces/default/displayShow.tmpl @@ -191,7 +191,7 @@ #continue #end if #if not $indexerApi($src_id).config.get('defunct') - + #else# #end if# @@ -430,7 +430,7 @@ #if not len($seasons)

No episode details at TV info source - $indexerApi($show.indexer).name + $indexerApi($show.indexer).name

#else diff --git a/gui/slick/interfaces/default/editShow.tmpl b/gui/slick/interfaces/default/editShow.tmpl index 045a9fe7..e2e460df 100644 --- a/gui/slick/interfaces/default/editShow.tmpl +++ b/gui/slick/interfaces/default/editShow.tmpl @@ -317,7 +317,7 @@ #set $data_link = '' #set $use_search_url = False #end if - $src_name + $src_name #end if $src_name diff --git a/gui/slick/interfaces/default/episodeView.tmpl b/gui/slick/interfaces/default/episodeView.tmpl index 2d05066a..19a30db6 100644 --- a/gui/slick/interfaces/default/episodeView.tmpl +++ b/gui/slick/interfaces/default/episodeView.tmpl @@ -421,10 +421,10 @@ - #if $sg_var('USE_IMDB_INFO') and $cur_result['imdb_id'] - [$sickbeard.indexerApi(INDEXER_IMDB).config.get('name')] + #if $sg_var('USE_IMDB_INFO') and $cur_result['imdb_url'] + [$sickbeard.indexerApi(INDEXER_IMDB).config.get('name')] #end if - $sickbeard.indexerApi($cur_indexer).name + $sickbeard.indexerApi($cur_indexer).name @@ -610,10 +610,10 @@ - #if $sg_var('USE_IMDB_INFO') and $cur_result['imdb_id'] - [$sickbeard.indexerApi(INDEXER_IMDB).name] + #if $sg_var('USE_IMDB_INFO') and $cur_result['imdb_url'] + [$sickbeard.indexerApi(INDEXER_IMDB).name] #end if - $sickbeard.indexerApi($cur_indexer).name + $sickbeard.indexerApi($cur_indexer).name [search] diff --git a/gui/slick/interfaces/default/home_massAddTable.tmpl b/gui/slick/interfaces/default/home_massAddTable.tmpl index 2bec4ca1..84b03ef0 100644 --- a/gui/slick/interfaces/default/home_massAddTable.tmpl +++ b/gui/slick/interfaces/default/home_massAddTable.tmpl @@ -57,7 +57,7 @@ #if $curDir['existing_info'][1] and $indexer > 0 - $curDir['existing_info'][1] + $curDir['existing_info'][1] #else ? diff --git a/gui/slick/interfaces/default/home_newShow.tmpl b/gui/slick/interfaces/default/home_newShow.tmpl index 5ebbad89..7b177989 100644 --- a/gui/slick/interfaces/default/home_newShow.tmpl +++ b/gui/slick/interfaces/default/home_newShow.tmpl @@ -62,7 +62,7 @@ #if $use_provided_info #set $provided_indexer_local = $provided_indexer #set $provided_indexer_id_local = $provided_indexer_id - Show: $provided_indexer_name + Show: $provided_indexer_name diff --git a/gui/slick/js/newShow.js b/gui/slick/js/newShow.js index 708e4e73..b4512481 100644 --- a/gui/slick/js/newShow.js +++ b/gui/slick/js/newShow.js @@ -123,7 +123,7 @@ $(document).ready(function () { + (0 < item[result.Overview].length ? '

' + item[result.Overview] + '

' : '') + 'Click for more' + '"' - + ' 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($1)')) + '' + showstartdate diff --git a/lib/plex/plex.py b/lib/plex/plex.py index e287736a..1cc87fc3 100644 --- a/lib/plex/plex.py +++ b/lib/plex/plex.py @@ -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: diff --git a/sickbeard/helpers.py b/sickbeard/helpers.py index e79a8c04..4971cc39 100644 --- a/sickbeard/helpers.py +++ b/sickbeard/helpers.py @@ -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 diff --git a/sickbeard/indexers/indexer_config.py b/sickbeard/indexers/indexer_config.py index 6c23fede..17ace516 100644 --- a/sickbeard/indexers/indexer_config.py +++ b/sickbeard/indexers/indexer_config.py @@ -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'), )) diff --git a/sickbeard/metadata/helpers.py b/sickbeard/metadata/helpers.py index 70cff329..be51decf 100644 --- a/sickbeard/metadata/helpers.py +++ b/sickbeard/metadata/helpers.py @@ -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 diff --git a/sickbeard/providers/pisexy.py b/sickbeard/providers/pisexy.py index ce7ab573..ea629947 100644 --- a/sickbeard/providers/pisexy.py +++ b/sickbeard/providers/pisexy.py @@ -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 diff --git a/sickbeard/webapi.py b/sickbeard/webapi.py index 19db1c03..dc331166 100644 --- a/sickbeard/webapi.py +++ b/sickbeard/webapi.py @@ -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) diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index 73d87a92..30795eae 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -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('%s' % 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']))