Added mediatracker type
This commit is contained in:
parent
cc86f13c13
commit
f0d25549a5
@ -4,7 +4,7 @@ import typing
|
||||
from al_arr_sync.anilist import AniListClient
|
||||
from al_arr_sync.radarr import RadarrClient
|
||||
from al_arr_sync.sonarr import SonarrClient
|
||||
from al_arr_sync.types import DlAutomator
|
||||
from al_arr_sync.types import DlAutomator, MediaTracker
|
||||
from al_arr_sync.config import load_config
|
||||
|
||||
|
||||
@ -12,10 +12,15 @@ def main(args: typing.Sequence[str]) -> int:
|
||||
cfg_path = args[0] if len(args) > 0 else "./config.ini"
|
||||
cfg = load_config(cfg_path)
|
||||
|
||||
al = AniListClient()
|
||||
al: MediaTracker = AniListClient()
|
||||
sonarr: DlAutomator = SonarrClient.from_config(cfg)
|
||||
radarr: DlAutomator = RadarrClient.from_config(cfg)
|
||||
|
||||
download_clients: typing.Dict[str, DlAutomator] = {
|
||||
"TV": sonarr,
|
||||
"MOVIE": radarr,
|
||||
}
|
||||
|
||||
username = cfg["anilist"]["username"]
|
||||
media = al.currently_watching(username)
|
||||
|
||||
@ -23,12 +28,9 @@ def main(args: typing.Sequence[str]) -> int:
|
||||
media_format = entry["media"]["format"]
|
||||
show_name = entry["media"]["title"]["english"]
|
||||
|
||||
client: DlAutomator
|
||||
if media_format == "TV":
|
||||
client = sonarr
|
||||
elif media_format == "MOVIE":
|
||||
client = radarr
|
||||
else:
|
||||
client: typing.Optional[DlAutomator] = download_clients.get(
|
||||
media_format)
|
||||
if client is None:
|
||||
continue
|
||||
|
||||
results = client.lookup_series(show_name)
|
||||
|
@ -4,8 +4,15 @@ AnyDict = typing.Dict[typing.Any, typing.Any]
|
||||
|
||||
|
||||
class DlAutomator(typing.Protocol):
|
||||
|
||||
def lookup_series(self, query: str) -> typing.List[AnyDict]:
|
||||
...
|
||||
|
||||
def add_series(self, *series: AnyDict):
|
||||
...
|
||||
|
||||
|
||||
class MediaTracker(typing.Protocol):
|
||||
|
||||
def currently_watching(self, username: str) -> typing.List[AnyDict]:
|
||||
...
|
||||
|
Loading…
x
Reference in New Issue
Block a user