diff options
| author | Fuwn <[email protected]> | 2025-07-07 01:27:36 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-07-07 01:27:36 -0700 |
| commit | 082fa52715bf1a4e70d249cbff5279e66745c168 (patch) | |
| tree | e8064fa639ff3306c39e2c11774d699cb2e06d9c /src | |
| parent | feat(schedule): Add source flag (diff) | |
| download | oguri-082fa52715bf1a4e70d249cbff5279e66745c168.tar.xz oguri-082fa52715bf1a4e70d249cbff5279e66745c168.zip | |
feat(schedule): Add month and year flags
Diffstat (limited to 'src')
| -rw-r--r-- | src/oguri/cli.py | 6 | ||||
| -rw-r--r-- | src/oguri/schedule.py | 20 |
2 files changed, 21 insertions, 5 deletions
diff --git a/src/oguri/cli.py b/src/oguri/cli.py index 6aa6cc9..d34dbb3 100644 --- a/src/oguri/cli.py +++ b/src/oguri/cli.py @@ -55,7 +55,9 @@ def cli(): default=["ORIGINAL", "MANGA", "LIGHT_NOVEL", "VISUAL_NOVEL", "VIDEO_GAME", "OTHER"], help="Filter by source. Can be used multiple times.", ) -def schedule(day, reverse, exact, first, sort_by, countries, episode, formats, sources): [email protected]("--year", type=int, help="Filter by airing year.") [email protected]("--month", type=int, help="Filter by airing month (1-12).") +def schedule(day, reverse, exact, first, sort_by, countries, episode, formats, sources, year, month): """ Shows the airing schedule for a given day. @@ -87,6 +89,8 @@ def schedule(day, reverse, exact, first, sort_by, countries, episode, formats, s episode, formats, sources, + year, + month, ) ) diff --git a/src/oguri/schedule.py b/src/oguri/schedule.py index 7a67df4..ba3be64 100644 --- a/src/oguri/schedule.py +++ b/src/oguri/schedule.py @@ -28,12 +28,24 @@ async def show_schedule( "VIDEO_GAME", "OTHER", ], + year: int | None = None, + month: int | None = None, ): client = Client(url="https://graphql.anilist.co") - start_of_day = datetime.now().replace( - hour=0, minute=0, second=0, microsecond=0 - ) + timedelta(days=days_offset) - end_of_day = start_of_day.replace(hour=23, minute=59, second=59, microsecond=999999) + if year and month: + start_of_day = datetime(year, month, 1).replace( + hour=0, minute=0, second=0, microsecond=0 + ) + # Calculate the last day of the month + if month == 12: + end_of_day = datetime(year + 1, 1, 1) - timedelta(microseconds=1) + else: + end_of_day = datetime(year, month + 1, 1) - timedelta(microseconds=1) + else: + start_of_day = datetime.now().replace( + hour=0, minute=0, second=0, microsecond=0 + ) + timedelta(days=days_offset) + end_of_day = start_of_day.replace(hour=23, minute=59, second=59, microsecond=999999) airing_schedules_query = Query.page().fields( PageFields.airing_schedules( airing_at_greater=int(start_of_day.timestamp()), |