rsshub 1.0.0-master.baeafb9 → 1.0.0-master.bb80a2e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/lib/config.js +4 -0
- package/lib/middleware/cache/index.js +3 -3
- package/lib/middleware/cache/memory.js +5 -11
- package/lib/router.js +23 -22
- package/lib/routes/amd/graphicsdrivers.js +1 -1
- package/lib/routes/weibo/keyword.js +18 -10
- package/lib/routes/weibo/super_index.js +24 -15
- package/lib/routes/weibo/timeline.js +37 -14
- package/lib/routes/weibo/user.js +42 -18
- package/lib/routes/weibo/utils.js +39 -0
- package/lib/utils/parse-date.js +171 -17
- package/lib/utils/torrent.js +9 -1
- package/lib/v2/asus/bios.js +38 -0
- package/lib/v2/asus/maintainer.js +3 -0
- package/lib/v2/asus/radar.js +13 -0
- package/lib/v2/asus/router.js +3 -0
- package/lib/v2/asus/templates/bios.art +6 -0
- package/lib/v2/douban/people/status.js +10 -2
- package/lib/v2/douban/people/wish.js +55 -43
- package/lib/v2/gov/anhui/kjt.js +56 -0
- package/lib/v2/gov/maintainer.js +1 -0
- package/lib/v2/gov/radar.js +90 -76
- package/lib/v2/gov/router.js +1 -0
- package/lib/v2/hupu/all.js +73 -0
- package/lib/v2/hupu/bbs.js +64 -0
- package/lib/v2/hupu/index.js +72 -0
- package/lib/v2/hupu/maintainer.js +7 -0
- package/lib/v2/hupu/radar.js +35 -0
- package/lib/v2/hupu/router.js +7 -0
- package/lib/v2/hupu/templates/description.art +6 -0
- package/lib/{routes → v2}/ifeng/feng.js +7 -5
- package/lib/v2/ifeng/maintainer.js +3 -0
- package/lib/v2/ifeng/radar.js +11 -0
- package/lib/v2/ifeng/router.js +3 -0
- package/lib/{routes → v2}/ifeng/utils.js +0 -0
- package/lib/v2/kakuyomu/episode.js +54 -0
- package/lib/v2/kakuyomu/maintainer.js +3 -0
- package/lib/v2/kakuyomu/radar.js +13 -0
- package/lib/v2/kakuyomu/router.js +1 -0
- package/lib/v2/mihoyo/bbs.js +62 -0
- package/lib/v2/mihoyo/maintainer.js +3 -0
- package/lib/v2/mihoyo/radar.js +31 -0
- package/lib/v2/mihoyo/router.js +3 -0
- package/lib/v2/mihoyo/templates/description.art +6 -0
- package/lib/{routes → v2}/mpaypass/main.js +23 -27
- package/lib/v2/mpaypass/maintainer.js +4 -0
- package/lib/v2/mpaypass/news.js +39 -0
- package/lib/v2/mpaypass/radar.js +19 -0
- package/lib/v2/mpaypass/router.js +4 -0
- package/lib/v2/natgeo/dailyphoto.js +32 -0
- package/lib/v2/natgeo/dailyselection.js +41 -0
- package/lib/v2/natgeo/maintainer.js +5 -0
- package/lib/{routes → v2}/natgeo/natgeo.js +18 -32
- package/lib/v2/natgeo/radar.js +24 -0
- package/lib/v2/natgeo/router.js +5 -0
- package/lib/v2/natgeo/templates/dailyPhoto.art +5 -0
- package/lib/v2/nuaa/cs/index.js +87 -0
- package/lib/v2/nuaa/jwc/jwc.js +82 -0
- package/lib/v2/nuaa/maintainer.js +5 -0
- package/lib/v2/nuaa/radar.js +23 -0
- package/lib/v2/nuaa/router.js +5 -0
- package/lib/{routes/universities → v2}/nuaa/utils/pypasswaf.js +1 -1
- package/lib/{routes/universities → v2}/nuaa/yjsy/yjsy.js +16 -22
- package/lib/v2/picuki/profile.js +12 -3
- package/lib/v2/pubmed/maintainer.js +3 -0
- package/lib/v2/pubmed/radar.js +13 -0
- package/lib/v2/pubmed/router.js +3 -0
- package/lib/v2/pubmed/templates/description.art +7 -0
- package/lib/v2/pubmed/trending.js +58 -0
- package/lib/v2/qweather/3days.js +46 -0
- package/lib/v2/qweather/maintainer.js +4 -0
- package/lib/v2/qweather/now.js +46 -0
- package/lib/v2/qweather/router.js +4 -0
- package/lib/v2/qweather/util/3days.art +20 -0
- package/lib/v2/qweather/util/now.art +16 -0
- package/lib/v2/telegram/channel.js +10 -6
- package/lib/v2/test/index.js +1 -1
- package/lib/{routes → v2}/thepaper/839studio/category.js +0 -0
- package/lib/{routes → v2}/thepaper/839studio/studio.js +0 -0
- package/lib/{routes → v2}/thepaper/channel.js +0 -0
- package/lib/v2/thepaper/factpaper.js +61 -0
- package/lib/{routes → v2}/thepaper/featured.js +0 -0
- package/lib/{routes → v2}/thepaper/list.js +0 -0
- package/lib/v2/thepaper/maintainer.js +8 -0
- package/lib/v2/thepaper/radar.js +42 -0
- package/lib/v2/thepaper/router.js +8 -0
- package/lib/v2/thepaper/templates/factpaper.art +12 -0
- package/lib/v2/thepaper/utils.js +55 -0
- package/lib/v2/zooTeam/blog.js +32 -0
- package/lib/v2/zooTeam/maintainer.js +4 -0
- package/lib/v2/zooTeam/radar.js +21 -0
- package/lib/v2/zooTeam/router.js +4 -0
- package/lib/v2/zooTeam/weekly.js +34 -0
- package/package.json +12 -8
- package/lib/routes/hupu/all.js +0 -53
- package/lib/routes/hupu/bbs.js +0 -83
- package/lib/routes/hupu/dept.js +0 -66
- package/lib/routes/mpaypass/news.js +0 -43
- package/lib/routes/natgeo/dailyphoto.js +0 -27
- package/lib/routes/pubmed/trending.js +0 -65
- package/lib/routes/thepaper/utils.js +0 -48
- package/lib/routes/universities/nuaa/cs/index.js +0 -84
- package/lib/routes/universities/nuaa/jwc/jwc.js +0 -105
package/README.md
CHANGED
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
> 🍰 Everything is RSSible
|
|
7
7
|
|
|
8
|
-
[](https://t.me/rsshub)
|
|
9
|
-
[](https://t.me/rsshub)
|
|
9
|
+
[](https://www.npmjs.com/package/rsshub)
|
|
10
|
+
[](https://hub.docker.com/r/diygod/rsshub)
|
|
11
|
+
[](https://github.com/DIYgod/RSSHub/actions/workflows/test.yml?query=event%3Apush+branch%3Amaster)
|
|
11
12
|
|
|
12
13
|
## Introduction
|
|
13
14
|
|
package/lib/config.js
CHANGED
|
@@ -27,10 +27,10 @@ if (config.cache.type === 'redis') {
|
|
|
27
27
|
globalCache.set = cacheModule.set;
|
|
28
28
|
} else if (config.cache.type === 'memory') {
|
|
29
29
|
cacheModule = require('./memory');
|
|
30
|
-
const {
|
|
30
|
+
const { memoryCache } = cacheModule.clients;
|
|
31
31
|
globalCache.get = (key) => {
|
|
32
32
|
if (key && cacheModule.status.available) {
|
|
33
|
-
return
|
|
33
|
+
return memoryCache.get(key, { updateAgeOnGet: false });
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
globalCache.set = (key, value, maxAge) => {
|
|
@@ -41,7 +41,7 @@ if (config.cache.type === 'redis') {
|
|
|
41
41
|
value = JSON.stringify(value);
|
|
42
42
|
}
|
|
43
43
|
if (key) {
|
|
44
|
-
return
|
|
44
|
+
return memoryCache.set(key, value, { ttl: maxAge * 1000 });
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
47
|
} else {
|
|
@@ -3,30 +3,24 @@ const config = require('@/config').value;
|
|
|
3
3
|
|
|
4
4
|
const status = { available: false };
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const memoryCache = new Lru({
|
|
7
7
|
ttl: config.cache.routeExpire * 1000,
|
|
8
8
|
max: config.memory.max,
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
const routeCache = new Lru({
|
|
12
|
-
ttl: config.cache.routeExpire * 1000,
|
|
13
|
-
max: config.memory.max,
|
|
14
|
-
updateAgeOnGet: true,
|
|
15
|
-
});
|
|
16
|
-
|
|
17
11
|
status.available = true;
|
|
18
12
|
|
|
19
13
|
module.exports = {
|
|
20
14
|
get: (key, refresh = true) => {
|
|
21
15
|
if (key && status.available) {
|
|
22
|
-
let value = (
|
|
16
|
+
let value = memoryCache.get(key, { updateAgeOnGet: refresh });
|
|
23
17
|
if (value) {
|
|
24
18
|
value = value + '';
|
|
25
19
|
}
|
|
26
20
|
return value;
|
|
27
21
|
}
|
|
28
22
|
},
|
|
29
|
-
set: (key, value, maxAge = config.cache.contentExpire
|
|
23
|
+
set: (key, value, maxAge = config.cache.contentExpire) => {
|
|
30
24
|
if (!value || value === 'undefined') {
|
|
31
25
|
value = '';
|
|
32
26
|
}
|
|
@@ -34,9 +28,9 @@ module.exports = {
|
|
|
34
28
|
value = JSON.stringify(value);
|
|
35
29
|
}
|
|
36
30
|
if (key && status.available) {
|
|
37
|
-
return
|
|
31
|
+
return memoryCache.set(key, value, { ttl: maxAge * 1000 });
|
|
38
32
|
}
|
|
39
33
|
},
|
|
40
|
-
clients: {
|
|
34
|
+
clients: { memoryCache },
|
|
41
35
|
status,
|
|
42
36
|
};
|
package/lib/router.js
CHANGED
|
@@ -301,9 +301,10 @@ router.get('/t66y/:id/:type?', lazyloadRouteHandler('./routes/t66y/index'));
|
|
|
301
301
|
// 色中色
|
|
302
302
|
router.get('/sexinsex/:id/:type?', lazyloadRouteHandler('./routes/sexinsex/index'));
|
|
303
303
|
|
|
304
|
-
// 国家地理
|
|
305
|
-
router.get('/natgeo/
|
|
306
|
-
router.get('/natgeo
|
|
304
|
+
// 国家地理 migrated to v2
|
|
305
|
+
// router.get('/natgeo/dailyselection', lazyloadRouteHandler('./routes/natgeo/dailyselection'));
|
|
306
|
+
// router.get('/natgeo/dailyphoto', lazyloadRouteHandler('./routes/natgeo/dailyphoto'));
|
|
307
|
+
// router.get('/natgeo/:cat/:type?', lazyloadRouteHandler('./routes/natgeo/natgeo'));
|
|
307
308
|
|
|
308
309
|
// 一个
|
|
309
310
|
router.get('/one', lazyloadRouteHandler('./routes/one/index'));
|
|
@@ -519,10 +520,10 @@ router.get('/seu/cse/:type?', lazyloadRouteHandler('./routes/universities/seu/cs
|
|
|
519
520
|
// 南京工业大学
|
|
520
521
|
router.get('/njtech/jwc', lazyloadRouteHandler('./routes/universities/njtech/jwc'));
|
|
521
522
|
|
|
522
|
-
// 南京航空航天大学
|
|
523
|
-
router.get('/nuaa/jwc/:type?', lazyloadRouteHandler('./routes/universities/nuaa/jwc/jwc'));
|
|
524
|
-
router.get('/nuaa/cs/:type?', lazyloadRouteHandler('./routes/universities/nuaa/cs/index'));
|
|
525
|
-
router.get('/nuaa/yjsy/:type?', lazyloadRouteHandler('./routes/universities/nuaa/yjsy/yjsy'));
|
|
523
|
+
// 南京航空航天大学 migrated to v2
|
|
524
|
+
// router.get('/nuaa/jwc/:type/:getDescription?', lazyloadRouteHandler('./routes/universities/nuaa/jwc/jwc'));
|
|
525
|
+
// router.get('/nuaa/cs/:type/:getDescription?', lazyloadRouteHandler('./routes/universities/nuaa/cs/index'));
|
|
526
|
+
// router.get('/nuaa/yjsy/:type?', lazyloadRouteHandler('./routes/universities/nuaa/yjsy/yjsy'));
|
|
526
527
|
|
|
527
528
|
// 河海大学
|
|
528
529
|
router.get('/hhu/libNews', lazyloadRouteHandler('./routes/universities/hhu/libNews'));
|
|
@@ -848,13 +849,13 @@ router.get('/xclient/app/:name', lazyloadRouteHandler('./routes/xclient/app'));
|
|
|
848
849
|
router.get('/embassy/:country/:city?', lazyloadRouteHandler('./routes/embassy/index'));
|
|
849
850
|
|
|
850
851
|
// 澎湃新闻
|
|
851
|
-
router.get('/thepaper/featured', lazyloadRouteHandler('./routes/thepaper/featured'));
|
|
852
|
-
router.get('/thepaper/channel/:id', lazyloadRouteHandler('./routes/thepaper/channel'));
|
|
853
|
-
router.get('/thepaper/list/:id', lazyloadRouteHandler('./routes/thepaper/list'));
|
|
852
|
+
// router.get('/thepaper/featured', lazyloadRouteHandler('./routes/thepaper/featured'));
|
|
853
|
+
// router.get('/thepaper/channel/:id', lazyloadRouteHandler('./routes/thepaper/channel'));
|
|
854
|
+
// router.get('/thepaper/list/:id', lazyloadRouteHandler('./routes/thepaper/list'));
|
|
854
855
|
|
|
855
856
|
// 澎湃美数课
|
|
856
|
-
router.get('/thepaper/839studio', lazyloadRouteHandler('./routes/thepaper/839studio/studio.js'));
|
|
857
|
-
router.get('/thepaper/839studio/:id', lazyloadRouteHandler('./routes/thepaper/839studio/category.js'));
|
|
857
|
+
// router.get('/thepaper/839studio', lazyloadRouteHandler('./routes/thepaper/839studio/studio.js'));
|
|
858
|
+
// router.get('/thepaper/839studio/:id', lazyloadRouteHandler('./routes/thepaper/839studio/category.js'));
|
|
858
859
|
|
|
859
860
|
// 电影首发站
|
|
860
861
|
router.get('/dysfz', lazyloadRouteHandler('./routes/dysfz/index'));
|
|
@@ -1264,9 +1265,9 @@ router.get('/xiaoheihe/discount/:platform?', lazyloadRouteHandler('./routes/xiao
|
|
|
1264
1265
|
// 惠誉评级
|
|
1265
1266
|
router.get('/fitchratings/site/:type', lazyloadRouteHandler('./routes/fitchratings/site'));
|
|
1266
1267
|
|
|
1267
|
-
// 移动支付
|
|
1268
|
-
router.get('/mpaypass/news', lazyloadRouteHandler('./routes/mpaypass/news'));
|
|
1269
|
-
router.get('/mpaypass/main/:type?', lazyloadRouteHandler('./routes/mpaypass/main'));
|
|
1268
|
+
// 移动支付 migrated to v2
|
|
1269
|
+
// router.get('/mpaypass/news', lazyloadRouteHandler('./routes/mpaypass/news'));
|
|
1270
|
+
// router.get('/mpaypass/main/:type?', lazyloadRouteHandler('./routes/mpaypass/main'));
|
|
1270
1271
|
|
|
1271
1272
|
// 新浪科技探索
|
|
1272
1273
|
router.get('/sina/discovery/:type', lazyloadRouteHandler('./routes/sina/discovery'));
|
|
@@ -1332,10 +1333,10 @@ router.get('/leetcode/submission/us/:user', lazyloadRouteHandler('./routes/leetc
|
|
|
1332
1333
|
router.get('/leetcode/submission/cn/:user', lazyloadRouteHandler('./routes/leetcode/check-cn'));
|
|
1333
1334
|
|
|
1334
1335
|
// 虎扑
|
|
1335
|
-
router.get('/hupu/bxj/:id/:order?', lazyloadRouteHandler('./routes/hupu/bbs'));
|
|
1336
|
-
router.get('/hupu/bbs/:id/:order?', lazyloadRouteHandler('./routes/hupu/bbs'));
|
|
1337
|
-
router.get('/hupu/all/:caty', lazyloadRouteHandler('./routes/hupu/all'));
|
|
1338
|
-
router.get('/hupu/dept/:dept', lazyloadRouteHandler('./routes/hupu/dept'));
|
|
1336
|
+
// router.get('/hupu/bxj/:id/:order?', lazyloadRouteHandler('./routes/hupu/bbs'));
|
|
1337
|
+
// router.get('/hupu/bbs/:id/:order?', lazyloadRouteHandler('./routes/hupu/bbs'));
|
|
1338
|
+
// router.get('/hupu/all/:caty', lazyloadRouteHandler('./routes/hupu/all'));
|
|
1339
|
+
// router.get('/hupu/dept/:dept', lazyloadRouteHandler('./routes/hupu/dept'));
|
|
1339
1340
|
|
|
1340
1341
|
// 牛客网 migrated to v2
|
|
1341
1342
|
// router.get('/nowcoder/discuss/:type/:order', lazyloadRouteHandler('./routes/nowcoder/discuss'));
|
|
@@ -2181,7 +2182,7 @@ router.get('/kaggle/competitions/:category?', lazyloadRouteHandler('./routes/kag
|
|
|
2181
2182
|
router.get('/kaggle/user/:user', lazyloadRouteHandler('./routes/kaggle/user'));
|
|
2182
2183
|
|
|
2183
2184
|
// PubMed Trending
|
|
2184
|
-
router.get('/pubmed/trending', lazyloadRouteHandler('./routes/pubmed/trending'));
|
|
2185
|
+
// router.get('/pubmed/trending', lazyloadRouteHandler('./routes/pubmed/trending'));
|
|
2185
2186
|
|
|
2186
2187
|
// 领科 (linkresearcher.com)
|
|
2187
2188
|
router.get('/linkresearcher/:params', lazyloadRouteHandler('./routes/linkresearcher/index'));
|
|
@@ -2457,8 +2458,8 @@ router.get('/lastfm/top/:country?', lazyloadRouteHandler('./routes/lastfm/top'))
|
|
|
2457
2458
|
router.get('/piapro/user/:pid', lazyloadRouteHandler('./routes/piapro/user'));
|
|
2458
2459
|
router.get('/piapro/public/:type/:tag?/:category?', lazyloadRouteHandler('./routes/piapro/public'));
|
|
2459
2460
|
|
|
2460
|
-
// 凤凰网
|
|
2461
|
-
router.get('/ifeng/feng/:id/:type', lazyloadRouteHandler('./routes/ifeng/feng'));
|
|
2461
|
+
// 凤凰网 migrated to v2
|
|
2462
|
+
// router.get('/ifeng/feng/:id/:type', lazyloadRouteHandler('./routes/ifeng/feng'));
|
|
2462
2463
|
|
|
2463
2464
|
// 第一版主
|
|
2464
2465
|
router.get('/novel/d1bz/:category/:id', lazyloadRouteHandler('./routes/d1bz/novel'));
|
|
@@ -27,7 +27,7 @@ module.exports = async (ctx) => {
|
|
|
27
27
|
if (!data) {
|
|
28
28
|
const res = await got.get(url);
|
|
29
29
|
data = res.data;
|
|
30
|
-
ctx.cache.set(url, data, config.cache.contentExpire
|
|
30
|
+
ctx.cache.set(url, data, config.cache.contentExpire);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
const $ = cheerio.load(data, { xmlMode: true });
|
|
@@ -3,21 +3,29 @@ const got = require('@/utils/got');
|
|
|
3
3
|
const weiboUtils = require('./utils');
|
|
4
4
|
const timezone = require('@/utils/timezone');
|
|
5
5
|
const { fallback, queryToBoolean } = require('@/utils/readable-social');
|
|
6
|
+
const config = require('@/config').value;
|
|
6
7
|
|
|
7
8
|
module.exports = async (ctx) => {
|
|
8
9
|
const keyword = ctx.params.keyword;
|
|
9
10
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
const data = await ctx.cache.tryGet(
|
|
12
|
+
`weibo:keyword:${keyword}`,
|
|
13
|
+
async () => {
|
|
14
|
+
const _r = await got({
|
|
15
|
+
method: 'get',
|
|
16
|
+
url: `https://m.weibo.cn/api/container/getIndex?containerid=100103type%3D61%26q%3D${encodeURIComponent(keyword)}%26t%3D0`,
|
|
17
|
+
headers: {
|
|
18
|
+
Referer: `https://m.weibo.cn/p/searchall?containerid=100103type%3D1%26q%3D${encodeURIComponent(keyword)}`,
|
|
19
|
+
'MWeibo-Pwa': 1,
|
|
20
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
21
|
+
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1',
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
return _r.data.data.cards;
|
|
18
25
|
},
|
|
19
|
-
|
|
20
|
-
|
|
26
|
+
config.cache.routeExpire,
|
|
27
|
+
false
|
|
28
|
+
);
|
|
21
29
|
|
|
22
30
|
const routeParams = querystring.parse(ctx.params.routeParams);
|
|
23
31
|
ctx.state.data = {
|
|
@@ -2,28 +2,37 @@ const got = require('@/utils/got');
|
|
|
2
2
|
const weiboUtils = require('./utils');
|
|
3
3
|
const timezone = require('@/utils/timezone');
|
|
4
4
|
const queryString = require('query-string');
|
|
5
|
+
const config = require('@/config').value;
|
|
5
6
|
|
|
6
7
|
module.exports = async (ctx) => {
|
|
7
8
|
const id = ctx.params.id;
|
|
8
9
|
const type = ctx.params.type ?? 'feed';
|
|
9
10
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
const containerData = await ctx.cache.tryGet(
|
|
12
|
+
`weibo:super_index:container:${id}:${type}`,
|
|
13
|
+
async () => {
|
|
14
|
+
const _r = await got('https://m.weibo.cn/api/container/getIndex', {
|
|
15
|
+
searchParams: queryString.stringify({
|
|
16
|
+
containerid: `${id}_-_${type}`,
|
|
17
|
+
luicode: '10000011',
|
|
18
|
+
lfid: `${id}_-_main`,
|
|
19
|
+
}),
|
|
20
|
+
headers: {
|
|
21
|
+
Referer: `https://m.weibo.cn/p/index?containerid=${id}_-_soul&luicode=10000011&lfid=${id}_-_main`,
|
|
22
|
+
'MWeibo-Pwa': '1',
|
|
23
|
+
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1',
|
|
24
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
return _r.data.data;
|
|
21
28
|
},
|
|
22
|
-
|
|
29
|
+
config.cache.routeExpire,
|
|
30
|
+
false
|
|
31
|
+
);
|
|
23
32
|
|
|
24
33
|
const resultItems = [];
|
|
25
34
|
|
|
26
|
-
for (const card of
|
|
35
|
+
for (const card of containerData.cards) {
|
|
27
36
|
if (!('card_group' in card)) {
|
|
28
37
|
continue;
|
|
29
38
|
}
|
|
@@ -45,9 +54,9 @@ module.exports = async (ctx) => {
|
|
|
45
54
|
}
|
|
46
55
|
|
|
47
56
|
ctx.state.data = {
|
|
48
|
-
title: `微博超话 - ${
|
|
57
|
+
title: `微博超话 - ${containerData.pageInfo.page_title}`,
|
|
49
58
|
link: `https://weibo.com/p/${id}/super_index`,
|
|
50
|
-
description: `#${
|
|
59
|
+
description: `#${containerData.pageInfo.page_title}# 的超话`,
|
|
51
60
|
item: resultItems,
|
|
52
61
|
};
|
|
53
62
|
};
|
|
@@ -12,6 +12,7 @@ module.exports = async (ctx) => {
|
|
|
12
12
|
const token = await ctx.cache.get('weibotimelineuid' + uid, false);
|
|
13
13
|
let displayVideo = '1';
|
|
14
14
|
let displayArticle = '0';
|
|
15
|
+
let displayComments = '0';
|
|
15
16
|
if (routeParams) {
|
|
16
17
|
if (routeParams === '1' || routeParams === '0') {
|
|
17
18
|
displayVideo = routeParams;
|
|
@@ -19,24 +20,41 @@ module.exports = async (ctx) => {
|
|
|
19
20
|
const routeParams = querystring.parse(ctx.params.routeParams);
|
|
20
21
|
displayVideo = fallback(undefined, queryToBoolean(routeParams.displayVideo), true) ? '1' : '0';
|
|
21
22
|
displayArticle = fallback(undefined, queryToBoolean(routeParams.displayArticle), false) ? '1' : '0';
|
|
23
|
+
displayComments = fallback(undefined, queryToBoolean(routeParams.displayComments), false) ? '1' : '0';
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
if (token) {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
const userInfo = await ctx.cache.tryGet(
|
|
29
|
+
`weibo:timeline:userInfo:${uid}`,
|
|
30
|
+
async () => {
|
|
31
|
+
const _r = await got({
|
|
32
|
+
method: 'get',
|
|
33
|
+
url: `https://m.weibo.cn/api/container/getIndex?type=uid&value=${uid}`,
|
|
34
|
+
headers: {
|
|
35
|
+
Referer: 'https://m.weibo.cn/',
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
return _r.data.data.userInfo;
|
|
31
39
|
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
40
|
+
config.cache.routeExpire,
|
|
41
|
+
false
|
|
42
|
+
);
|
|
43
|
+
const name = userInfo.screen_name;
|
|
44
|
+
const description = userInfo.description;
|
|
45
|
+
const profileImageUrl = userInfo.profile_image_url;
|
|
36
46
|
|
|
37
|
-
const response = await
|
|
47
|
+
const response = await ctx.cache.tryGet(
|
|
48
|
+
`weibo:timeline:${uid}`,
|
|
49
|
+
async () => {
|
|
50
|
+
const _r = await got(`https://api.weibo.com/2/statuses/home_timeline.json?access_token=${token}&count=100&feature=${feature}`);
|
|
51
|
+
return _r.data;
|
|
52
|
+
},
|
|
53
|
+
config.cache.routeExpire,
|
|
54
|
+
false
|
|
55
|
+
);
|
|
38
56
|
// 检查token失效
|
|
39
|
-
if (response.
|
|
57
|
+
if (response.error !== undefined) {
|
|
40
58
|
const { app_key = '', redirect_url = ctx.request.origin + '/weibo/timeline/0' } = config.weibo;
|
|
41
59
|
|
|
42
60
|
ctx.status = 302;
|
|
@@ -46,7 +64,7 @@ module.exports = async (ctx) => {
|
|
|
46
64
|
ctx.redirect(`https://api.weibo.com/oauth2/authorize?client_id=${app_key}&redirect_uri=${redirect_url}${routeParams ? `&state=${routeParams}` : ''}`);
|
|
47
65
|
}
|
|
48
66
|
const resultItem = await Promise.all(
|
|
49
|
-
response.
|
|
67
|
+
response.statuses.map(async (item) => {
|
|
50
68
|
const key = `weibotimelineurl${item.user.id}${item.id}`;
|
|
51
69
|
const value = await ctx.cache.tryGet(key, async () => {
|
|
52
70
|
const _data = await weiboUtils.getShowData(uid, item.id);
|
|
@@ -63,7 +81,7 @@ module.exports = async (ctx) => {
|
|
|
63
81
|
// 转发的长微博处理
|
|
64
82
|
const retweet = item.retweeted_status;
|
|
65
83
|
if (retweet?.isLongText) {
|
|
66
|
-
const retweetData = await weiboUtils.getShowData(retweet.user.id, retweet.id);
|
|
84
|
+
const retweetData = await ctx.cache.tryGet(`weibo:retweeted:${retweet.user.id}:${retweet.id}`, () => weiboUtils.getShowData(retweet.user.id, retweet.id));
|
|
67
85
|
if (retweetData?.text) {
|
|
68
86
|
item.retweeted_status.text = retweetData.text;
|
|
69
87
|
}
|
|
@@ -86,6 +104,11 @@ module.exports = async (ctx) => {
|
|
|
86
104
|
}
|
|
87
105
|
}
|
|
88
106
|
|
|
107
|
+
// 评论的处理
|
|
108
|
+
if (displayComments === '1') {
|
|
109
|
+
description = await weiboUtils.formatComments(ctx, description, item);
|
|
110
|
+
}
|
|
111
|
+
|
|
89
112
|
// 文章的处理
|
|
90
113
|
if (displayArticle === '1') {
|
|
91
114
|
// 含被转发微博时需要从被转发微博中获取文章
|
|
@@ -123,7 +146,7 @@ module.exports = async (ctx) => {
|
|
|
123
146
|
const token = rep.data.access_token;
|
|
124
147
|
const uid = rep.data.uid;
|
|
125
148
|
const expires_in = rep.data.expires_in;
|
|
126
|
-
await ctx.cache.set('weibotimelineuid' + uid, token, expires_in
|
|
149
|
+
await ctx.cache.set('weibotimelineuid' + uid, token, expires_in);
|
|
127
150
|
|
|
128
151
|
ctx.set({
|
|
129
152
|
'Content-Type': 'text/html; charset=UTF-8',
|
package/lib/routes/weibo/user.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const querystring = require('querystring');
|
|
2
2
|
const got = require('@/utils/got');
|
|
3
3
|
const weiboUtils = require('./utils');
|
|
4
|
+
const config = require('@/config').value;
|
|
4
5
|
const timezone = require('@/utils/timezone');
|
|
5
6
|
const { parseDate } = require('@/utils/parse-date');
|
|
6
7
|
const { fallback, queryToBoolean } = require('@/utils/readable-social');
|
|
@@ -9,6 +10,7 @@ module.exports = async (ctx) => {
|
|
|
9
10
|
const uid = ctx.params.uid;
|
|
10
11
|
let displayVideo = '1';
|
|
11
12
|
let displayArticle = '0';
|
|
13
|
+
let displayComments = '0';
|
|
12
14
|
if (ctx.params.routeParams) {
|
|
13
15
|
if (ctx.params.routeParams === '1' || ctx.params.routeParams === '0') {
|
|
14
16
|
displayVideo = ctx.params.routeParams;
|
|
@@ -16,35 +18,52 @@ module.exports = async (ctx) => {
|
|
|
16
18
|
const routeParams = querystring.parse(ctx.params.routeParams);
|
|
17
19
|
displayVideo = fallback(undefined, queryToBoolean(routeParams.displayVideo), true) ? '1' : '0';
|
|
18
20
|
displayArticle = fallback(undefined, queryToBoolean(routeParams.displayArticle), false) ? '1' : '0';
|
|
21
|
+
displayComments = fallback(undefined, queryToBoolean(routeParams.displayComments), false) ? '1' : '0';
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
24
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
const containerData = await ctx.cache.tryGet(
|
|
26
|
+
`weibo:user:profile:${uid}`,
|
|
27
|
+
async () => {
|
|
28
|
+
const _r = await got({
|
|
29
|
+
method: 'get',
|
|
30
|
+
url: `https://m.weibo.cn/profile/info?uid=${uid}`,
|
|
31
|
+
headers: {
|
|
32
|
+
Referer: 'https://m.weibo.cn/',
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
return _r.data;
|
|
27
36
|
},
|
|
28
|
-
|
|
37
|
+
config.cache.routeExpire,
|
|
38
|
+
false
|
|
39
|
+
);
|
|
29
40
|
const name = containerData.data.user.screen_name;
|
|
30
41
|
const description = containerData.data.user.description;
|
|
31
42
|
const profileImageUrl = containerData.data.user.profile_image_url;
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
const containerId = containerData.data.more.match(/\d+/)[0];
|
|
44
|
+
|
|
45
|
+
const cards = await ctx.cache.tryGet(
|
|
46
|
+
`weibo:user:cards:${uid}:${containerId}`,
|
|
47
|
+
async () => {
|
|
48
|
+
const _r = await got({
|
|
49
|
+
method: 'get',
|
|
50
|
+
url: `https://m.weibo.cn/api/container/getIndex?containerid=${containerId}`,
|
|
51
|
+
headers: {
|
|
52
|
+
Referer: `https://m.weibo.cn/u/${uid}`,
|
|
53
|
+
'MWeibo-Pwa': 1,
|
|
54
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
return _r.data.data.cards;
|
|
41
58
|
},
|
|
42
|
-
|
|
59
|
+
config.cache.routeExpire,
|
|
60
|
+
false
|
|
61
|
+
);
|
|
43
62
|
|
|
44
63
|
let earliestDate;
|
|
45
64
|
|
|
46
65
|
const resultItem = await Promise.all(
|
|
47
|
-
|
|
66
|
+
cards
|
|
48
67
|
.reverse() // reverse first to ensure the pinned card will be processed lastly
|
|
49
68
|
.map(async (item) => {
|
|
50
69
|
if (!item.mblog && item.card_group && Array.isArray(item.card_group) && item.card_group.length > 0) {
|
|
@@ -85,7 +104,7 @@ module.exports = async (ctx) => {
|
|
|
85
104
|
// 转发的长微博处理
|
|
86
105
|
const retweet = item.mblog.retweeted_status;
|
|
87
106
|
if (retweet && retweet.isLongText) {
|
|
88
|
-
const retweetData = await weiboUtils.getShowData(retweet.user.id, retweet.bid);
|
|
107
|
+
const retweetData = await ctx.cache.tryGet(`weibo:retweeted:${retweet.user.id}:${retweet.bid}`, () => weiboUtils.getShowData(retweet.user.id, retweet.bid));
|
|
89
108
|
if (retweetData !== undefined && retweetData.text) {
|
|
90
109
|
item.mblog.retweeted_status.text = retweetData.text;
|
|
91
110
|
}
|
|
@@ -107,6 +126,11 @@ module.exports = async (ctx) => {
|
|
|
107
126
|
}
|
|
108
127
|
}
|
|
109
128
|
|
|
129
|
+
// 评论的处理
|
|
130
|
+
if (displayComments === '1') {
|
|
131
|
+
description = await weiboUtils.formatComments(ctx, description, item.mblog);
|
|
132
|
+
}
|
|
133
|
+
|
|
110
134
|
// 文章的处理
|
|
111
135
|
if (displayArticle === '1') {
|
|
112
136
|
// 含被转发微博时需要从被转发微博中获取文章
|
|
@@ -348,6 +348,45 @@ const weiboUtils = {
|
|
|
348
348
|
}
|
|
349
349
|
return itemDesc;
|
|
350
350
|
},
|
|
351
|
+
formatComments: async (ctx, itemDesc, status) => {
|
|
352
|
+
if (status && status.comments_count && status.id && status.mid) {
|
|
353
|
+
const id = status.id;
|
|
354
|
+
const mid = status.mid;
|
|
355
|
+
const link = `https://m.weibo.cn/comments/hotflow?id=${id}&mid=${mid}&max_id_type=0`;
|
|
356
|
+
const response = await ctx.cache.tryGet(link, async () => {
|
|
357
|
+
const _response = await got.get(link, {
|
|
358
|
+
headers: {
|
|
359
|
+
Referer: `https://m.weibo.cn/detail/${id}`,
|
|
360
|
+
'MWeibo-Pwa': 1,
|
|
361
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
362
|
+
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1',
|
|
363
|
+
},
|
|
364
|
+
});
|
|
365
|
+
return _response.data;
|
|
366
|
+
});
|
|
367
|
+
if (response.data && response.data.data) {
|
|
368
|
+
const comments = response.data.data;
|
|
369
|
+
itemDesc += `<br clear="both" /><div style="clear: both"></div><div style="background: #80808010;border-top:1px solid #80808030;border-bottom:1px solid #80808030;margin:0;padding:5px 20px;">`;
|
|
370
|
+
itemDesc += '<h3>热门评论</h3>';
|
|
371
|
+
comments.forEach((comment) => {
|
|
372
|
+
itemDesc += '<p style="margin-bottom: 0.5em;margin-top: 0.5em">';
|
|
373
|
+
itemDesc += `<a href="https://weibo.com/${comment.user.id}" target="_blank">${comment.user.screen_name}</a>: ${comment.text}`;
|
|
374
|
+
if (comment.comments) {
|
|
375
|
+
itemDesc += '<blockquote style="border-left:0.2em solid #80808080; margin-left: 0.3em; padding-left: 0.5em; margin-bottom: 0.5em; margin-top: 0.25em">';
|
|
376
|
+
comment.comments.forEach((comment) => {
|
|
377
|
+
itemDesc += '<div style="font-size: 0.9em">';
|
|
378
|
+
itemDesc += `<a href="https://weibo.com/${comment.user.id}" target="_blank">${comment.user.screen_name}</a>: ${comment.text}`;
|
|
379
|
+
itemDesc += '</div>';
|
|
380
|
+
});
|
|
381
|
+
itemDesc += '</blockquote>';
|
|
382
|
+
}
|
|
383
|
+
itemDesc += '</p>';
|
|
384
|
+
});
|
|
385
|
+
itemDesc += '</div>';
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return itemDesc;
|
|
389
|
+
},
|
|
351
390
|
};
|
|
352
391
|
|
|
353
392
|
module.exports = weiboUtils;
|