change metadata provider functions

This commit is contained in:
maxDorninger
2025-06-09 21:25:04 +02:00
parent d525231959
commit 7458d71bf6
3 changed files with 17 additions and 6 deletions

View File

@@ -17,6 +17,8 @@ class TmdbConfig(BaseSettings):
TMDB_API_KEY: str | None = None
ENDED_STATUS = {"Ended", "Canceled"}
config = TmdbConfig()
log = logging.getLogger(__name__)
@@ -24,6 +26,9 @@ log = logging.getLogger(__name__)
class TmdbMetadataProvider(AbstractMetadataProvider):
name = "tmdb"
def __init__(self, api_key: str = None):
tmdbsimple.API_KEY = api_key
def download_show_poster_image(self, show: Show) -> bool:
show_metadata = TV(show.external_id).info()
# downloading the poster
@@ -92,6 +97,7 @@ class TmdbMetadataProvider(AbstractMetadataProvider):
year=year,
seasons=season_list,
metadata_provider=self.name,
ended=show_metadata["status"] in ENDED_STATUS,
)
return show
@@ -146,8 +152,6 @@ class TmdbMetadataProvider(AbstractMetadataProvider):
log.warning(f"Error processing search result {result}: {e}")
return formatted_results
def __init__(self, api_key: str = None):
tmdbsimple.API_KEY = api_key
if config.TMDB_API_KEY is not None:

View File

@@ -35,7 +35,9 @@ class TvdbMetadataProvider(AbstractMetadataProvider):
if show_metadata["image"] is not None:
media_manager.metadataProvider.utils.download_poster_image(
storage_path=self.storage_path, poster_url=show_metadata["image"], show=show
storage_path=self.storage_path,
poster_url=show_metadata["image"],
show=show,
)
log.info("Successfully downloaded poster image for show " + show.name)
return True
@@ -76,6 +78,8 @@ class TvdbMetadataProvider(AbstractMetadataProvider):
year = series["year"]
except KeyError:
year = None
# NOTE: the TVDB API is fucking shit and seems to be very poorly documentated, I can't for the life of me
# figure out which statuses this fucking api returns
show = Show(
name=series["name"],
overview=series["overview"],
@@ -83,12 +87,13 @@ class TvdbMetadataProvider(AbstractMetadataProvider):
external_id=series["id"],
metadata_provider=self.name,
seasons=seasons,
ended=False,
)
return show
def search_show(
self, query: str | None = None
self, query: str | None = None
) -> list[MetaDataProviderShowSearchResult]:
if query is None:
results = self.tvdb_client.get_all_series()