diff --git a/lib/config.ts b/lib/config.ts index 735e9614b..db9d0d20e 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -292,6 +292,7 @@ export type Config = { }; saraba1st: { cookie?: string; + host?: string; }; sehuatang: { cookie?: string; @@ -729,6 +730,7 @@ const calculateValue = () => { }, saraba1st: { cookie: envs.SARABA1ST_COOKIE, + host: envs.SARABA1ST_HOST || 'https://stage1st.com', }, sehuatang: { cookie: envs.SEHUATANG_COOKIE, diff --git a/lib/routes/saraba1st/digest.ts b/lib/routes/saraba1st/digest.ts index 3a9e12433..94493e467 100644 --- a/lib/routes/saraba1st/digest.ts +++ b/lib/routes/saraba1st/digest.ts @@ -12,7 +12,7 @@ import path from 'node:path'; export const route: Route = { path: '/digest/:tid', categories: ['bbs'], - example: '/saraba1st/digest/forum-75-1', + example: '/saraba1st/digest/forum-6-1', parameters: { tid: '论坛 id' }, features: { requireConfig: false, @@ -25,13 +25,14 @@ export const route: Route = { name: '论坛摘要', maintainers: ['shinemoon'], handler, - description: `版面网址如果为 \`https://bbs.saraba1st.com/2b/forum-75-1.html\` 那么论坛 id 就是 \`forum-75-1\`。`, + description: `版面网址如果为 \`https://stage1st.com/2b/forum-6-1.html\` 那么论坛 id 就是 \`forum-6-1\`。`, }; async function handler(ctx) { const tid = ctx.req.param('tid'); const cookieString = config.saraba1st.cookie ?? ''; - const res = await got('https://bbs.saraba1st.com/2b/' + tid + '.html', { + const host = config.saraba1st.host; + const res = await got(`${host}/2b/${tid}.html`, { headers: { Cookie: cookieString, }, @@ -48,7 +49,7 @@ async function handler(ctx) { const floorUrl = each.find('th.new a.s.xst').attr('href'); return { title: `${title}:${floor}`, - link: new URL(floorUrl, 'https://bbs.saraba1st.com/2b/').href, + link: new URL(floorUrl, `${host}/2b/`).href, author: each.find('td.by cite').text(), pubDate: timezone(parseDate(each.find('td.by em').first().text()), +8), }; @@ -65,7 +66,7 @@ async function handler(ctx) { return { title: `Stage1 论坛 - ${title}`, - link: `https://bbs.saraba1st.com/2b/${tid}.html`, + link: `${host}/2b/${tid}.html`, // item: await resultItems, item: resultItems, }; @@ -92,6 +93,7 @@ async function fetchContent(url) { postinfo: subind(this).find('div.authi em[id*=authorposton]').text(), }, msg: subind(this).find('td[id*="postmessage_"]').html(), + host: config.saraba1st.host, }); stubS.append(section); } diff --git a/lib/routes/saraba1st/namespace.ts b/lib/routes/saraba1st/namespace.ts index 106c418ed..1cc3191b4 100644 --- a/lib/routes/saraba1st/namespace.ts +++ b/lib/routes/saraba1st/namespace.ts @@ -2,6 +2,6 @@ import type { Namespace } from '@/types'; export const namespace: Namespace = { name: 'Saraba1st', - url: 'bbs.saraba1st.com', + url: 'stage1st.com', lang: 'zh-CN', }; diff --git a/lib/routes/saraba1st/templates/digest.art b/lib/routes/saraba1st/templates/digest.art index 06c8ea37e..ef7f64954 100644 --- a/lib/routes/saraba1st/templates/digest.art +++ b/lib/routes/saraba1st/templates/digest.art @@ -1,5 +1,5 @@