Add an error message if the moviedb api key is not set

This commit is contained in:
Zoe Roux 2023-04-05 13:34:25 +09:00
parent 0b614ec4b6
commit a3b2b80c1e
2 changed files with 15 additions and 4 deletions

View File

@ -3,6 +3,8 @@ from aiohttp import ClientSession
from abc import abstractmethod, abstractproperty
from typing import Optional, TypeVar
from providers.utils import ProviderError
from .types.episode import Episode, PartialShow
from .types.show import Show
from .types.movie import Movie
@ -22,6 +24,11 @@ class Provider:
if tmdb:
providers.append(TheMovieDatabase(client, tmdb))
if not any(providers):
raise ProviderError(
"No provider configured. You probably forgot to specify an API Key"
)
return providers
@abstractproperty

View File

@ -1,3 +1,4 @@
from providers.utils import ProviderError
from .scanner import Scanner
from .monitor import monitor
@ -36,7 +37,10 @@ async def main():
*args, key_transformer=jsons.KEY_TRANSFORMER_CAMELCASE, **kwargs
),
) as client:
try:
scanner = Scanner(client, languages=languages.split(","), api_key=api_key)
await scanner.scan(path)
logging.info("Scan finished. Starting to monitor...")
await monitor(path, scanner)
except ProviderError as e:
logging.error(e)