|
|
|
@ -119,17 +119,16 @@ class Convert:
|
|
|
|
|
imdb_id = None
|
|
|
|
|
try:
|
|
|
|
|
imdb_id = self.config.TMDb.convert_from(tmdb_id, "imdb_id", is_movie)
|
|
|
|
|
except Failed:
|
|
|
|
|
if self.config.Trakt:
|
|
|
|
|
try:
|
|
|
|
|
imdb_id = self.config.Trakt.convert(tmdb_id, "tmdb", "imdb", "movie" if is_movie else "show")
|
|
|
|
|
except Failed:
|
|
|
|
|
pass
|
|
|
|
|
if fail and imdb_id is None:
|
|
|
|
|
raise Failed(f"Convert Error: No IMDb ID Found for TMDb ID: {tmdb_id}")
|
|
|
|
|
if self.config.Cache and imdb_id:
|
|
|
|
|
if imdb_id:
|
|
|
|
|
if self.config.Cache:
|
|
|
|
|
self.config.Cache.update_imdb_to_tmdb_map(media_type, expired, imdb_id, tmdb_id)
|
|
|
|
|
return imdb_id
|
|
|
|
|
elif fail:
|
|
|
|
|
raise Failed(f"Convert Error: No IMDb ID Found for TMDb ID: {tmdb_id}")
|
|
|
|
|
else:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
def imdb_to_tmdb(self, imdb_id, is_movie=True, fail=False):
|
|
|
|
|
media_type = "movie" if is_movie else "show"
|
|
|
|
@ -141,17 +140,16 @@ class Convert:
|
|
|
|
|
tmdb_id = None
|
|
|
|
|
try:
|
|
|
|
|
tmdb_id = self.config.TMDb.convert_to(imdb_id, "imdb_id", is_movie)
|
|
|
|
|
except Failed:
|
|
|
|
|
if self.config.Trakt:
|
|
|
|
|
try:
|
|
|
|
|
tmdb_id = self.config.Trakt.convert(imdb_id, "imdb", "tmdb", media_type)
|
|
|
|
|
except Failed:
|
|
|
|
|
pass
|
|
|
|
|
if fail and tmdb_id is None:
|
|
|
|
|
raise Failed(f"Convert Error: No TMDb ID Found for IMDb ID: {imdb_id}")
|
|
|
|
|
if self.config.Cache and tmdb_id:
|
|
|
|
|
if tmdb_id:
|
|
|
|
|
if self.config.Cache:
|
|
|
|
|
self.config.Cache.update_imdb_to_tmdb_map(media_type, expired, imdb_id, tmdb_id)
|
|
|
|
|
return tmdb_id
|
|
|
|
|
elif fail:
|
|
|
|
|
raise Failed(f"Convert Error: No TMDb ID Found for IMDb ID: {imdb_id}")
|
|
|
|
|
else:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
def tmdb_to_tvdb(self, tmdb_id, fail=False):
|
|
|
|
|
expired = False
|
|
|
|
@ -161,18 +159,17 @@ class Convert:
|
|
|
|
|
return cache_id
|
|
|
|
|
tvdb_id = None
|
|
|
|
|
try:
|
|
|
|
|
tvdb_id = int(self.config.TMDb.convert_from(tmdb_id, "tvdb_id", False))
|
|
|
|
|
except Failed:
|
|
|
|
|
if self.config.Trakt:
|
|
|
|
|
try:
|
|
|
|
|
tvdb_id = int(self.config.Trakt.convert(tmdb_id, "tmdb", "tvdb", "show"))
|
|
|
|
|
tvdb_id = self.config.TMDb.convert_from(tmdb_id, "tvdb_id", False)
|
|
|
|
|
except Failed:
|
|
|
|
|
pass
|
|
|
|
|
if fail and tvdb_id is None:
|
|
|
|
|
raise Failed(f"Convert Error: No TVDb ID Found for TMDb ID: {tmdb_id}")
|
|
|
|
|
if self.config.Cache and tvdb_id:
|
|
|
|
|
if tvdb_id:
|
|
|
|
|
if self.config.Cache:
|
|
|
|
|
self.config.Cache.update_tmdb_to_tvdb_map(expired, tmdb_id, tvdb_id)
|
|
|
|
|
return tvdb_id
|
|
|
|
|
elif fail:
|
|
|
|
|
raise Failed(f"Convert Error: No TVDb ID Found for TMDb ID: {tmdb_id}")
|
|
|
|
|
else:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
def tvdb_to_tmdb(self, tvdb_id, fail=False):
|
|
|
|
|
expired = False
|
|
|
|
@ -183,17 +180,16 @@ class Convert:
|
|
|
|
|
tmdb_id = None
|
|
|
|
|
try:
|
|
|
|
|
tmdb_id = self.config.TMDb.convert_to(tvdb_id, "tvdb_id", False)
|
|
|
|
|
except Failed:
|
|
|
|
|
if self.config.Trakt:
|
|
|
|
|
try:
|
|
|
|
|
tmdb_id = self.config.Trakt.convert(tvdb_id, "tvdb", "tmdb", "show")
|
|
|
|
|
except Failed:
|
|
|
|
|
pass
|
|
|
|
|
if fail and tmdb_id is None:
|
|
|
|
|
raise Failed(f"Convert Error: No TMDb ID Found for TVDb ID: {tvdb_id}")
|
|
|
|
|
if self.config.Cache and tmdb_id:
|
|
|
|
|
if tmdb_id:
|
|
|
|
|
if self.config.Cache:
|
|
|
|
|
self.config.Cache.update_tmdb_to_tvdb_map(expired, tmdb_id, tvdb_id)
|
|
|
|
|
return tmdb_id
|
|
|
|
|
elif fail:
|
|
|
|
|
raise Failed(f"Convert Error: No TMDb ID Found for TVDb ID: {tvdb_id}")
|
|
|
|
|
else:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
def tvdb_to_imdb(self, tvdb_id, fail=False):
|
|
|
|
|
expired = False
|
|
|
|
@ -204,17 +200,16 @@ class Convert:
|
|
|
|
|
imdb_id = None
|
|
|
|
|
try:
|
|
|
|
|
imdb_id = self.tmdb_to_imdb(self.tvdb_to_tmdb(tvdb_id, fail=True), is_movie=False, fail=True)
|
|
|
|
|
except Failed:
|
|
|
|
|
if self.config.Trakt:
|
|
|
|
|
try:
|
|
|
|
|
imdb_id = self.config.Trakt.convert(tvdb_id, "tvdb", "imdb", "show")
|
|
|
|
|
except Failed:
|
|
|
|
|
pass
|
|
|
|
|
if fail and imdb_id is None:
|
|
|
|
|
raise Failed(f"Convert Error: No IMDb ID Found for TVDb ID: {tvdb_id}")
|
|
|
|
|
if self.config.Cache and imdb_id:
|
|
|
|
|
if imdb_id:
|
|
|
|
|
if self.config.Cache:
|
|
|
|
|
self.config.Cache.update_imdb_to_tvdb_map(expired, imdb_id, tvdb_id)
|
|
|
|
|
return imdb_id
|
|
|
|
|
elif fail:
|
|
|
|
|
raise Failed(f"Convert Error: No IMDb ID Found for TVDb ID: {tvdb_id}")
|
|
|
|
|
else:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
def imdb_to_tvdb(self, imdb_id, fail=False):
|
|
|
|
|
expired = False
|
|
|
|
@ -225,17 +220,16 @@ class Convert:
|
|
|
|
|
tvdb_id = None
|
|
|
|
|
try:
|
|
|
|
|
tvdb_id = self.tmdb_to_tvdb(self.imdb_to_tmdb(imdb_id, is_movie=False, fail=True), fail=True)
|
|
|
|
|
except Failed:
|
|
|
|
|
if self.config.Trakt:
|
|
|
|
|
try:
|
|
|
|
|
tvdb_id = self.config.Trakt.convert(imdb_id, "imdb", "tvdb", "show")
|
|
|
|
|
except Failed:
|
|
|
|
|
pass
|
|
|
|
|
if fail and tvdb_id is None:
|
|
|
|
|
raise Failed(f"Convert Error: No TVDb ID Found for IMDb ID: {imdb_id}")
|
|
|
|
|
if self.config.Cache and tvdb_id:
|
|
|
|
|
if tvdb_id:
|
|
|
|
|
if self.config.Cache:
|
|
|
|
|
self.config.Cache.update_imdb_to_tvdb_map(expired, imdb_id, tvdb_id)
|
|
|
|
|
return tvdb_id
|
|
|
|
|
elif fail:
|
|
|
|
|
raise Failed(f"Convert Error: No TVDb ID Found for IMDb ID: {imdb_id}")
|
|
|
|
|
else:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
def get_id(self, item, library):
|
|
|
|
|
expired = None
|
|
|
|
|