mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-08-29 01:53:47 +08:00
fix: weibo image regex (#14739)
* fix: weibo image regex * fix: return handlers ---------
This commit is contained in:
@@ -146,12 +146,9 @@ async function handler(ctx) {
|
||||
})
|
||||
);
|
||||
|
||||
ctx.set(
|
||||
'data',
|
||||
weiboUtils.sinaimgTvax({
|
||||
title,
|
||||
link: `https://weibo.com`,
|
||||
item: resultItems,
|
||||
})
|
||||
);
|
||||
return weiboUtils.sinaimgTvax({
|
||||
title,
|
||||
link: `https://weibo.com`,
|
||||
item: resultItems,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -103,13 +103,10 @@ async function handler(ctx) {
|
||||
})
|
||||
);
|
||||
|
||||
ctx.set(
|
||||
'data',
|
||||
weiboUtils.sinaimgTvax({
|
||||
title: groupName,
|
||||
link: `https://weibo.com/mygroups?gid=${gid}`,
|
||||
description: '微博自定义分组',
|
||||
item: resultItems,
|
||||
})
|
||||
);
|
||||
return weiboUtils.sinaimgTvax({
|
||||
title: groupName,
|
||||
link: `https://weibo.com/mygroups?gid=${gid}`,
|
||||
description: '微博自定义分组',
|
||||
item: resultItems,
|
||||
});
|
||||
}
|
||||
|
||||
+16
-18
@@ -48,22 +48,20 @@ async function handler(ctx) {
|
||||
);
|
||||
|
||||
const routeParams = querystring.parse(ctx.req.param('routeParams'));
|
||||
ctx.set(
|
||||
'data',
|
||||
weiboUtils.sinaimgTvax({
|
||||
title: `又有人在微博提到${keyword}了`,
|
||||
link: `http://s.weibo.com/weibo/${encodeURIComponent(keyword)}&b=1&nodup=1`,
|
||||
description: `又有人在微博提到${keyword}了`,
|
||||
item: data.map((item) => {
|
||||
item.mblog.created_at = timezone(item.mblog.created_at, +8);
|
||||
if (item.mblog.retweeted_status && item.mblog.retweeted_status.created_at) {
|
||||
item.mblog.retweeted_status.created_at = timezone(item.mblog.retweeted_status.created_at, +8);
|
||||
}
|
||||
return weiboUtils.formatExtended(ctx, item.mblog, undefined, {
|
||||
showAuthorInTitle: fallback(undefined, queryToBoolean(routeParams.showAuthorInTitle), true),
|
||||
showAuthorInDesc: fallback(undefined, queryToBoolean(routeParams.showAuthorInDesc), true),
|
||||
});
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
return weiboUtils.sinaimgTvax({
|
||||
title: `又有人在微博提到${keyword}了`,
|
||||
link: `http://s.weibo.com/weibo/${encodeURIComponent(keyword)}&b=1&nodup=1`,
|
||||
description: `又有人在微博提到${keyword}了`,
|
||||
item: data.map((item) => {
|
||||
item.mblog.created_at = timezone(item.mblog.created_at, +8);
|
||||
if (item.mblog.retweeted_status && item.mblog.retweeted_status.created_at) {
|
||||
item.mblog.retweeted_status.created_at = timezone(item.mblog.retweeted_status.created_at, +8);
|
||||
}
|
||||
return weiboUtils.formatExtended(ctx, item.mblog, undefined, {
|
||||
showAuthorInTitle: fallback(undefined, queryToBoolean(routeParams.showAuthorInTitle), true),
|
||||
showAuthorInDesc: fallback(undefined, queryToBoolean(routeParams.showAuthorInDesc), true),
|
||||
});
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -27,21 +27,18 @@ export const route: Route = {
|
||||
async function handler(ctx) {
|
||||
const userid = ctx.req.param('userid');
|
||||
const link = `https://oasis.weibo.cn/v1/h5/share?uid=${userid}`;
|
||||
ctx.set(
|
||||
'data',
|
||||
weiboUtils.sinaimgTvax(
|
||||
await buildData({
|
||||
link,
|
||||
url: link,
|
||||
title: `$('.name-main').text().trim() + ' - 用户 - 绿洲'`,
|
||||
description: `$('.desc').text().trim()`,
|
||||
item: {
|
||||
item: '.container .status-item',
|
||||
title: `$('.status-item-title').clone().children().remove().end().text()`,
|
||||
description: `$('.status-item-title').clone().children().remove().end().text() + '<br>' + $('.status-img').html()`,
|
||||
link: `'https://oasis.weibo.cn/v1/h5/share?sid=' + $('.status-item-title').parent().data('id')`,
|
||||
},
|
||||
})
|
||||
)
|
||||
return weiboUtils.sinaimgTvax(
|
||||
await buildData({
|
||||
link,
|
||||
url: link,
|
||||
title: `$('.name-main').text().trim() + ' - 用户 - 绿洲'`,
|
||||
description: `$('.desc').text().trim()`,
|
||||
item: {
|
||||
item: '.container .status-item',
|
||||
title: `$('.status-item-title').clone().children().remove().end().text()`,
|
||||
description: `$('.status-item-title').clone().children().remove().end().text() + '<br>' + $('.status-img').html()`,
|
||||
link: `'https://oasis.weibo.cn/v1/h5/share?sid=' + $('.status-item-title').parent().data('id')`,
|
||||
},
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -76,13 +76,10 @@ async function handler(ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
ctx.set(
|
||||
'data',
|
||||
weiboUtils.sinaimgTvax({
|
||||
title: `微博超话 - ${containerData.pageInfo.page_title}`,
|
||||
link: `https://weibo.com/p/${id}/super_index`,
|
||||
description: `#${containerData.pageInfo.page_title}# 的超话`,
|
||||
item: resultItems,
|
||||
})
|
||||
);
|
||||
return weiboUtils.sinaimgTvax({
|
||||
title: `微博超话 - ${containerData.pageInfo.page_title}`,
|
||||
link: `https://weibo.com/p/${id}/super_index`,
|
||||
description: `#${containerData.pageInfo.page_title}# 的超话`,
|
||||
item: resultItems,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -142,16 +142,13 @@ async function handler(ctx) {
|
||||
})
|
||||
);
|
||||
|
||||
ctx.set(
|
||||
'data',
|
||||
weiboUtils.sinaimgTvax({
|
||||
title: `个人微博时间线--${name}`,
|
||||
link: `http://weibo.com/${uid}/`,
|
||||
description,
|
||||
image: profileImageUrl,
|
||||
item: resultItem,
|
||||
})
|
||||
);
|
||||
return weiboUtils.sinaimgTvax({
|
||||
title: `个人微博时间线--${name}`,
|
||||
link: `http://weibo.com/${uid}/`,
|
||||
description,
|
||||
image: profileImageUrl,
|
||||
item: resultItem,
|
||||
});
|
||||
} else if (uid === '0' || ctx.req.query()) {
|
||||
const { app_key = '', redirect_url = ctx.req.origin + '/weibo/timeline/0', app_secret = '' } = config.weibo;
|
||||
|
||||
|
||||
@@ -169,14 +169,11 @@ async function handler(ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
ctx.set(
|
||||
'data',
|
||||
weiboUtils.sinaimgTvax({
|
||||
title: `${name}的微博`,
|
||||
link: `https://weibo.com/${uid}/`,
|
||||
description,
|
||||
image: profileImageUrl,
|
||||
item: resultItems,
|
||||
})
|
||||
);
|
||||
return weiboUtils.sinaimgTvax({
|
||||
title: `${name}的微博`,
|
||||
link: `https://weibo.com/${uid}/`,
|
||||
description,
|
||||
image: profileImageUrl,
|
||||
item: resultItems,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ const weiboUtils = {
|
||||
htmlNewLineUnreplaced = htmlNewLineUnreplaced.replaceAll(/"https:\/\/weibo\.cn\/sinaurl.*?[&?]u=(http.*?)"/g, (match, p1) => `"${decodeURIComponent(p1)}"`);
|
||||
|
||||
// 处理图片的链接
|
||||
htmlNewLineUnreplaced = htmlNewLineUnreplaced.replaceAll(/<a\s+href="https?:\/\/.+\.(jpg|png|gif)"/g, (match) => `${match} data-rsshub-image="href"`);
|
||||
htmlNewLineUnreplaced = htmlNewLineUnreplaced.replaceAll(/<a\s+href="https?:\/\/[^"]+\.(jpg|png|gif)"/g, (match) => `${match} data-rsshub-image="href"`);
|
||||
|
||||
let html = htmlNewLineUnreplaced.replaceAll('\n', '<br>');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user