feat: add route for girlimg - album (#4425)
This commit is contained in:
@@ -44,6 +44,12 @@ pageClass: routes
|
||||
|
||||
</Route>
|
||||
|
||||
## GirlImg
|
||||
|
||||
### album
|
||||
|
||||
<Route author="junfengP" example="/girlimg/album" path="/girlimg/album/:tag?/:mode?" :paramsDesc="['过滤标签,在链接参数中&tab=部分,如:中国,BoLoLi','加载模式,留空为简单模式,获取20篇文章标题与封面;非空为详细模式,加载10篇文章内容']" />
|
||||
|
||||
## Google Doodles
|
||||
|
||||
### 更新
|
||||
|
||||
@@ -2529,4 +2529,7 @@ router.get('/ccreports/article', require('./routes/ccreports'));
|
||||
// iYouPort
|
||||
router.get('/iyouport/article', require('./routes/iyouport'));
|
||||
|
||||
// girlimg
|
||||
router.get('/girlimg/album/:tag?/:mode?', require('./routes/girlimg/album'));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
const got = require('@/utils/got');
|
||||
const CryptoJS = require('crypto-js');
|
||||
const password = 'gefdzfdef';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const tag = ctx.params.tag ? ctx.params.tag : 'all';
|
||||
const mode = ctx.params.mode ? ctx.params.mode : 'simple';
|
||||
const limit = 'simple' === mode ? 20 : 10;
|
||||
|
||||
const url = `https://girlimg.epio.app/api/articles?lang=en-us&filter={"where":{"tag":"${tag}","lang":"en-us"},"limit":20,"skip":0}`;
|
||||
|
||||
const index_json = await fetchUrl(url);
|
||||
|
||||
const items = await Promise.all(
|
||||
index_json.slice(0, limit).map(async (item) => {
|
||||
const simple = {
|
||||
title: item.title,
|
||||
link: `https://girlimg.epio.app/article/detail/${item._id}`,
|
||||
pubDate: new Date(item.release_date).toUTCString(),
|
||||
};
|
||||
let details;
|
||||
if ('simple' === mode) {
|
||||
details = {
|
||||
description: item.cover,
|
||||
};
|
||||
} else {
|
||||
details = await ctx.cache.tryGet(item._id, async () => {
|
||||
const data = await fetchUrl(`https://girlimg.epio.app/api/articles/${item._id}?lang=en-us`);
|
||||
return {
|
||||
description: data.content,
|
||||
};
|
||||
});
|
||||
}
|
||||
return Promise.resolve(Object.assign({}, simple, details));
|
||||
})
|
||||
);
|
||||
ctx.state.data = {
|
||||
title: 'girlimg - album',
|
||||
link: `https://girlimg.epio.app`,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
||||
async function fetchUrl(url) {
|
||||
const encrypt_json = (
|
||||
await got({
|
||||
method: 'get',
|
||||
url: url,
|
||||
headers: {
|
||||
Referer: 'https://girlimg.epio.app/',
|
||||
},
|
||||
})
|
||||
).data;
|
||||
|
||||
const bytes = CryptoJS.AES.decrypt(encrypt_json.string, password);
|
||||
return JSON.parse(bytes.toString(CryptoJS.enc.Utf8));
|
||||
}
|
||||
@@ -68,6 +68,7 @@
|
||||
"chrono-node": "1.4.5",
|
||||
"cloudscraper": "4.6.0",
|
||||
"co-redis": "2.1.1",
|
||||
"crypto-js": "4.0.0",
|
||||
"currency-symbol-map": "4.0.4",
|
||||
"dayjs": "1.8.24",
|
||||
"dotenv": "8.2.0",
|
||||
|
||||
@@ -3764,6 +3764,11 @@ crypto-browserify@^3.11.0:
|
||||
randombytes "^2.0.0"
|
||||
randomfill "^1.0.3"
|
||||
|
||||
crypto-js@4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.npm.taobao.org/crypto-js/download/crypto-js-4.0.0.tgz?cache=0&sync_timestamp=1581509247325&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcrypto-js%2Fdownload%2Fcrypto-js-4.0.0.tgz#2904ab2677a9d042856a2ea2ef80de92e4a36dcc"
|
||||
integrity sha1-KQSrJnep0EKFai6i74DekuSjbcw=
|
||||
|
||||
crypto-random-string@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-2.0.0.tgz#ef2a7a966ec11083388369baa02ebead229b30d5"
|
||||
|
||||
Reference in New Issue
Block a user