From 64279b2eca561cca2a996eef3fb627c728284c07 Mon Sep 17 00:00:00 2001 From: miteruzo Date: Sun, 29 Dec 2024 16:49:45 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=AD=E3=83=AA=E7=95=AA=E7=A5=9D=E3=81=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nico.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/nico.py b/nico.py index 4fd8a28..419438a 100644 --- a/nico.py +++ b/nico.py @@ -29,7 +29,8 @@ KIRIBAN_VIEWS_COUNTS: list[int] = sorted ({ *range (1_000, 10_000, 1_000), *range (10_000, 1_000_001, 10_000), 194, 245, 510, 810, 114_514, 1_940, 2_450, 5_100, 19_400, 24_500, 51_000, 93_194, 2_424, 242_424, 1_919, - 4_545, 194_245, 245_194, 510_245 }) + 4_545, 194_245, 245_194, 510_245 }, + reverse = True) class VideoInfo (TypedDict): contentId: str @@ -134,17 +135,19 @@ def get_kiriban_list ( .max ('fetched_at'))) for kiriban_views_count in KIRIBAN_VIEWS_COUNTS: - targets = ({ vh.video.code for vh in (VideoHistory - .where ('fetched_at', latest_fetched_at) - .where ('views_count', '>=', kiriban_views_count) - .get ()) } - - { vh.video.code for vh in (VideoHistory - .where ('fetched_at', previous_fetched_at) - .where ('views_count', '>=', kiriban_views_count) - .get ()) }) + targets = { vh.video.code for vh in (VideoHistory + .where ('fetched_at', latest_fetched_at) + .where ('views_count', '>=', kiriban_views_count) + .get ()) } for code in targets: if code in [kiriban[1]['contentId'] for kiriban in kiriban_list]: continue + previous_views_count = cast (int, (VideoHistory + .where ('code', code) + .where ('fetched_at', '<', latest_fetched_at) + .max ('views_count'))) + if previous_views_count >= kiriban_views_count: + continue video_info = get_video_info (code) if video_info is not None: kiriban_list.append ((kiriban_views_count, video_info,