aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-07-07 01:35:44 -0700
committerFuwn <[email protected]>2025-07-07 01:35:44 -0700
commit6cbf32a9f8dd1fbac5c090d35c3e32b04515f434 (patch)
tree50f2b2c63ec7c7cbd9854115799c4a446d9f0a8a /src
parentrefactor: Move option defaults to module (diff)
downloadoguri-6cbf32a9f8dd1fbac5c090d35c3e32b04515f434.tar.xz
oguri-6cbf32a9f8dd1fbac5c090d35c3e32b04515f434.zip
refactor: Move option defaults to module
Diffstat (limited to 'src')
-rw-r--r--src/oguri/cli.py65
-rw-r--r--src/oguri/schedule.py36
2 files changed, 14 insertions, 87 deletions
diff --git a/src/oguri/cli.py b/src/oguri/cli.py
index b8aa41a..3575c67 100644
--- a/src/oguri/cli.py
+++ b/src/oguri/cli.py
@@ -2,6 +2,7 @@ import asyncio
import click
from click_aliases import ClickAliasedGroup
from . import schedule as schedule_logic
+from . import constants
@click.group(cls=ClickAliasedGroup)
@@ -29,8 +30,8 @@ def cli():
"--country",
"countries",
multiple=True,
- type=click.Choice(["JP", "KR", "CN"], case_sensitive=False),
- default=["JP", "KR", "CN"],
+ type=click.Choice(constants.COUNTRIES, case_sensitive=False),
+ default=constants.COUNTRIES,
help="Filter by country of origin. Can be used multiple times. Not an exhaustive list.",
)
@click.option("--episode", type=int, help="Filter by episode number.")
@@ -38,21 +39,16 @@ def cli():
"--format",
"formats",
multiple=True,
- type=click.Choice(
- ["TV", "TV_SHORT", "MOVIE", "SPECIAL", "OVA"], case_sensitive=False
- ),
- default=["TV", "TV_SHORT", "MOVIE", "SPECIAL", "OVA"],
+ type=click.Choice(constants.FORMATS, case_sensitive=False),
+ default=constants.FORMATS,
help="Filter by format. Can be used multiple times.",
)
@click.option(
"--source",
"sources",
multiple=True,
- type=click.Choice(
- ["ORIGINAL", "MANGA", "LIGHT_NOVEL", "VISUAL_NOVEL", "VIDEO_GAME", "OTHER"],
- case_sensitive=False,
- ),
- default=["ORIGINAL", "MANGA", "LIGHT_NOVEL", "VISUAL_NOVEL", "VIDEO_GAME", "OTHER"],
+ type=click.Choice(constants.SOURCES, case_sensitive=False),
+ default=constants.SOURCES,
help="Filter by source. Can be used multiple times.",
)
@click.option("--year", type=int, help="Filter by airing year.")
@@ -61,51 +57,8 @@ def cli():
"--genre",
"genres",
multiple=True,
- type=click.Choice(
- [
- "Action",
- "Adventure",
- "Comedy",
- "Drama",
- "Ecchi",
- "Fantasy",
- "Hentai",
- "Horror",
- "Mahou Shoujo",
- "Mecha",
- "Music",
- "Mystery",
- "Psychological",
- "Romance",
- "Sci-Fi",
- "Slice of Life",
- "Sports",
- "Supernatural",
- "Thriller",
- ],
- case_sensitive=False,
- ),
- default=[
- "Action",
- "Adventure",
- "Comedy",
- "Drama",
- "Ecchi",
- "Fantasy",
- "Hentai",
- "Horror",
- "Mahou Shoujo",
- "Mecha",
- "Music",
- "Mystery",
- "Psychological",
- "Romance",
- "Sci-Fi",
- "Slice of Life",
- "Sports",
- "Supernatural",
- "Thriller",
- ],
+ type=click.Choice(constants.GENRES, case_sensitive=False),
+ default=constants.GENRES,
help="Filter by genre. Can be used multiple times.",
)
def schedule(
diff --git a/src/oguri/schedule.py b/src/oguri/schedule.py
index 35819cd..b036f33 100644
--- a/src/oguri/schedule.py
+++ b/src/oguri/schedule.py
@@ -9,6 +9,7 @@ from anilist_client.custom_fields import (
PageFields,
)
from anilist_client.custom_queries import Query
+from . import constants
async def show_schedule(
@@ -17,40 +18,13 @@ async def show_schedule(
exact_time: bool = False,
first_episode_only: bool = False,
sort_by: str = "time",
- countries: list[str] = ["JP", "KR", "CN"],
+ countries: list[str] = constants.COUNTRIES,
episode: int | None = None,
- formats: list[str] = ["TV", "TV_SHORT", "MOVIE", "SPECIAL", "OVA"],
- sources: list[str] = [
- "ORIGINAL",
- "MANGA",
- "LIGHT_NOVEL",
- "VISUAL_NOVEL",
- "VIDEO_GAME",
- "OTHER",
- ],
+ formats: list[str] = constants.FORMATS,
+ sources: list[str] = constants.SOURCES,
year: int | None = None,
month: int | None = None,
- genres: list[str] = [
- "Action",
- "Adventure",
- "Comedy",
- "Drama",
- "Ecchi",
- "Fantasy",
- "Hentai",
- "Horror",
- "Mahou Shoujo",
- "Mecha",
- "Music",
- "Mystery",
- "Psychological",
- "Romance",
- "Sci-Fi",
- "Slice of Life",
- "Sports",
- "Supernatural",
- "Thriller",
- ],
+ genres: list[str] = constants.GENRES,
):
client = Client(url="https://graphql.anilist.co")
now = datetime.now()