Skip to content

Commit

Permalink
Add an error message if the moviedb api key is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
zoriya committed Apr 5, 2023
1 parent 2b45421 commit 468b7b3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 7 additions & 0 deletions scanner/providers/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
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
Expand All @@ -22,6 +24,11 @@ def get_all(cls: type[Self], client: ClientSession) -> list[Self]:
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
Expand Down
12 changes: 8 additions & 4 deletions scanner/scanner/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from providers.utils import ProviderError
from .scanner import Scanner
from .monitor import monitor

Expand Down Expand Up @@ -36,7 +37,10 @@ async def main():
*args, key_transformer=jsons.KEY_TRANSFORMER_CAMELCASE, **kwargs
),
) as client:
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)
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)

0 comments on commit 468b7b3

Please sign in to comment.