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.
- Loading branch information
Ethan Shen
authored
Nov 27, 2021
1 parent
56f1469
commit 1501116
Showing
8 changed files
with
166 additions
and
79 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
const got = require('@/utils/got'); | ||
const cheerio = require('cheerio'); | ||
const timezone = require('@/utils/timezone'); | ||
const { parseDate } = require('@/utils/parse-date'); | ||
const { art } = require('@/utils/render'); | ||
const path = require('path'); | ||
|
||
module.exports = async (ctx) => { | ||
let category = ctx.params.category ?? ''; | ||
let domain = ctx.query.domain ?? 'btbtt20.com'; | ||
|
||
if (category === 'base') { | ||
category = ''; | ||
domain = '88btbtt.com'; | ||
} else if (category === 'govern') { | ||
category = ''; | ||
domain = '2btjia.com'; | ||
} | ||
|
||
const rootUrl = `https://www.${domain}`; | ||
const currentUrl = `${rootUrl}${category ? `/${category}.htm` : ''}`; | ||
|
||
const response = await got({ | ||
method: 'get', | ||
url: currentUrl, | ||
}); | ||
|
||
const $ = cheerio.load(response.data); | ||
|
||
$('.bg2').prevAll('table').remove(); | ||
|
||
let items = $('#threadlist table') | ||
.toArray() | ||
.map((item) => { | ||
const a = $(item).find('.subject_link'); | ||
|
||
return { | ||
title: a.text(), | ||
link: `${rootUrl}/${a.attr('href')}`, | ||
}; | ||
}); | ||
|
||
items = await Promise.all( | ||
items.map((item) => | ||
ctx.cache.tryGet(item.link, async () => { | ||
const detailResponse = await got({ | ||
method: 'get', | ||
url: item.link, | ||
}); | ||
|
||
const content = cheerio.load(detailResponse.data); | ||
|
||
content('h2, .message').remove(); | ||
|
||
content('.attachlist') | ||
.find('a') | ||
.each(function () { | ||
content(this) | ||
.children('img') | ||
.attr('src', `${rootUrl}${content(this).children('img').attr('src')}`); | ||
content(this).attr( | ||
'href', | ||
`${rootUrl}/${content(this) | ||
.attr('href') | ||
.replace(/^attach-dialog/, 'attach-download')}` | ||
); | ||
}); | ||
|
||
const torrents = content('.attachlist').find('a'); | ||
|
||
item.description = content('.post').html(); | ||
item.author = content('.purple, .grey').first().prev().text(); | ||
item.pubDate = timezone(parseDate(content('.bg2 b').first().text()), +8); | ||
|
||
if (torrents.length > 0) { | ||
item.description += art(path.join(__dirname, 'templates/torrents.art'), { | ||
torrents: torrents.toArray().map((t) => content(t).parent().html()), | ||
}); | ||
item.enclosure_type = 'application/x-bittorrent'; | ||
item.enclosure_url = torrents.first().attr('href'); | ||
} | ||
|
||
return item; | ||
}) | ||
) | ||
); | ||
|
||
ctx.state.data = { | ||
title: `${$('#menu, #threadtype') | ||
.find('.checked') | ||
.toArray() | ||
.map((c) => $(c).text()) | ||
.filter((c) => c !== '全部') | ||
.join('|')} - BT之家`, | ||
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,3 @@ | ||
module.exports = { | ||
'/:category?': ['nczitzk'], | ||
}; |
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,13 @@ | ||
module.exports = { | ||
'btbtt20.com': { | ||
_name: 'BT之家', | ||
'.': [ | ||
{ | ||
title: '分类', | ||
docs: 'https://docs.rsshub.app/multimedia.html#bt-zhi-jia', | ||
source: ['/'], | ||
target: '/btzj/:category?', | ||
}, | ||
], | ||
}, | ||
}; |
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,3 @@ | ||
module.exports = function (router) { | ||
router.get('/:category?', require('./index')); | ||
}; |
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,5 @@ | ||
<table> | ||
{{ each torrents torrent }} | ||
<tr><td>{{ torrent }}</td></tr> | ||
{{ /each }} | ||
</table> |