diff --git a/lib/routes/bing/daily-wallpaper.ts b/lib/routes/bing/daily-wallpaper.ts
index 10b1460ac..2a6a3d907 100644
--- a/lib/routes/bing/daily-wallpaper.ts
+++ b/lib/routes/bing/daily-wallpaper.ts
@@ -4,38 +4,77 @@ import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
export const route: Route = {
- path: '/',
+ path: '/:routeParams?',
+ parameters: {
+ routeParams: '额外参数type,story和lang:请参阅以下说明和表格',
+ },
radar: [
{
- source: ['cn.bing.com/'],
+ source: ['www.bing.com/', 'cn.bing.com/'],
target: '',
},
],
name: '每日壁纸',
- maintainers: ['FHYunCai'],
+ maintainers: ['FHYunCai', 'LLLLLFish'],
handler,
- url: 'cn.bing.com/',
+ url: 'www.bing.com/',
+ example: '/bing/type=UHD&story=1&lang=zh-CN',
+ description: `| 参数 | 含义 | 接受的值 | 默认值 | 备注 |
+|-------|--------------------|-----------------------------------------------------------|-----------|--------------------------------------------------------|
+| type | 输出壁纸的像素类型 | UHD/1920x1080/1920x1200/768x1366/1080x1920/1080x1920_logo | 1920x1080 | 1920x1200与1080x1920_logo带有水印,输入的值不在接受范围内都会输出成1920x1080 |
+| story | 是否输出壁纸的故事 | 1/0 | 0 | 输入的值不为1都不会输出故事 |
+| lang | 输出壁纸图文的地区(中文或者是英文) | zh/en | zh | zh/en输出的壁纸图文不一定是一样的;如果en不生效,试着部署到其他地方 |
+`,
};
async function handler(ctx) {
- const response = await ofetch('HPImageArchive.aspx', {
- baseURL: 'https://cn.bing.com',
+ const routeParams = new URLSearchParams(ctx.req.param('routeParams'));
+ let type = routeParams.get('type') || '1920x1080';
+ let lang = routeParams.get('lang');
+ let apiUrl = '';
+ const allowedTypes = ['UHD', '1920x1080', '1920x1200', '768x1366', '1080x1920', '1080x1920_logo'];
+ if (lang !== 'zh' && lang !== 'en') {
+ lang = 'zh';
+ }
+ if (lang === 'zh') {
+ lang = 'zh-CN';
+ apiUrl = 'https://cn.bing.com';
+ } else {
+ lang = 'en-US';
+ apiUrl = 'https://www.bing.com';
+ }
+ if (!allowedTypes.includes(type)) {
+ type = '1920x1080';
+ }
+ const story = routeParams.get('story') === '1';
+ const resp = await ofetch('/hp/api/model', {
+ baseURL: apiUrl,
+ method: 'GET',
query: {
- format: 'js',
- idx: 0,
- n: ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 7,
- mkt: 'zh-CN',
+ mtk: lang,
},
});
- const data = response;
+ const items = resp.MediaContents.map((item) => {
+ const ssd = item.Ssd;
+ const link = `${apiUrl}${item.ImageContent.Image.Url.match(/\/th\?id=[^_]+_[^_]+/)[0].replace(/(_\d+x\d+\.webp)$/i, '')}_${type}.jpg`;
+ let description = `
`;
+ if (story) {
+ description += `${item.ImageContent.Headline}`;
+ description += `${item.ImageContent.QuickFact.MainText}
`;
+ description += `
${item.ImageContent.Description}
`;
+ }
+ return {
+ title: item.ImageContent.Title,
+ description,
+ link: `${apiUrl}${item.ImageContent.BackstageUrl}`,
+ author: item.ImageContent.Copyright,
+ pubDate: timezone(parseDate(ssd, 'YYYYMMDD_HHmm'), 0),
+ };
+ });
return {
title: 'Bing每日壁纸',
- link: 'https://cn.bing.com/',
- item: data.images.map((item) => ({
- title: item.copyright,
- description: ``,
- link: item.copyrightlink,
- pubDate: timezone(parseDate(item.fullstartdate), 0),
- })),
+ link: apiUrl,
+ description: 'Bing每日壁纸',
+ item: items,
};
}
diff --git a/lib/routes/sspai/author.ts b/lib/routes/sspai/author.ts
index fced3b0cf..f9d3666b9 100644
--- a/lib/routes/sspai/author.ts
+++ b/lib/routes/sspai/author.ts
@@ -61,7 +61,13 @@ async function handler(ctx) {
const key = `sspai: ${item.id}`;
return cache.tryGet(key, async () => {
const response = await got(link);
- description = response.data.data.body;
+ // description = response.data.data.body;
+ const articleData = response.data.data;
+ const banner = articleData.promote_image;
+ if (banner) {
+ description = `
`;
+ }
+ description += articleData.body;
return {
title: item.title.trim(),
diff --git a/lib/routes/sspai/index.ts b/lib/routes/sspai/index.ts
index ad27475f8..6216d0011 100644
--- a/lib/routes/sspai/index.ts
+++ b/lib/routes/sspai/index.ts
@@ -42,10 +42,7 @@ async function handler() {
return cache.tryGet(key, async () => {
const response = await got({ method: 'get', url: link });
const articleData = response.data.data;
- let banner = articleData.banner;
- if (articleData.keywords.includes('派早报')) {
- banner = `https://cdnfile.sspai.com/${banner}`;
- }
+ const banner = articleData.promote_image;
if (banner) {
description = `
`;
}
diff --git a/lib/routes/sspai/matrix.ts b/lib/routes/sspai/matrix.ts
index 2ade91768..0adfd5c3f 100644
--- a/lib/routes/sspai/matrix.ts
+++ b/lib/routes/sspai/matrix.ts
@@ -42,7 +42,13 @@ async function handler() {
const key = `sspai: ${item.id}`;
return cache.tryGet(key, async () => {
const response = await got(link);
- description = response.data.data.body;
+ // description = response.data.data.body;
+ const articleData = response.data.data;
+ const banner = articleData.promote_image;
+ if (banner) {
+ description = `
`;
+ }
+ description += articleData.body;
return {
title: item.title.trim(),
diff --git a/lib/routes/sspai/tag.ts b/lib/routes/sspai/tag.ts
index 5e4c40e7f..b56547b8f 100644
--- a/lib/routes/sspai/tag.ts
+++ b/lib/routes/sspai/tag.ts
@@ -46,7 +46,13 @@ async function handler(ctx) {
const key = `sspai: ${item.id}`;
return cache.tryGet(key, async () => {
const response = await got({ method: 'get', url: link, headers: { Referer: host } });
- description = response.data.data.body;
+ // description = response.data.data.body;
+ const articleData = response.data.data;
+ const banner = articleData.promote_image;
+ if (banner) {
+ description = `
`;
+ }
+ description += articleData.body;
return {
title: item.title.trim(),
diff --git a/lib/routes/sspai/topic.ts b/lib/routes/sspai/topic.ts
index 5ca450d5e..bb90ece19 100644
--- a/lib/routes/sspai/topic.ts
+++ b/lib/routes/sspai/topic.ts
@@ -52,7 +52,13 @@ async function handler(ctx) {
}
return cache.tryGet(`sspai: ${item.id}`, async () => {
const response = await got(link);
- const description = response.data.data.body;
+ let description = '';
+ const articleData = response.data.data;
+ const banner = articleData.promote_image;
+ if (banner) {
+ description = `
`;
+ }
+ description += articleData.body;
const single = {
title,
diff --git a/lib/routes/sspai/topics.ts b/lib/routes/sspai/topics.ts
index c23b96df7..90d7ecfd7 100644
--- a/lib/routes/sspai/topics.ts
+++ b/lib/routes/sspai/topics.ts
@@ -42,7 +42,7 @@ async function handler() {
const key = `sspai:topics:${item.id}`;
return cache.tryGet(key, () => {
- description = `${item.intro}
如有兴趣,请复制链接订阅