Skip to content

Commit

Permalink
Merge pull request #2046 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 Jan 22, 2025
2 parents efa2328 + 6b3af0b commit 0d8d8ad
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 27 deletions.
4 changes: 2 additions & 2 deletions lib/routes/bilibili/user-collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const route: Route = {
supportScihub: false,
},
name: 'UP äø»é¢‘道ēš„合集',
maintainers: ['shininome'],
maintainers: ['shininome', 'cscnk52'],
handler,
};

Expand All @@ -42,7 +42,7 @@ async function handler(ctx) {

const link = `https://space.bilibili.com/${uid}/channel/collectiondetail?sid=${sid}`;
const [userName, face] = await cache.getUsernameAndFaceFromUID(uid);
const host = `https://api.bilibili.com/x/polymer/space/seasons_archives_list?mid=${uid}&season_id=${sid}&sort_reverse=${sortReverse}&page_num=${page}&page_size=${limit}`;
const host = `https://api.bilibili.com/x/polymer/web-space/seasons_archives_list?mid=${uid}&season_id=${sid}&sort_reverse=${sortReverse}&page_num=${page}&page_size=${limit}`;

const response = await got(host, {
headers: {
Expand Down
26 changes: 21 additions & 5 deletions lib/routes/hrbust/news.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ export const route: Route = {
handler,
example: '/hrbust/news',
parameters: { category: 'ꠏē›®ę ‡čƆļ¼Œé»˜č®¤äøŗ lgywļ¼ˆē†å·„要闻ļ¼‰' },
description: `| ē†å·„要闻 | ę–°é—»åƼčÆ» | ē»¼åˆę–°é—» | ę•™å­¦ē§‘ē ” | 院处åŠØꀁ | å­¦ęœÆē§‘创 | äŗ¤ęµåˆä½œ | ꋛē”Ÿå°±äøš | 党å»ŗꀝę”æ | åœØēŗæę’­ę”¾ | ē†å·„ꠔꊄ | åŖ’体ē†å·„ | č®²åŗ§č®ŗ坛 | äŗŗꉍꋛ聘 |
|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|
| lgyw | xwdd | zhenew | jxky | ycdt | xskc | jlhz | zsjy | djsz | zxbf | lgxb | mtlg | jzlt | rczp |`,
description: `| ē†å·„要闻 | ę–°é—»åƼčÆ» | å›¾ę–‡ęŠ„é“ | ē»¼åˆę–°é—» | ę•™å­¦ē§‘ē ” | 院处åŠØꀁ | å­¦ęœÆē§‘创 | äŗ¤ęµåˆä½œ | å­¦ē”Ÿå¤©åœ° | ꋛē”Ÿå°±äøš | 党å»ŗꀝę”æ | åœØēŗæę’­ę”¾ | ē†å·„äŗŗē‰© | ē†å·„ꠔꊄ | åŖ’体ē†å·„ | č®²åŗ§č®ŗ坛 | äŗŗꉍꋛ聘 | å­¦ē§‘å»ŗč®¾ |
|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|
| lgyw | xwdd | twbd | zhenew | jxky | ycdt | xskc | jlhz | xstd | zsjy | djsz | zxbf | lgrw | lgxb | mtlg | jzlt | rczp | xkjs |`,
categories: ['university'],
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
supportRadar: true,
},
radar: [
Expand All @@ -44,7 +50,7 @@ async function handler(ctx) {

const bigTitle = $('title').text().split('-')[0].trim();

const list = $('div.main-liebiao-con-left-bottom li[id^=line_u10]')
const list = $('li[id^=line_u10]')
.toArray()
.map((item) => {
const element = $(item);
Expand Down Expand Up @@ -75,7 +81,17 @@ async function handler(ctx) {
item.pubDate = pubTime;
}

item.description = content('div.v_news_content').html() || 'č§£ęžę­£ę–‡å¤±č“„';
const author = content('p.xinxi span:contains("ä½œč€…ļ¼š")').text().replace('ä½œč€…ļ¼š', '').trim();
item.author = author || null;

const newsContent = content('div.v_news_content') || 'č§£ęžę­£ę–‡å¤±č“„';
const listAttachments = content('ul[style="list-style-type:none;"] a');
let listAttachmentsHtml = '';
listAttachments.each((_, a_element) => {
listAttachmentsHtml += '<br />' + content(a_element).prop('outerHTML');
});

item.description = newsContent + listAttachmentsHtml;
return item;
})
)
Expand Down
9 changes: 9 additions & 0 deletions lib/routes/tmtpost/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: '钛åŖ’体',
url: 'tmtpost.com',
categories: ['new-media'],
description: '钛åŖ’体ę˜Æäø€å®¶äø“ę³ØäŗŽę–°åŖ’体领域ēš„ē§‘ꊀåŖ’体',
lang: 'zh-CN',
};
59 changes: 59 additions & 0 deletions lib/routes/tmtpost/nictation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { Route } from '@/types';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';

export const route: Route = {
path: '/nictation',
categories: ['new-media'],
example: '/tmtpost/word',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: {
source: ['www.tmtpost.com'],
},
name: 'åæ«ęŠ„',
maintainers: ['defp'],
handler,
url: 'www.tmtpost.com/nictation',
};

async function handler() {
const currentTime = Math.floor(Date.now() / 1000);
const oneHourAgo = currentTime - 3600;
const url = 'https://api.tmtpost.com/v1/word/list';

const response = await got({
method: 'get',
url,
searchParams: {
time_start: oneHourAgo,
time_end: currentTime,
limit: 40,
fields: ['share_description', 'share_image', 'word_comments', 'stock_list', 'is_important', 'duration', 'word_classify', 'share_link'].join(';'),
},
headers: {
'app-version': 'web1.0',
},
});

const data = response.data.data;

return {
title: '钛åŖ’体 - åæ«ęŠ„',
link: 'https://www.tmtpost.com/nictation',
item: data.map((item) => ({
title: item.title,
description: item.detail,
pubDate: parseDate(item.time_published, 'X'),
link: item.share_link || `https://www.tmtpost.com/nictation/${item.guid}.html`,
author: item.author_name,
})),
};
}
66 changes: 66 additions & 0 deletions lib/routes/tongji/gs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { Route } from '@/types';
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: '/gs',
categories: ['university'],
example: '/tongji/gs',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['gs.tongji.edu.cn/tzgg.htm', 'gs.tongji.edu.cn/'],
},
],
name: 'ē ”ē©¶ē”Ÿé™¢é€šēŸ„公告',
maintainers: ['sitdownkevin'],
handler,
url: 'gs.tongji.edu.cn/tzgg.htm',
};

async function getNoticeContent(item) {
const response = await got(item.link);
const $ = load(response.body);
const content = $('#vsb_content').html();
item.description = content;
return item;
}

async function handler() {
const baseUrl = 'https://gs.tongji.edu.cn';
const response = await got(`${baseUrl}/tzgg.htm`);
const $ = load(response.body);
const container = $('body > div > div.con_list.ma0a > div > div.list_content_right > div.list_list > ul');
const items = container
.find('li')
.toArray()
.map((item) => {
const title = $(item).find('a').attr('title');
const linkRaw = $(item).find('a').attr('href');
const link = linkRaw.startsWith('http') ? linkRaw : `${baseUrl}/${linkRaw}`;
const pubDate = $(item).find('span').text();
return { title, link, pubDate: parseDate(pubDate, 'YYYY-MM-DD') };
});

const itemsWithContent = await Promise.all(items.map((item) => cache.tryGet(item.link, () => getNoticeContent(item))));

return {
title: 'åŒęµŽå¤§å­¦ē ”ē©¶ē”Ÿé™¢',
link: baseUrl,
description: 'åŒęµŽå¤§å­¦ē ”ē©¶ē”Ÿé™¢é€šēŸ„公告',
image: 'https://upload.wikimedia.org/wikipedia/zh/f/f8/Tongji_University_Emblem.svg',
icon: 'https://upload.wikimedia.org/wikipedia/zh/f/f8/Tongji_University_Emblem.svg',
logo: 'https://upload.wikimedia.org/wikipedia/zh/f/f8/Tongji_University_Emblem.svg',
item: itemsWithContent,
};
}
54 changes: 34 additions & 20 deletions lib/routes/tongji/yjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Route } from '@/types';
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: '/yjs',
Expand All @@ -21,32 +22,45 @@ export const route: Route = {
source: ['yz.tongji.edu.cn/zsxw/ggtz.htm', 'yz.tongji.edu.cn/'],
},
],
name: 'ē ”ē©¶ē”Ÿé™¢é€šēŸ„公告',
maintainers: ['shengmaosu'],
name: 'ē ”ē©¶ē”Ÿę‹›ē”Ÿē½‘通ēŸ„公告',
maintainers: ['shengmaosu', 'sitdownkevin'],
handler,
url: 'yz.tongji.edu.cn/zsxw/ggtz.htm',
};

async function handler() {
const link = 'https://yz.tongji.edu.cn/zsxw/ggtz.htm';
const response = await got(link);
async function getNoticeContent(item) {
const response = await got(item.link);
const $ = load(response.data);
const list = $('.list_main_content li');
const content = $('#vsb_content').html();
item.description = content;
return item;
}

async function handler() {
const baseUrl = 'https://yz.tongji.edu.cn';
const response = await got(`${baseUrl}/zsxw/ggtz.htm`);
const $ = load(response.body);
const container = $('#content-box > div.content > div.list_main_content > ul');
const items = container
.find('li')
.toArray()
.map((item) => {
const title = $(item).find('a').attr('title');
const linkRaw = $(item).find('a').attr('href');
const link = linkRaw.startsWith('http') ? linkRaw : new URL(linkRaw, `${baseUrl}/zsxw`).toString();
const pubDate = $(item).find('span').text();
return { title, link, pubDate: parseDate(pubDate, 'YYYY-MM-DD') };
});

const itemsWithContent = await Promise.all(items.map((item) => cache.tryGet(item.link, () => getNoticeContent(item))));

return {
title: 'åŒęµŽå¤§å­¦ē ”ē©¶ē”Ÿé™¢',
link,
description: 'åŒęµŽå¤§å­¦ē ”ē©¶ē”Ÿé™¢é€šēŸ„公告',
item:
list &&
list.toArray().map((item) => {
item = $(item);
const a = item.find('a');
return {
title: a.attr('title'),
link: new URL(a.attr('href'), link).href,
pubDate: parseDate(item.find('span').text(), 'YYYY-MM-DD'),
};
}),
title: 'åŒęµŽå¤§å­¦ē ”ē©¶ē”Ÿę‹›ē”Ÿē½‘',
link: baseUrl,
description: 'åŒęµŽå¤§å­¦ē ”ē©¶ē”Ÿę‹›ē”Ÿē½‘通ēŸ„公告',
image: 'https://upload.wikimedia.org/wikipedia/zh/f/f8/Tongji_University_Emblem.svg',
icon: 'https://upload.wikimedia.org/wikipedia/zh/f/f8/Tongji_University_Emblem.svg',
logo: 'https://upload.wikimedia.org/wikipedia/zh/f/f8/Tongji_University_Emblem.svg',
item: itemsWithContent,
};
}

0 comments on commit 0d8d8ad

Please sign in to comment.