feat(route): add u3c3 (#10062)

* feat(route): add u3c3

- u3c3 的几个子分类页面
- 搜索功能
- torrent/magnet
- 中英文档

* Update docs/en/multimedia.md

docs(u3c3): fix typo in english document

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/v2/u3c3/index.js

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* feat(radar): add u3c3.com radar

* refactor(u3c3): clean code

* docs(u3c3): fix lost info in u3c3 english document

* fix(radar): fix typo in u3c3 radar

Co-authored-by: noname <no-email@no.email>
This commit is contained in:
noname1897
2022-06-30 00:09:20 +08:00
committed by GitHub
co-authored by Tony noname
parent 4849f8b202
commit e6f0cc8f4c
6 changed files with 114 additions and 0 deletions
+10
View File
@@ -369,6 +369,16 @@ Refer to [Pornhub F.A.Qs](https://help.pornhub.com/hc/en-us/articles/36004432703
<RouteEn author="hoilc" example="/trakt/collection/tomyangsh/movies" path="/trakt/collection/:username/:type?" :paramsDesc="['Username','Collection type, can be `movies`,`shows`,`episodes`,`all`, default to `all`']" radar="1" rssbud="1" />
## u3c3
### Keyword Search
<RouteEn author="noname1897" example="/u3c3/search/les" path="/u3c3/search/:keyword?" :paramsDesc="['search keyword']" supportBT="1" radar="1"/>
### Type
<RouteEn author="noname1897" example="/u3c3/U3C3" path="/u3c3/:type?" :paramsDesc="['type, pay attention to case, it should be exactly same as the choices: `U3C3`/`Video`/`Photo`/`Book`/`Game`/`Software`/`Other`, if no type is provided, show the home index']" supportBT="1" radar="1"/>
## YouTube
Refer to [#youtube](/en/social-media.html#youtube)
+10
View File
@@ -1101,6 +1101,16 @@ JavDB 有多个备用域名,本路由默认使用永久域名 <https://javdb.c
<Route author="sakamossan" example="/yahoo-jp-tv/%E8%8A%B1%E6%BE%A4%E9%A6%99%E8%8F%9C" path="/yahoo-jp-tv/:query" :paramsDesc="['搜索查询']"/>
## u3c3
### 关键词搜索
<Route author="noname1897" example="/u3c3/search/新片速递" path="/u3c3/search/:keyword?" :paramsDesc="['搜索关键字']" supportBT="1" radar="1" />
### 分类
<Route author="noname1897" example="/u3c3/U3C3" path="/u3c3/:type?" :paramsDesc="['类别名称,注意大小写,需要严格对应!可选的 `type` 有 `U3C3`/`Video`/`Photo`/`Book`/`Game`/`Software`/`Other`,如果不设置 type,则展示首页']" supportBT="1" radar="1" />
## YouTube
见 [#youtube](/social-media.html#youtube)
+59
View File
@@ -0,0 +1,59 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const type = ctx.params.type;
// should be:
// undefined
// U3C3
// Videos
// Photo
// Book
// Game
// Software
// Other
const rootURL = 'https://www.u3c3.com';
let currentURL;
let title;
if (typeof type === 'undefined') {
currentURL = rootURL;
title = 'home - u3c3';
} else if (type === 'search') {
const keyword = typeof ctx.params.keyword === 'undefined' ? '' : ctx.params.keyword;
currentURL = `${rootURL}/?search=${keyword}`;
title = `search ${keyword} - u3c3`;
} else {
currentURL = `${rootURL}/?type=${type}&p=1`;
title = `${type} - u3c3`;
}
const response = await got(currentURL);
const $ = cheerio.load(response.data);
const items = $('body > div.container > div.table-responsive > table > tbody > tr')
.toArray()
.map((item) => {
item = $(item);
const title = item.find('td:nth-of-type(2) > a ').attr('title');
const guid = rootURL + item.find('td:nth-of-type(2) > a').attr('href');
const link = guid;
const pubDate = item.find('td:nth-of-type(5)').text();
const enclosure_url = item.find('td:nth-of-type(3) > a:nth-of-type(2)').attr('href');
return {
title,
guid,
link,
pubDate,
enclosure_url,
enclosure_type: 'application/x-bittorrent',
};
});
ctx.state.data = {
title,
description: title,
link: currentURL,
item: items,
};
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/:type?/:keyword?': ['noname1897']
};
+29
View File
@@ -0,0 +1,29 @@
module.exports = {
'u3c3.com': {
_name: 'u3c3',
'.': [
{
title: '分类',
docs: 'https://docs.rsshub.app/multimedia.html#u3c3-fen-lei',
source: '/',
target: (params, url) => {
const searchParams = new URL(url).searchParams;
const type = searchParams.has('type') ? searchParams.get('type') : '';
return `/u3c3/${type}`;
},
},
{
title: '关键词搜索',
docs: 'https://docs.rsshub.app/multimedia.html#u3c3-guan-jian-ci-sou-suo',
source: '/',
target: (params, url) => {
const searchParams = new URL(url).searchParams;
if (searchParams.has('search')) {
const keyword = searchParams.get('search');
return `/u3c3/search/${keyword}`;
}
},
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/:type?/:keyword?', require('./index'));
};