Skip to content

Commit

Permalink
Normalize the imdb_id (#10923)
Browse files Browse the repository at this point in the history
* Normalize the imdb_id
* make sure we store imdb_id without `tt` in indexer_mapping

* Fix indents
  • Loading branch information
p0psicles committed Sep 10, 2022
1 parent 17fee5a commit ca129da
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 11 additions & 3 deletions medusa/indexers/tvmaze/api.py
Expand Up @@ -466,9 +466,17 @@ def _get_show_data(self, tvmaze_id, language='en'):
# Get external ids.
# As the external id's are not part of the shows default response, we need to make an additional call for it.
# Im checking for the external value. to make sure only externals with a value get in.
self._set_show_data(tvmaze_id, 'externals', {external_id: text_type(getattr(self.shows[tvmaze_id], external_id, None))
for external_id in ['tvdb_id', 'imdb_id', 'tvrage_id']
if getattr(self.shows[tvmaze_id], external_id, None)})
externals = {
external_id: text_type(getattr(self.shows[tvmaze_id], external_id, None))
for external_id in ['tvdb_id', 'imdb_id', 'tvrage_id']
if getattr(self.shows[tvmaze_id], external_id, None)
}

# Normalize the imdb_id
if 'imdb_id' in externals:
externals['imdb_id'] = ImdbIdentifier(externals['imdb_id']).series_id

self._set_show_data(tvmaze_id, 'externals', externals)

# get episode data
if self.config['episodes_enabled']:
Expand Down
2 changes: 2 additions & 0 deletions medusa/tv/series.py
Expand Up @@ -1368,6 +1368,8 @@ def _save_externals_to_db(self):

for external in self.externals:
if external in reverse_mappings and self.externals[external]:
if external == 'imdb_id':
self.externals[external] = ImdbIdentifier(self.externals[external]).series_id
sql_l.append(['INSERT OR IGNORE '
'INTO indexer_mapping (indexer_id, indexer, mindexer_id, mindexer) '
'VALUES (?,?,?,?)',
Expand Down

0 comments on commit ca129da

Please sign in to comment.