forked from chengxuanying/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.
feat(route): add FIX字幕侠 (DIYgod#7412)
Co-authored-by: NeverBehave <[email protected]>
- Loading branch information
1 parent
4c499e3
commit d32b904
Showing
4 changed files
with
116 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
|
||
module.exports = async (ctx) => { | ||
const category = ctx.params.category || ''; | ||
|
||
const rootUrl = 'https://www.zimuxia.cn'; | ||
const currentUrl = `${rootUrl}/我们的作品?cat=${category}`; | ||
const response = await got({ | ||
method: 'get', | ||
url: currentUrl, | ||
}); | ||
|
||
const $ = cheerio.load(response.data); | ||
|
||
const list = $('.pg-item a') | ||
.slice(0, 10) | ||
.map((_, item) => { | ||
item = $(item); | ||
|
||
return { | ||
title: item.find('h2').text(), | ||
link: item.attr('href'), | ||
}; | ||
}) | ||
.get(); | ||
|
||
const items = await Promise.all( | ||
list.map( | ||
async (item) => | ||
await ctx.cache.tryGet(item.link, async () => { | ||
const detailResponse = await got({ | ||
method: 'get', | ||
url: item.link, | ||
}); | ||
const content = cheerio.load(detailResponse.data); | ||
|
||
const links = detailResponse.data.match(/<a href="magnet:(.*?)" target="_blank">磁力下载<\/a>/g); | ||
|
||
if (links) { | ||
item.enclosure_type = 'application/x-bittorrent'; | ||
item.enclosure_url = links.pop().match(/<a href="(.*)" target="_blank">磁力下载<\/a>/)[1]; | ||
} | ||
|
||
item.description = content('.content-box').html(); | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
|
||
ctx.state.data = { | ||
title: `${category || 'ALL'} - FIX字幕侠`, | ||
link: currentUrl, | ||
item: items, | ||
}; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
|
||
module.exports = async (ctx) => { | ||
const id = ctx.params.id; | ||
|
||
const rootUrl = 'http://zimuxia.cn'; | ||
const currentUrl = `${rootUrl}/portfolio/${id}`; | ||
const response = await got({ | ||
method: 'get', | ||
url: currentUrl, | ||
}); | ||
|
||
const $ = cheerio.load(response.data); | ||
|
||
const items = $('a') | ||
.filter(function () { | ||
return $(this).attr('href').substr(0, 7) === 'magnet:'; | ||
}) | ||
.reverse() | ||
.map((_, item) => { | ||
item = $(item); | ||
|
||
return { | ||
link: currentUrl, | ||
title: item.parent().text().split(' ')[0], | ||
description: `<p>${item.parent().html()}</p>`, | ||
enclosure_url: item.attr('href'), | ||
enclosure_type: 'application/x-bittorrent', | ||
}; | ||
}) | ||
.get(); | ||
|
||
ctx.state.data = { | ||
title: `${$('.content-page-title').text()} - FIX字幕侠`, | ||
link: currentUrl, | ||
item: items, | ||
}; | ||
}; |