fix(route): zimuxia portfolio.js compatible for old stype and support ed2k baidu (#13783)

* fix(route): zimuxia portfolio.js compatible for old stype and support ed2k

page like https://www.zimuxia.cn/portfolio/9%E5%8F%B7%E7%A7%98%E4%BA%8B the a were not wrap in div or p, only seperated by <br>

https://rsshub.app/zimuxia/portfolio/9%E5%8F%B7%E7%A7%98%E4%BA%8B

* lint

* limited regex to a list to avoid vulnerability

* fix doc

* fix doc

---------

Co-authored-by: Beisi Xu <beisi.xu@stjude.org>
This commit is contained in:
Beisi Xu
2023-11-16 22:31:09 +08:00
committed by GitHub
co-authored by Beisi Xu
parent 10082eb817
commit 817f683a6a
2 changed files with 14 additions and 7 deletions
+8 -7
View File
@@ -1,8 +1,12 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const allowlinktypes = [ 'all', 'magnet', 'ed2k', 'baidu', 'subhd', 'quark', '115' ];
module.exports = async (ctx) => {
const id = ctx.params.id;
let linktype = ctx.query.linktype ?? 'magnet';
linktype = allowlinktypes.includes(linktype) ? linktype : 'magnet';
linktype = linktype === "all" ? "." : linktype;
const rootUrl = 'https://www.zimuxia.cn';
const currentUrl = `${rootUrl}/portfolio/${id}`;
@@ -17,16 +21,13 @@ module.exports = async (ctx) => {
const $ = cheerio.load(response.data);
const items = $('a')
.filter((_, el) => $(el).attr('href')?.startsWith('magnet:'))
.filter((_, el) => $(el).attr('href')?.match(RegExp(linktype)))
.toArray()
.map((item) => {
item = $(item);
const title = item
.parent()
.contents()
.filter((_, el) => el.type === 'text')
.text()
.trim();
const tmpstr2match = $.html(item.parent().children()[item.prevAll("br").first().index() + 1]);
const tmphtml = item.parent().contents().toArray().map((item) => $.html($(item)));
const title = tmphtml[tmphtml.indexOf(tmpstr2match) - 1].trim().replace(/\s.*|&nbsp;.*/, "");
return {
link: currentUrl,
+6
View File
@@ -535,6 +535,12 @@ Official RSS: [https://eztv.io/ezrss.xml](https://eztv.io/ezrss.xml)
<Route author="nczitzk" example="/zimuxia/portfolio/我们这一天" path="/zimuxia/portfolio/:id" paramsDesc={['剧集名,可在剧集页 URL 中找到']} />
:::tip
本路由以 `magnet` 为默认linktype,可以通过在路由后方加上 `?linktype=链接类型` 指定导出的链接类型。比如路由为 [`/zimuxia/portfolio/我们这一天?linktype=baidu`](https://rsshub.app/zimuxia/portfolio/我们这一天?linktype=baidu) 来导出百度盘链接. 目前,你可以选择的 `链接类型` 包括: `magnet`(默认), `all`(所有), `ed2k`(电驴), `baidu`(百度盘), `quark`(夸克盘), `115`(115盘), `subhd`(字幕).
:::
### Lookup Torrents by IMDB ID {#fix-zi-mu-xia-lookup-torrents-by-imdb-id}
<Route author="Songkeys" example="/eztv/torrents/6048596" path="/eztv/torrents/:imdb_id" paramsDesc={['想搜寻的 show 的种子所对应的 IMDB ID, 可在 [IMDB](https://www.imdb.com) 官网找到']} supportBT="1"/>