Skip to content

Commit

Permalink
Fix tvdbcount
Browse files Browse the repository at this point in the history
tvdbcount should be calculated in the second, full loop. Also piggybacking off the collection array, no need for a separate dict.
  • Loading branch information
Praxinator committed Jan 14, 2023
1 parent 93b214d commit 31ab16a
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions Contents/Code/AnimeLists.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ def GetMetadata(media, movie, error_log, id):
TMDBid = ""
IMDBid = ""
tvdb_numbering = True if not movie and (TVDB_id or AniDB_id and max(map(int, media.seasons.keys()))>1) else False
tvdbcounts = {}

### Search for match ###
Log.Info("tvdb_numbering: {}".format(tvdb_numbering))
Expand Down Expand Up @@ -114,9 +113,6 @@ def anime_core(anime):
else: continue
found = True

# record the number of entries using the same tvdb id
SaveDict(Dict(tvdbcounts, TVDBid, default=0)+1, tvdbcounts, TVDBid)

defaulttvdbseason, episodeoffset, s1_mapping_count, is_primary_series = anime_core(anime)

if not tvdb_numbering and not TVDB_id: TVDB_id2 = TVDBid
Expand Down Expand Up @@ -201,8 +197,6 @@ def anime_core(anime):

Log.Info(' ----- ------')
Log.Info(' {:>5} {:>6}'.format(AniDB_winner, TVDB_winner))

SaveDict(Dict(tvdbcounts, TVDB_winner), mappingList, 'tvdbcount')

if source=="tvdb":
for s in media.seasons:
Expand All @@ -223,6 +217,8 @@ def anime_core(anime):
if anime_core(anime)[3]: #[3]==is_primary_series
title = AniDB.GetAniDBTitle(AniDB.AniDBTitlesDB.xpath('/animetitles/anime[@aid="{}"]/title'.format(anime.get("anidbid", ""))))[0] #returns [title, main, language_rank]
studio = GetXml(anime, "supplemental-info/studio")
# record the number of entries using the same tvdb id
SaveDict(len(TVDB_collection), mappingList, 'tvdbcount')
if len(TVDB_collection)>1 and title: # Require that there be at least 2 anidb mappings for a collection
Log.Info("[ ] collection: TVDBid '%s' is part of collection: '%s', related_anime_list: %s" % (TVDB_winner, SaveDict([title + ' Collection'], AnimeLists_dict, 'collections'), TVDB_collection))
else: Log.Info("[ ] collection: TVDBid '%s' is not part of any collection" % TVDB_winner)
Expand Down

0 comments on commit 31ab16a

Please sign in to comment.