mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-05 04:11:26 +08:00
fix: add Lofter话题/标签文章分类 & 视频 (#8054)
This commit is contained in:
@@ -136,7 +136,13 @@ If you don't want to setup credentials, use Picuki.
|
||||
|
||||
### Tag
|
||||
|
||||
<RouteEn author="hoilc" example="/lofter/tag/名侦探柯南/date" path="/lofter/tag/:name/:type?" :paramsDesc="['tag name', 'ranking type, default to new, can be new date week month total']"/>
|
||||
<Route author="hoilc nczitzk" example="/lofter/tag/摄影/date" path="/lofter/tag/:name?/:type?" :paramsDesc="['tag name, such as `名侦探柯南`, `摄影` by default', 'ranking type, see below, new by default']">
|
||||
|
||||
| new | date | week | month | total |
|
||||
| ---- | ---- | ---- | ----- | ----- |
|
||||
| 最新 | 日榜 | 周榜 | 月榜 | 总榜 |
|
||||
|
||||
</Route>
|
||||
|
||||
## Mastodon
|
||||
|
||||
|
||||
@@ -458,12 +458,14 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性
|
||||
|
||||
### 话题 (标签)
|
||||
|
||||
<Route author="hoilc" example="/lofter/tag/名侦探柯南/date" path="/lofter/tag/:name/:type?" :paramsDesc="['话题名(标签名) 例如 `名侦探柯南`', '排行类型, 默认显示最新话题, 取值如下']"/>
|
||||
<Route author="hoilc nczitzk" example="/lofter/tag/摄影/date" path="/lofter/tag/:name?/:type?" :paramsDesc="['话题(标签)名 例如 `名侦探柯南`,默认为 `摄影`', '排行类型, 见下表,默认显示最新']">
|
||||
|
||||
| new | date | week | month | total |
|
||||
| ---- | ---- | ---- | ----- | ----- |
|
||||
| 最新 | 日榜 | 周榜 | 月榜 | 总榜 |
|
||||
|
||||
</Route>
|
||||
|
||||
## Mastodon
|
||||
|
||||
::: tip 提示
|
||||
|
||||
@@ -2246,7 +2246,7 @@ router.get('/taptap/changelog/:id', lazyloadRouteHandler('./routes/taptap/change
|
||||
router.get('/taptap/review/:id/:order?', lazyloadRouteHandler('./routes/taptap/review'));
|
||||
|
||||
// lofter
|
||||
router.get('/lofter/tag/:name/:type?', lazyloadRouteHandler('./routes/lofter/tag'));
|
||||
router.get('/lofter/tag/:name?/:type?', lazyloadRouteHandler('./routes/lofter/tag'));
|
||||
router.get('/lofter/user/:username', lazyloadRouteHandler('./routes/lofter/posts'));
|
||||
|
||||
// 米坛社区表盘
|
||||
|
||||
@@ -1,55 +1,59 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const titles = {
|
||||
date: '日榜',
|
||||
week: '周榜',
|
||||
month: '月榜',
|
||||
total: '总榜',
|
||||
new: '最新',
|
||||
};
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const name = ctx.params.name;
|
||||
const type = ctx.params.type ? ctx.params.type : 'new';
|
||||
const name = ctx.params.name || '摄影';
|
||||
const type = ctx.params.type || 'new';
|
||||
|
||||
const url = `http://www.lofter.com/tag/${encodeURIComponent(name)}/${type}/`;
|
||||
const rootUrl = 'http://www.lofter.com';
|
||||
const currentUrl = `${rootUrl}/tag/${name}/${type}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const response = await got.get(url);
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('.m-mlist > .mlistcnt').slice(1).toArray();
|
||||
$('.js-digest').remove();
|
||||
|
||||
ctx.state.data = {
|
||||
title: `lofter话题 - ${name} - ${titles[type]}`,
|
||||
link: url,
|
||||
item: list.map((item) => {
|
||||
let title = $('a.j-crt').text();
|
||||
title = title === '最热' ? $('.select-recomm-type').text() : title;
|
||||
|
||||
const items = $('div[data-blogid]')
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
|
||||
const author = item.find('.w-who > .ptag').first().text().trim();
|
||||
const videos = item
|
||||
.find('.js-video')
|
||||
.toArray()
|
||||
.reduce((accumulator, currentValue) => accumulator + `<video src="${$(currentValue).attr('data-videourl')}" poster="${$(currentValue).attr('data-videoimg')}" controls="controls"></video>`, '');
|
||||
|
||||
const images = item.find('img[data-origin]');
|
||||
for (let k = 0; k < images.length; k++) {
|
||||
$(images[k]).replaceWith(`<img src="${$(images[k]).attr('data-origin')}" />`);
|
||||
}
|
||||
const images = item
|
||||
.find('.imgc img')
|
||||
.toArray()
|
||||
.reduce((accumulator, currentValue) => accumulator + `<img src="${$(currentValue).attr('data-origin') || $(currentValue).attr('src')}"/>`, '');
|
||||
|
||||
item.find('.imgc[style]').removeAttr('style');
|
||||
|
||||
item.find('.js-digest').remove();
|
||||
|
||||
item.find('a:not([href])').each(function () {
|
||||
$(this).replaceWith($(this).html());
|
||||
});
|
||||
|
||||
const title = item.find('.tit');
|
||||
const description = item.find('.js-content.ptag');
|
||||
|
||||
return {
|
||||
title: title.length === 0 ? `${author}的图片` : title.text().trim(),
|
||||
author,
|
||||
description: item.find('.m-icnt.ctag > .cnt').html(),
|
||||
link: item.find('a.isayc').attr('href'),
|
||||
pubDate: new Date(item.find('a.isayc').attr('data-time') * 1),
|
||||
author: item.attr('data-blognickname'),
|
||||
link: item.find('.isayc').attr('href'),
|
||||
title: item.find('.tit').text() || `${item.find('.w-who .ptag').text()}${description.text() ? `:${description.text()}` : ''}`,
|
||||
pubDate: parseDate(item.find('.isayc').attr('data-time') * 1),
|
||||
description: videos + images + description.html(),
|
||||
category: item
|
||||
.find('.opta .opti')
|
||||
.toArray()
|
||||
.map((item) => $(item).text()),
|
||||
};
|
||||
}),
|
||||
})
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${name} - ${title}|LOFTER`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user