feat(route): 添加Lovelive官网Schedule页的路由 (#11128)

* 添加Lovelive官网Schedule页的路由

* fix pubDate
This commit is contained in:
Axojhf
2022-10-31 21:13:01 +08:00
committed by GitHub
parent 347de8b39c
commit e754ff764e
7 changed files with 118 additions and 10 deletions
+22 -3
View File
@@ -375,9 +375,9 @@ Sources
<Route author="axojhf" example="/lovelive-anime/topics/otonokizaka" path="/lovelive-anime/topics/:abbr/:category?/:option?" :paramsDesc="['Love Live系列子企划在官网的路径,详见下表', '官网列出的Topics分类,`category` 为 `detail` 时抓取全文,其他分类详见下表', '`option` 为 `detail` 时抓取全文']" radar="1">
| 子企划名(非全称) | Lovelive! | Lovelive! Sunshine!! | Lovelive! Nijigasaki High School Idol Club | Lovelive! Superstar!! |
| --------- | ----------- | -------------------- | ------------------------------------------ | --------------------- |
| `abbr`参数 | otonokizaka | uranohoshi | nijigasaki | yuigaoka |
| 子企划名(非全称) | Lovelive! | Lovelive! Sunshine!! | Lovelive! Nijigasaki High School Idol Club | Lovelive! Superstar!! | 幻日のヨハネ | ラブライブ!スクールアイドルミュージカル |
| --------- | ----------- | -------------------- | ------------------------------------------ | --------------------- | ------ | -------------------- |
| `abbr`参数 | otonokizaka | uranohoshi | nijigasaki | yuigaoka | yohane | musical |
| 分类名 | 全てのニュース | 音楽商品 | アニメ映像商品 | キャスト映像商品 | 劇場 | アニメ放送 / 配信 | キャスト配信 / ラジオ | ライブ / イベント | ブック | グッズ | ゲーム | メディア | ご当地情報 | その他 | キャンペーン |
| ------------ | ------------ | ----- | ----------- | ---------- | ------- | ---------- | ------------ | ---------- | ----- | ----- | ---- | ----- | ----- | ----- | -------- |
@@ -385,6 +385,25 @@ Sources
</Route>
### Love Live 官网 Schedule
<Route author="axojhf" example="/lovelive-anime/schedules" path="/schedules/:serie?/:category?" :paramsDesc="['Love Live系列子企划简称,详见下表', '官网列出的分类,详见下表']" radar="1">
::: tip 请注意!!!
该路由获取的时间及其他信息以官网公告为准!<br>
该 RSS 路由没有经过严格的测试,提供的信息不能保证准确性!
:::
| 子企划名(非全称) | 全シリーズ | Lovelive! | Lovelive! Sunshine!! | Lovelive! Nijigasaki High School Idol Club | Lovelive! Superstar!! | ラブライブ!スクールアイドルミュージカル |
| --------- | ------------------ | ---------- | -------------------- | ------------------------------------------ | --------------------- | -------------------- |
| `serie`参数 | <u>*无参数*</u>或`all` | `lovelive` | `sunshine` | `nijigasaki` | `superstar` | `musical` |
| 分类名 | 全て | ライブ | イベント | 生配信 |
| ------------ | ------------------ | ------ | ------- | --------- |
| `category`参数 | <u>*无参数*</u>或`all` | `live` | `event` | `haishin` |
</Route>
## Mox.moe
### 首頁
+25 -6
View File
@@ -84,14 +84,33 @@ When `posts` is selected as the value of the parameter **source**, the parameter
<RouteEn author="axojhf" example="/lovelive-anime/topics/otonokizaka" path="/lovelive-anime/topics/:abbr/:category?/:option?" :paramsDesc="['The path to the Love Live series of sub-projects on the official website is detailed in the table below', 'The official website lists the Topics category, `category` is `detail` when crawling the full text, other categories see the following table for details', 'Crawl full text when `option` is `detail`.']" radar="1">
| Sub-project name (not full name) | Lovelive! | Lovelive! Sunshine!! | Lovelive! Nijigasaki High School Idol Club | Lovelive! Superstar!! |
| -------------------------------- | ----------- | -------------------- | ------------------------------------------ | --------------------- |
| `abbr`parameter | otonokizaka | uranohoshi | nijigasaki | yuigaoka |
| Sub-project Name (not full name) | Lovelive! | Lovelive! Sunshine!! | Lovelive! Nijigasaki High School Idol Club | Lovelive! Superstar!! | 幻日のヨハネ | ラブライブ!スクールアイドルミュージカル |
|----------------------------------|-------------|----------------------|--------------------------------------------|-----------------------|--------|----------------------|
| `abbr`parameter | otonokizaka | uranohoshi | nijigasaki | yuigaoka | yohane | musical |
| category name | 全てのニュース | 音楽商品 | アニメ映像商品 | キャスト映像商品 | 劇場 | アニメ放送/配信 | キャスト配信/ラジオ | ライブ/イベント | ブック | グッズ | ゲーム | メディア | ご当地情報 | その他 | キャンペーン |
| -------------- | --------------- | -------- | -------------- | ---------------- | ------- | --------------- | ------------------- | --------------- | ------ | ------ | ------ | -------- | ---------- | ------ | ------------ |
| `category`parameter | <u>*No parameter*</u> | music | anime_movie | cast_movie | theater | onair | radio | event | books | goods | game | media | local | other | campaign |
| Category Name | 全てのニュース | 音楽商品 | アニメ映像商品 | キャスト映像商品 | 劇場 | アニメ放送/配信 | キャスト配信/ラジオ | ライブ/イベント | ブック | グッズ | ゲーム | メディア | ご当地情報 | その他 | キャンペーン |
|---------------------|-----------------------|-------|-------------|------------|---------|----------|------------|----------|-------|-------|------|-------|-------|-------|----------|
| `category`parameter | <u>*No parameter*</u> | music | anime_movie | cast_movie | theater | onair | radio | event | books | goods | game | media | local | other | campaign |
</RouteEn>
### Love Live Official Website Schedule
<RouteEn author="axojhf" example="/lovelive-anime/schedules" path="/schedules/:serie?/:category?" :paramsDesc="['Love Live! Series sub-projects abbreviation, see the following table', 'The official website lists the categories, see the following table for details']" radar="1">
::: tip Please note!
The schedule and other information obtained by this route is subject to the official website announcement!
The RSS routing has not been rigorously tested and the information provided cannot be guaranteed accurate!
:::
| Sub-project Name (not full name) | 全シリーズ | Lovelive! | Lovelive! Sunshine!! | Lovelive! Nijigasaki High School Idol Club | Lovelive! Superstar!! | ラブライブ!スクールアイドルミュージカル |
|----------------------------------|------------------------------|------------|----------------------|--------------------------------------------|-----------------------|----------------------|
| `serie`parameter | <u>*No parameter*</u>or`all` | `lovelive` | `sunshine` | `nijigasaki` | `superstar` | `musical` |
| Category Name | 全て | ライブ | イベント | 生配信 |
|---------------------|------------------------------|--------|---------|-----------|
| `category`parameter | <u>*No parameter*</u>or`all` | `live` | `event` | `haishin` |
</RouteEn>
+2 -1
View File
@@ -1,4 +1,5 @@
module.exports = {
'/news/:option?': ['axojhf'],
'/topics/:abbr/:category?': ['axojhf'],
'/topics/:abbr/:category?/:option?': ['axojhf'],
'/schedules/:serie/:category?': ['axojhf'],
};
+9
View File
@@ -17,6 +17,15 @@ module.exports = {
return `/lovelive-anime/topics/${params.abbr}/${null !== cat && cat.length === 2 ? cat[1] : ''}`;
},
},
{
title: 'Schedule',
docs: 'https://docs.rsshub.app/anime.html#lovelive-anime-love-live-guan-wang-schedule',
source: ['/schedule/'],
target: (params, url) => {
const cat = url.match(/\?series=(.*)&category=(.*)/);
return `/lovelive-anime/schedules/${null !== cat && cat.length >= 2 ? cat[1] : ''}/${null !== cat && cat.length === 3 ? cat[2] : ''}`;
},
},
],
},
};
+1
View File
@@ -1,4 +1,5 @@
module.exports = (router) => {
router.get('/news/:option?', require('./news'));
router.get('/topics/:abbr/:category?/:option?', require('./topics'));
router.get('/schedules/:serie?/:category?', require('./schedules'));
};
+56
View File
@@ -0,0 +1,56 @@
const got = require('@/utils/got');
const path = require('path');
const { art } = require('@/utils/render');
const renderDescription = (desc) => art(path.join(__dirname, 'templates/scheduleDesc.art'), desc);
const dayjs = require('dayjs');
const utc = require('dayjs/plugin/utc');
const timezone = require('dayjs/plugin/timezone');
module.exports = async (ctx) => {
dayjs.extend(utc);
dayjs.extend(timezone);
const serie = ctx.params.serie;
const category = ctx.params.category;
const rootUrl = `https://www.lovelive-anime.jp/common/api/calendar_list.php`;
const nowTime = dayjs();
const dataPara = {
year: nowTime.year(),
month: nowTime.format('MM'),
};
if (serie && 'all' !== serie) {
dataPara.series = [serie];
}
if (category && 'all' !== category) {
dataPara.category = [category];
}
const response = await got(`${rootUrl}?site=jp&ip=lovelive&data=${JSON.stringify(dataPara)}`);
const items = response.data.data.schedule_list.map((item) => {
const link = item.url.select_url;
const title = item.title;
const category = item.categories.name;
const eventStartDate = dayjs.unix(item.event_startdate).tz('Asia/Tokyo').format('YYYY-MM-DD HH:mm:ss JST');
const eventEndDate = dayjs.unix(item.event_enddate).tz('Asia/Tokyo').format('YYYY-MM-DD HH:mm:ss JST');
return {
link,
pubDate: item.start_endflg ? dayjs.unix(item.event_enddate).tz('Asia/Tokyo') : dayjs.unix(item.event_startdate).tz('Asia/Tokyo'),
title,
category,
description: renderDescription({
title,
desc: item.event_dspdate,
startTime: eventStartDate,
endTime: eventEndDate,
}),
};
});
ctx.state.data = {
title: `${category} - ${serie} - Love Live Official Website Schedule`,
link: 'https://www.lovelive-anime.jp/schedule/',
item: items,
description:
'The schedule date and other information shall be subject to the announcement on the official website. The RSS route has not been strictly tested, and the captured information cannot be guaranteed to be correct.',
};
};
@@ -0,0 +1,3 @@
<h1>{{title}}</h1><br>
<b>{{startTime}}</b>&nbsp;&nbsp;&nbsp;~&nbsp;&nbsp;&nbsp;<b>{{endTime}}</b><br><br>
{{desc}}