Skip to content

Commit

Permalink
Merge pull request #1330 from DIYgod/master
Browse files Browse the repository at this point in the history
[pull] master from diygod:master
  • Loading branch information
pull[bot] authored Mar 27, 2024
2 parents b31734a + 74fddc4 commit 08d9eed
Show file tree
Hide file tree
Showing 33 changed files with 717 additions and 258 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@ jobs:
run: pnpm i
- name: Build assets
run: pnpm build
- name: Build docs
run: pnpm build:docs
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./assets
user_name: 'github-actions[bot]'
user_email: '41898282+github-actions[bot]@users.noreply.github.com'
# prevent deleting build/test-full-routes.json which will break build:docs
keep_files: true
- name: Build docs
run: pnpm build:docs
- name: Checkout docs
uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-test-cont.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
actions: 'add-labels'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ steps.source-run-info.outputs.pullRequestNumber }}
labels: 'Route Test: Failed'
labels: 'Auto: Route Test Failed'

- name: Print Docker container logs
if: (env.TEST_CONTINUE)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
actions: 'add-labels'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
labels: 'Route Test: Failed'
labels: 'Auto: Route Test Failed'

- name: Test Docker image
run: bash scripts/docker/test-docker.sh
Expand Down
7 changes: 4 additions & 3 deletions lib/routes/163/dy2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const route: Route = {
path: '/dy2/:id',
categories: ['new-media'],
example: '/163/dy2/T1555591616739',
parameters: { id: 'id,该网易号主页网址最后一项html的文件名' },
parameters: { id: 'id,该网易号主页网址最后一项 html 的文件名' },
features: {
requireConfig: false,
requirePuppeteer: false,
Expand All @@ -21,7 +21,7 @@ export const route: Route = {
supportScihub: false,
},
name: '网易号(通用)',
maintainers: ['mjysci'],
maintainers: ['mjysci', 'lyqluis'],
handler,
description: `优先使用方法一,若是网易号搜索页面搜不到的小众网易号(文章页面不含\`data-wemediaid\`)则可使用此法。
触发反爬会只抓取到标题,建议自建。`,
Expand All @@ -43,11 +43,12 @@ async function handler(ctx) {
.toArray()
.map((item) => {
item = $(item);
const itemImg = item.find('a.img img');
return {
title: item.find('h4 a').text(),
link: item.find('a').first().attr('href'),
pubDate: timezone(parseDate(item.find('.time').text()), 8),
imgsrc: item.find('a img').attr('src'),
imgsrc: itemImg.attr('src') ?? itemImg.attr('_src'),
};
});

Expand Down
3 changes: 2 additions & 1 deletion lib/routes/163/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ const parseDyArticle = (charset, item, tryGet) =>
}
});

const imgUrl = new URL(item.imgsrc);
item.description = art(path.join(__dirname, 'templates/dy.art'), {
imgsrc: item.imgsrc?.split('?')[0],
imgsrc: imgUrl.searchParams.get('url'),
postBody: $('.post_body').html(),
});

Expand Down
121 changes: 121 additions & 0 deletions lib/routes/3kns/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import { Data, DataItem, Route } from '@/types';
import got from '@/utils/got';
import { getCurrentPath } from '@/utils/helpers';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
import { load } from 'cheerio';
import { Context } from 'hono';
import * as path from 'node:path';
const __dirname = getCurrentPath(import.meta.url);

export const route: Route = {
path: '/:filters?/:order?',
categories: ['game'],
example: '/3kns/category=all&lang=all',
parameters: {
filters: '过滤器,可用参数见下表',
order: '排序,按高分排序:desc;按低分排序:asc',
},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: '3k-Switch游戏库',
maintainers: ['xzzpig'],
handler,
url: 'www.3kns.com/',
description: `游戏类型(category)
| 不限 | 角色扮演 | 动作冒险 | 策略游戏 | 模拟经营 | 即时战略 | 格斗类 | 射击游戏 | 休闲益智 | 体育运动 | 街机格斗 | 无双类 | 其他游戏 | 赛车竞速 |
| ---- | -------- | -------- | -------- | -------- | -------- | ------ | -------- | -------- | -------- | -------- | ------ | -------- | -------- |
| all | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
游戏语言(language)
| 不限 | 中文 | 英语 | 日语 | 其他 | 中文汉化 | 德语 |
| ---- | ---- | ---- | ---- | ---- | -------- | ---- |
| all | 1 | 2 | 3 | 4 | 5 | 6 |
游戏标签(tag)
| 不限 | 热门 | 多人聚会 | 僵尸 | 体感 | 大作 | 音乐 | 三国 | RPG | 格斗 | 闯关 | 横版 | 科幻 | 棋牌 | 运输 | 无双 | 卡通动漫 | 日系 | 养成 | 恐怖 | 运动 | 乙女 | 街机 | 飞行模拟 | 解谜 | 海战 | 战争 | 跑酷 | 即时策略 | 射击 | 经营 | 益智 | 沙盒 | 模拟 | 冒险 | 竞速 | 休闲 | 动作 | 生存 | 独立 | 拼图 | 魔改 xci | 卡牌 | 塔防 |
| ---- | ---- | -------- | ---- | ---- | ---- | ---- | ---- | --- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | -------- | ---- | ---- | ---- | ---- | ---- | ---- | -------- | ---- | ---- | ---- | ---- | -------- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | -------- | ---- | ---- |
| all | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 |
发售时间(pubDate)
| 不限 | 2017 年 | 2018 年 | 2019 年 | 2020 年 | 2021 年 | 2022 年 | 2023 年 | 2024 年 |
| ---- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- |
| all | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
游戏集合(collection)
| 不限 | 舞力全开 | 马里奥 | 生化危机 | 炼金工房 | 最终幻想 | 塞尔达 | 宝可梦 | 勇者斗恶龙 | 模拟器 | 秋之回忆 | 第一方 | 体感健身 | 开放世界 | 儿童乐园 |
| ---- | -------- | ------ | -------- | -------- | -------- | ------ | ------ | ---------- | ------ | -------- | ------ | -------- | -------- | -------- |
| all | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |`,
};

async function handler(ctx: Context): Promise<Data> {
const filters = new URLSearchParams(ctx.req.param('filters'));
const order = ctx.req.param('order');

const category = filters.get('category') ?? 'all';
const language = filters.get('language') ?? 'all';
const tag = filters.get('tag') ?? 'all';
const pubDate = filters.get('pubDate') ?? 'all';
const collection = filters.get('collection') ?? 'all';

const baseUrl = 'https://www.3kns.com/';
const currentUrl = new URL(`${baseUrl}forum.php?mod=forumdisplay&fid=2&filter=sortid&typeid=0&sortid=1&searchsort=1&orderbystr=0`);
currentUrl.searchParams.set('dztgeshi', category);
currentUrl.searchParams.set('dztfenlei', language);
currentUrl.searchParams.set('nex_sg_tags', tag);
currentUrl.searchParams.set('deanbgbs', pubDate);
currentUrl.searchParams.set('nex_sg_stars', collection);
if (order !== undefined) {
currentUrl.searchParams.set('ascdescstr', order);
currentUrl.searchParams.set('orderbystr', 'nex_sg_score');
}

const response = await got(currentUrl);
const $ = load(response.data as any);

const selector = `form .newItem`;
const items: DataItem[] = $(selector)
.toArray()
.map((item) => {
const $item = $(item);
const title = $item.find('.showname a').text().trim();
const category = $item.find('.showtype').text().trim();
const pubDate = ($item.find('.showdate').contents()[0] as any).data.trim();
return {
title,
link: baseUrl + $item.find('.entry-media a').attr('href')!,
pubDate: parseDate(pubDate ?? ''),
category: [category],
description:
art(path.join(__dirname, 'templates/description.art'), {
cover: $item.find('.entry-media img').attr('src')?.trim().replace('.', baseUrl),
title,
tid: $item.find('.jb-chakan').text().trim(),
category,
language: $item.find('.jb-new').text().trim(),
pubDate,
system: $item.find('.jb-youxxx').text().trim(),
score: $item.find('.shownamep').text().trim(),
version: $item.find('.jb-youxbb').text().trim(),
}) ?? '',
};
});

return {
title: $('title').text(),
link: currentUrl.toString(),
allowEmpty: true,
item: items,
};
}
6 changes: 6 additions & 0 deletions lib/routes/3kns/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: '3k-Switch游戏库',
url: 'www.3kns.com',
};
9 changes: 9 additions & 0 deletions lib/routes/3kns/templates/description.art
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<img src="{{ cover }}">
<h1>{{ title }}</h1>
<p>游戏TID:{{ tid }}</p>
<p>类型:{{ category }}</p>
<p>语言:{{ language }}</p>
<p>更新日期:{{ pubDate }}</p>
<p>系统要求:{{ system }}</p>
<p>{{ score }}</p>
<p>游戏版本:{{ version }}</p>
1 change: 0 additions & 1 deletion lib/routes/aeon/category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ async function handler(ctx) {
title: item.node.title,
author: item.node.authors.map((author) => author.displayName).join(', '),
link: `https://aeon.co/${item.node.type.toLowerCase()}s/${item.node.slug}`,
pubDate: item.node.createdAt,
}));

const items = await getData(ctx, list);
Expand Down
1 change: 0 additions & 1 deletion lib/routes/aeon/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ async function handler(ctx) {
const list = data.props.pageProps.articles.map((item) => ({
title: item.title,
link: `https://aeon.co/${binaryType}/${item.slug}`,
pubDate: item.createdAt,
}));

const items = await getData(ctx, list);
Expand Down
3 changes: 3 additions & 0 deletions lib/routes/aeon/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const getData = async (ctx, list) => {

const data = JSON.parse($('script#__NEXT_DATA__').text());
const type = data.props.pageProps.article.type.toLowerCase();

item.pubDate = new Date(data.props.pageProps.article.publishedAt).toUTCString();

if (type === 'video') {
item.description = art(path.join(__dirname, 'templates/video.art'), { article: data.props.pageProps.article });
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/bilibili/dynamic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ async function handler(ctx) {

const response = await got({
method: 'get',
url: `https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history?host_uid=${uid}`,
url: `https://api.vc.bilibili.com/dynamic_svr/v2/dynamic_svr/space_history?host_uid=${uid}`,
headers: {
Referer: `https://space.bilibili.com/${uid}/`,
},
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/bjfu/namespace.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: '北京师范大学',
name: '北京林业大学',
url: 'graduate.bjfu.edu.cn',
};
56 changes: 56 additions & 0 deletions lib/routes/bnu/jwb.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import cache from '@/utils/cache';

export const route: Route = {
path: '/jwb',
categories: ['university'],
example: '/bnu/jwb',
parameters: {},
radar: [
{
source: ['jwb.bnu.edu.cn'],
},
],
name: '教务部(研究生院)',
maintainers: ['ladeng07'],
handler,
url: 'jwb.bnu.edu.cn/tzgg/index.htm',
};

async function handler() {
const link = 'https://jwb.bnu.edu.cn/tzgg/index.htm';
const response = await got(link);
const $ = load(response.data);
const list = $('.article-list .boxlist ul li')
.toArray()
.map((e) => {
e = $(e);
const a = e.find('a');
return {
title: e.find('a span').text(),
link: a.attr('href').startsWith('http') ? a.attr('href') : 'https://jwb.bnu.edu.cn' + a.attr('href').substring(2),
pubDate: parseDate(e.find('span.fr.text-muted').text(), 'YYYY-MM-DD'),
};
});

const out = await Promise.all(
list.map((item) =>
cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
item.author = '北京师范大学教务部';
item.description = $('.contenttxt').html();
return item;
})
)
);

return {
title: '北京师范大学教务部',
link,
description: '北京师范大学教务部最新通知',
item: out,
};
}
Loading

0 comments on commit 08d9eed

Please sign in to comment.