Force TMDB ID to int on guid map and Trakt lookups

This commit is contained in:
mza921 2020-12-15 11:04:19 -08:00
parent 51e85013e9
commit 16cdd00aa1
2 changed files with 6 additions and 3 deletions

View file

@ -118,7 +118,7 @@ def get_map(config_path, plex):
elif imdb_id:
key_id = imdb_id
print(adjust_space(current_length, "| Cache | {} | {:<46} | {:<6} | {}".format("^" if update == True else "+", item.guid, key_id, item.title)))
update_guid_map(config_path, item.guid, tmdb_id=key_id)
update_guid_map(config_path, item.guid, imdb_id=key_id)
elif item_type == 'imdb' and plex.library_type == "movie":
key_id = None
if TMDB.valid and key_id is None:
@ -433,7 +433,10 @@ def query_guid_map(config_path, key, column):
cursor.execute("SELECT * FROM guids WHERE plex_guid = ?", (key, ))
row = cursor.fetchone()
if row:
return row[column]
if row[column] and column == 'tmdb_id':
return int(row[column])
else:
return row[column]
def update_guid_map(config_path, plex_guid, **kwargs):
config_dir = os.path.dirname(config_path)

View file

@ -48,7 +48,7 @@ def trakt_get_movies(config_path, plex, plex_map, data, method):
trakt_url = trakt_url[:-1]
trakt_list_path = urlparse(trakt_url).path
trakt_list_items = trakt.Trakt[trakt_list_path].items()
title_ids = [str(m.get_key('tmdb')) for m in trakt_list_items if isinstance(m, trakt.objects.movie.Movie)]
title_ids = [int(m.get_key('tmdb')) for m in trakt_list_items if isinstance(m, trakt.objects.movie.Movie)]
print("| {} Movies found on Trakt".format(len(title_ids)))
matched = []