From 7d9a201fc156454fbd9bf674d68a81d4b9c4be38 Mon Sep 17 00:00:00 2001 From: Prinz23 Date: Sat, 7 Jan 2017 02:51:59 +0100 Subject: [PATCH] Change improve indexermapper. --- sickbeard/indexermapper.py | 26 +++++++++++++++++--------- sickbeard/indexers/indexer_config.py | 4 ++-- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/sickbeard/indexermapper.py b/sickbeard/indexermapper.py index b905356a..17c22f04 100644 --- a/sickbeard/indexermapper.py +++ b/sickbeard/indexermapper.py @@ -194,11 +194,26 @@ def get_imdbid_by_name(name, startyear): if hasattr(r, 'movieID') and hasattr(r, 'data') and 'kind' in r.data and r.data['kind'] == 'tv series' \ and 'year' in r.data and r.data['year'] == startyear: ids[INDEXER_IMDB] = tryInt(r.movieID) + break except (StandardError, Exception): pass return {k: v for k, v in ids.iteritems() if v not in (None, '', 0)} +def check_missing_trakt_id(n_ids, show_obj, url_trakt): + if INDEXER_TRAKT not in n_ids: + new_url_trakt = TraktDict() + for k, v in n_ids.iteritems(): + if k != show_obj.indexer and k in [INDEXER_TVDB, INDEXER_TVRAGE, INDEXER_IMDB] and 0 < v \ + and k not in url_trakt: + new_url_trakt[k] = v + + if 0 < len(new_url_trakt): + n_ids.update(get_trakt_ids(new_url_trakt)) + + return n_ids + + def map_indexers_to_show(show_obj, update=False, force=False, recheck=False): """ @@ -281,18 +296,11 @@ def map_indexers_to_show(show_obj, update=False, force=False, recheck=False): or k not in new_ids or new_ids.get(k) in (None, 0, '', MapStatus.NOT_FOUND)} new_ids.update(tvids) - if INDEXER_TRAKT not in new_ids: - new_url_trakt = TraktDict() - for k, v in new_ids.iteritems(): - if k != show_obj.indexer and k in [INDEXER_TVDB, INDEXER_TVRAGE, INDEXER_IMDB] and 0 < v \ - and k not in url_trakt: - new_url_trakt[k] = v - - if 0 < len(new_url_trakt): - new_ids.update(get_trakt_ids(new_url_trakt)) + new_ids = check_missing_trakt_id(new_ids, show_obj, url_trakt) if INDEXER_IMDB not in new_ids: new_ids.update(get_imdbid_by_name(show_obj.name, show_obj.startyear)) + new_ids = check_missing_trakt_id(new_ids, show_obj, url_trakt) if INDEXER_TMDB in mis_map \ and (None is new_ids.get(INDEXER_TMDB) or MapStatus.NOT_FOUND == new_ids.get(INDEXER_TMDB)) \ diff --git a/sickbeard/indexers/indexer_config.py b/sickbeard/indexers/indexer_config.py index 9e7a4cbd..6f6ac01a 100644 --- a/sickbeard/indexers/indexer_config.py +++ b/sickbeard/indexers/indexer_config.py @@ -41,7 +41,7 @@ indexerConfig = { icon='tvrage16.png', ), INDEXER_TVMAZE: dict( - main_url='http://www.tvmaze.com/', + main_url='https://www.tvmaze.com/', id=INDEXER_TVMAZE, name='TVmaze', module=None, @@ -109,7 +109,7 @@ indexerConfig[info_src].update(dict( info_src = INDEXER_TVMAZE indexerConfig[info_src].update(dict( - base_url='http://api.tvmaze.com/', + base_url='https://api.tvmaze.com/', show_url='%sshows/' % indexerConfig[info_src]['main_url'], finder='%ssearch?q=%s' % (indexerConfig[info_src]['main_url'], '%s'), ))