forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from DIYgod/master
[pull] master from diygod:master
- Loading branch information
Showing
21 changed files
with
279 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,31 @@ | ||
const path = require('path'); | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const { art } = require('@/utils/render'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
|
||
module.exports = async (ctx) => { | ||
const response = await got({ | ||
method: 'get', | ||
url: 'https://nsfw.ahhhhfs.com/articles-archive/', | ||
url: 'https://nsfw.abskoop.com/wp-json/wp/v2/posts', | ||
searchParams: { | ||
per_page: ctx.query.limit ? parseInt(ctx.query.limit) : 10, | ||
_embed: '', | ||
}, | ||
}); | ||
|
||
const $list = cheerio.load(response.data); | ||
const list = $list('article li') | ||
.slice(0, 20) | ||
.map(function () { | ||
return { | ||
link: $list(this).find('a').attr('href'), | ||
}; | ||
}) | ||
.get(); | ||
|
||
const items = await Promise.all( | ||
list.map((item) => | ||
ctx.cache.tryGet(item.link, async () => { | ||
const detailResponse = await got({ method: 'get', url: item.link }); | ||
const $detail = cheerio.load(detailResponse.data); | ||
$detail('article .entry-content a').each(function () { | ||
if ($detail(this).find('img').length > 0) { | ||
$detail(this).replaceWith(`<img src=${$detail(this).attr('href')}>`); | ||
} | ||
}); | ||
const desc = []; | ||
$detail('article .entry-content > p').each(function () { | ||
desc.push($detail(this).html()); | ||
}); | ||
item.title = $detail('article h1.entry-title').text(); | ||
item.description = art(path.join(__dirname, 'templates/description.art'), { desc }); | ||
item.pubDate = parseDate($detail('meta[property="article:published_time"]').attr('content')); | ||
return item; | ||
}) | ||
) | ||
); | ||
const list = response.data.map((item) => ({ | ||
title: item.title.rendered, | ||
description: item.content.rendered, | ||
link: item.link, | ||
pubDate: parseDate(item.date_gmt), | ||
updated: parseDate(item.modified_gmt), | ||
author: item._embedded.author[0].name, | ||
category: [...new Set(item._embedded['wp:term'].flatMap((i) => i.map((j) => j.name)))], | ||
})); | ||
|
||
ctx.state.data = { | ||
title: 'ahhhhfs-A姐分享NSFW', | ||
link: 'https://nsfw.ahhhhfs.com', | ||
link: 'https://nsfw.ahhhhfs.com/articles-archive', | ||
description: | ||
'A姐分享NSFW,分享各种网络云盘资源、BT种子、磁力链接、高清电影电视剧和羊毛福利,收集各种有趣实用的软件和APP的下载、安装、使用方法,发现一些稀奇古怪的的网站,折腾一些有趣实用的教程,关注谷歌苹果等互联网最新的资讯动态,探索新领域,发现新美好,分享小快乐。', | ||
item: items, | ||
item: list, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.