Skip to content

Commit

Permalink
Merge pull request #518 from cameronkinsella/bug/Fix_duplicate_mapping
Browse files Browse the repository at this point in the history
Skip episode if another is mapped to its value
  • Loading branch information
ZeroQI authored Jun 30, 2022
2 parents 16c8a40 + f258807 commit c24f2e3
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions Contents/Code/TheTVDBv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ def GetMetadata(media, movie, error_log, lang, metadata_source, AniDBid, TVDBid,

### episode loop ###
tvdb_special_missing, summary_missing_special, summary_missing, summary_present, episode_missing, episode_missing_season, episode_missing_season_all, abs_number, ep_count = [], [], [], [], [], [], True, 0, 0

# To avoid duplicate mapping we will remember episodes that have been mapped to a different value
mapped_episodes = []
for key in sorted(sorted_episodes_json):
episode_json = sorted_episodes_json[key]
episode = str(Dict(episode_json, 'airedEpisodeNumber'))
season = str(Dict(episode_json, 'airedSeason' ))
season, episode, anidbid = AnimeLists.anidb_ep(mappingList, season, episode)
if anidbid != 'xxxxxxx': mapped_episodes.append((season, episode))

for key in sorted(sorted_episodes_json):

# Episode and Absolute number calculation engine, episode translation
Expand Down Expand Up @@ -185,9 +195,11 @@ def GetMetadata(media, movie, error_log, lang, metadata_source, AniDBid, TVDBid,

### Check for Missing Episodes ###
is_missing = False
if not(str(Dict(episode_json, 'airedSeason'))=='0' and str(Dict(episode_json, 'airedEpisodeNumber')) in list_sp_eps) and \
not(metadata_source in ('tvdb3', 'tvdb4') and str(abs_number) in list_abs_eps) and \
not(not movie and season in media.seasons and episode in media.seasons[season].episodes):
if (not(str(Dict(episode_json, 'airedSeason'))=='0' and str(Dict(episode_json, 'airedEpisodeNumber')) in list_sp_eps) and
not(metadata_source in ('tvdb3', 'tvdb4') and str(abs_number) in list_abs_eps) and
not(not movie and season in media.seasons and episode in media.seasons[season].episodes)) or \
(not movie and season in media.seasons and episode in media.seasons[season].episodes and
anidbid == 'xxxxxxx' and (season, episode) in mapped_episodes):
is_missing = True
Log.Info('[ ] {:>7} s{:0>2}e{:0>3} anidbid: {:>7} air_date: {}'.format(numbering, season, episode, anidbid, Dict(episode_json, 'firstAired')))
air_date = Dict(episode_json, 'firstAired')
Expand Down

0 comments on commit c24f2e3

Please sign in to comment.