mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 15:21:59 +08:00
fix: add Lofter用户文章分类 & 视频 (#8061)
* fix: add Lofter用户文章分类 & 视频 * add limit * fix limit * refactor: migrate to v2 * fix: route path Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
This commit is contained in:
@@ -865,10 +865,6 @@
|
||||
{ title: 'IPO Featured Stories', docs: 'http://docs.rsshub.app/en/university.html#umass-amherst', source: '/ipo/iss/featured-stories', target: '/umass/amherst/ipostories' },
|
||||
],
|
||||
},
|
||||
'lofter.com': {
|
||||
_name: 'Lofter',
|
||||
www: [{ title: '话题 (标签)', docs: 'https://docs.rsshub.app/social-media.html#lofter', source: ['/tag/:name', '/tag/:name/:type'], target: (params) => `/lofter/tag/${params.name}/${params.type || ''}` }],
|
||||
},
|
||||
'yuque.com': {
|
||||
_name: '语雀',
|
||||
www: [
|
||||
|
||||
@@ -132,7 +132,7 @@ If you don't want to setup credentials, use Picuki.
|
||||
|
||||
### User
|
||||
|
||||
<RouteEn author="hoilc" example="/lofter/user/tingtingtingtingzhi" path="/lofter/user/:name" :paramsDesc="['Lofter user name, in the URL']"/>
|
||||
<RouteEn author="hoilc nczitzk" example="/lofter/user/i" path="/lofter/user/:name?" :paramsDesc="['Lofter user name, can be found in the URL']"/>
|
||||
|
||||
### Tag
|
||||
|
||||
|
||||
@@ -462,7 +462,7 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性
|
||||
|
||||
### 用户
|
||||
|
||||
<Route author="hondajojo" example="/lofter/user/tingtingtingtingzhi" path="/lofter/user/:name" :paramsDesc="['Lofter 用户名, 在URL里']"/>
|
||||
<Route author="hondajojo nczitzk" example="/lofter/user/i" path="/lofter/user/:name?" :paramsDesc="['Lofter 用户名, 可以在用户页 URL 中找到']"/>
|
||||
|
||||
### 话题 (标签)
|
||||
|
||||
|
||||
@@ -1977,18 +1977,6 @@ module.exports = {
|
||||
},
|
||||
],
|
||||
},
|
||||
'lofter.com': {
|
||||
_name: 'Lofter',
|
||||
www: [
|
||||
{
|
||||
title: '话题 (标签)',
|
||||
docs: 'https://docs.rsshub.app/social-media.html#lofter',
|
||||
source: ['/tag/:name', '/tag/:name/:type'],
|
||||
target: (params) => `/lofter/tag/${params.name}/${params.type || ''}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
'yuque.com': {
|
||||
_name: '语雀',
|
||||
www: [
|
||||
|
||||
@@ -2179,9 +2179,9 @@ router.get('/taptap/topic/:id/:label?', lazyloadRouteHandler('./routes/taptap/to
|
||||
router.get('/taptap/changelog/:id', lazyloadRouteHandler('./routes/taptap/changelog'));
|
||||
router.get('/taptap/review/:id/:order?', lazyloadRouteHandler('./routes/taptap/review'));
|
||||
|
||||
// lofter
|
||||
router.get('/lofter/tag/:name?/:type?', lazyloadRouteHandler('./routes/lofter/tag'));
|
||||
router.get('/lofter/user/:username', lazyloadRouteHandler('./routes/lofter/posts'));
|
||||
// lofter migrated to v2
|
||||
// router.get('/lofter/tag/:name?/:type?', lazyloadRouteHandler('./routes/lofter/tag'));
|
||||
// router.get('/lofter/user/:name?', lazyloadRouteHandler('./routes/lofter/user'));
|
||||
|
||||
// 米坛社区表盘
|
||||
router.get('/watchface/:watch_type?/:list_type?', lazyloadRouteHandler('./routes/watchface/update'));
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const blogdomain = `${ctx.params.username}.lofter.com`;
|
||||
const response = await got({
|
||||
method: 'post',
|
||||
url: `http://api.lofter.com/v2.0/blogHomePage.api?product=lofter-iphone-6.8.2`,
|
||||
headers: {
|
||||
Host: 'api.lofter.com',
|
||||
'User-Agent': 'LOFTER/6.8.2 (iPhone; iOS 13.4; Scale/2.00)',
|
||||
},
|
||||
form: {
|
||||
blogdomain,
|
||||
checkpwd: '1',
|
||||
following: '0',
|
||||
limit: '15',
|
||||
method: 'getPostLists',
|
||||
needgetpoststat: '1',
|
||||
offset: '0',
|
||||
postdigestnew: '1',
|
||||
supportposttypes: '1,2,3,4,5,6',
|
||||
},
|
||||
});
|
||||
if (!response.data.response || response.data.response.posts.length === 0) {
|
||||
throw 'Blog Not Found';
|
||||
}
|
||||
const data = response.data.response.posts;
|
||||
const blogNickName = data[0].post.blogInfo.blogNickName;
|
||||
const selfIntro = data[0].post.blogInfo.selfIntro;
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${blogNickName} - lofter`,
|
||||
link: `https://${blogdomain}`,
|
||||
description: selfIntro,
|
||||
item: data.map((item) => {
|
||||
let content = item.post.content;
|
||||
const title = item.post.title || item.post.noticeLinkTitle;
|
||||
const photos = JSON.parse(item.post.photoLinks || `[]`);
|
||||
const images = [];
|
||||
photos.forEach((photo) => {
|
||||
images.push(`<p><img src="${photo.raw}"/></p>`);
|
||||
});
|
||||
content = `${content}${images.join('')}`;
|
||||
return {
|
||||
title,
|
||||
description: content,
|
||||
pubDate: new Date(item.post.publishTime).toUTCString(),
|
||||
link: item.post.blogPageUrl,
|
||||
guid: item.post.blogPageUrl,
|
||||
author: blogNickName,
|
||||
};
|
||||
}),
|
||||
};
|
||||
};
|
||||
4
lib/v2/lofter/maintainer.js
Normal file
4
lib/v2/lofter/maintainer.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
'/tag/:name?/:type?': ['hoilc', 'nczitzk'],
|
||||
'/user/:name?': ['hondajojo', 'nczitzk'],
|
||||
};
|
||||
17
lib/v2/lofter/radar.js
Normal file
17
lib/v2/lofter/radar.js
Normal file
@@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
'lofter.com': {
|
||||
_name: 'Lofter',
|
||||
www: [
|
||||
{
|
||||
title: '话题 (标签)',
|
||||
docs: 'https://docs.rsshub.app/social-media.html#lofter',
|
||||
source: ['/tag/:name', '/tag/:name/:type'],
|
||||
target: (params) => `/lofter/tag/${params.name}/${params.type || ''}`,
|
||||
},
|
||||
{
|
||||
title: '用户',
|
||||
docs: 'https://docs.rsshub.app/social-media.html#lofter',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
4
lib/v2/lofter/router.js
Normal file
4
lib/v2/lofter/router.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/tag/:name?/:type?', require('./tag'));
|
||||
router.get('/user/:name?', require('./user'));
|
||||
};
|
||||
@@ -3,10 +3,10 @@ const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const name = ctx.params.name || '摄影';
|
||||
const type = ctx.params.type || 'new';
|
||||
const name = ctx.params.name ?? '摄影';
|
||||
const type = ctx.params.type ?? 'new';
|
||||
|
||||
const rootUrl = 'http://www.lofter.com';
|
||||
const rootUrl = 'https://www.lofter.com';
|
||||
const currentUrl = `${rootUrl}/tag/${name}/${type}`;
|
||||
|
||||
const response = await got({
|
||||
@@ -52,7 +52,7 @@ module.exports = async (ctx) => {
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${name} - ${title}|LOFTER`,
|
||||
title: `${name} - ${title} | LOFTER`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
52
lib/v2/lofter/user.js
Normal file
52
lib/v2/lofter/user.js
Normal file
@@ -0,0 +1,52 @@
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const name = ctx.params.name ?? 'i';
|
||||
const limit = ctx.query.limit ? parseInt(ctx.query.limit) : '50';
|
||||
|
||||
const rootUrl = `${name}.lofter.com`;
|
||||
|
||||
const response = await got({
|
||||
method: 'post',
|
||||
url: `http://api.lofter.com/v2.0/blogHomePage.api?product=lofter-iphone-10.0.0`,
|
||||
form: {
|
||||
blogdomain: rootUrl,
|
||||
checkpwd: '1',
|
||||
following: '0',
|
||||
limit,
|
||||
method: 'getPostLists',
|
||||
needgetpoststat: '1',
|
||||
offset: '0',
|
||||
postdigestnew: '1',
|
||||
supportposttypes: '1,2,3,4,5,6',
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.data.response || response.data.response.posts.length === 0) {
|
||||
throw 'Blog Not Found';
|
||||
}
|
||||
|
||||
const items = response.data.response.posts.map((item) => ({
|
||||
title: item.post.title || item.post.noticeLinkTitle,
|
||||
link: item.post.blogPageUrl,
|
||||
description:
|
||||
JSON.parse(item.post.photoLinks || `[]`)
|
||||
.map((photo) => `<img src="${photo.raw}">`)
|
||||
.join('') +
|
||||
JSON.parse(item.post.embed ? `[${item.post.embed}]` : `[]`)
|
||||
.map((video) => `<video src="${video.originUrl}" poster="${video.video_img_url}" controls="controls"></video>`)
|
||||
.join('') +
|
||||
item.post.content,
|
||||
pubDate: parseDate(item.post.publishTime),
|
||||
author: item.post.blogInfo.blogNickName,
|
||||
category: item.post.tag.split(','),
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${items[0].author} | LOFTER`,
|
||||
link: rootUrl,
|
||||
item: items,
|
||||
description: response.data.response.posts[0].post.blogInfo.selfIntro,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user