diff options
| -rw-r--r-- | bemani/polaris_chord.py | 6 | ||||
| -rw-r--r-- | constants.py | 1 | ||||
| -rw-r--r-- | news_feed.py | 2 |
3 files changed, 7 insertions, 2 deletions
diff --git a/bemani/polaris_chord.py b/bemani/polaris_chord.py index b4c96cd..9bfb57e 100644 --- a/bemani/polaris_chord.py +++ b/bemani/polaris_chord.py @@ -11,12 +11,16 @@ CATEGORY_MAP = { "i_04": "OTHER" } -def parse_polaris_chord_news_site(html: str) -> list[dict]: +def parse_polaris_chord_news_site(html: str, limit: int) -> list[dict]: base_url = "https://eacache.s.konaminet.jp/game/polarischord/pc/" soup = BeautifulSoup(html, 'html.parser') news_list = [] for li in soup.select('li.news'): + # Check if we've reached the limit + if len(news_list) >= limit: + break + raw_type = li.get('data-category') post_type = CATEGORY_MAP.get(raw_type, "OTHER") diff --git a/constants.py b/constants.py index f31a0eb..6125147 100644 --- a/constants.py +++ b/constants.py @@ -6,6 +6,7 @@ SOUND_VOLTEX_EXCEED_GEAR_NEWS_SITE ="https://p.eagate.573.jp/game/sdvx/vi/news/i IIDX_PINKY_CRUSH_NEWS_SITE="https://p.eagate.573.jp/game/2dx/32/info/index.html" # legacy should not be used, eamuse feed is more verbose DDR_WORLD_NEWS_SITE="https://p.eagate.573.jp/game/ddr/ddrworld/info/index.html" POLARIS_CHORD_NEWS_SITE="https://p.eagate.573.jp/game/polarischord/pc/news/news.html" +POLARIS_CHORD_RECENT_NEWS_LIMIT=15 EAMUSE_APP_FEED="https://eam.573.jp/app/web/post/official" EAMUSE_APP_API_ROUTE="https://eam.573.jp/app/web/post/official" diff --git a/news_feed.py b/news_feed.py index 05378ca..1e4021c 100644 --- a/news_feed.py +++ b/news_feed.py @@ -73,7 +73,7 @@ def get_news(news_url: str, version=None) -> list: elif news_url == constants.POLARIS_CHORD_NEWS_SITE: site_data = download_site_as_html(news_url) - news_posts = sorted(polaris_chord.parse_polaris_chord_news_site(site_data), key=lambda x: x['timestamp'], reverse=True) + news_posts = sorted(polaris_chord.parse_polaris_chord_news_site(site_data, constants.POLARIS_CHORD_RECENT_NEWS_LIMIT), key=lambda x: x['timestamp'], reverse=True) news_posts = translate.add_translate_text_to_en(news_posts, iidx.KEY_TERMS_TL) elif news_url == constants.EAMUSE_APP_API_ROUTE: |
