Compare commits
2 Commits
66a602b06f
...
f0d25549a5
Author | SHA1 | Date | |
---|---|---|---|
f0d25549a5 | |||
cc86f13c13 |
21
LICENSE.md
Normal file
21
LICENSE.md
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 niku
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -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]:
|
||||
...
|
||||
|
Reference in New Issue
Block a user