diff --git a/docs/en/multimedia.md b/docs/en/multimedia.md index 43f979fff..a63cf4ddc 100644 --- a/docs/en/multimedia.md +++ b/docs/en/multimedia.md @@ -369,6 +369,16 @@ Refer to [Pornhub F.A.Qs](https://help.pornhub.com/hc/en-us/articles/36004432703 +## u3c3 + +### Keyword Search + + + +### Type + + + ## YouTube Refer to [#youtube](/en/social-media.html#youtube) diff --git a/docs/multimedia.md b/docs/multimedia.md index 7fa6780de..dbe635327 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -1101,6 +1101,16 @@ JavDB 有多个备用域名,本路由默认使用永久域名 +## u3c3 + +### 关键词搜索 + + + +### 分类 + + + ## YouTube 见 [#youtube](/social-media.html#youtube) diff --git a/lib/v2/u3c3/index.js b/lib/v2/u3c3/index.js new file mode 100644 index 000000000..c8f057663 --- /dev/null +++ b/lib/v2/u3c3/index.js @@ -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, + }; +}; diff --git a/lib/v2/u3c3/maintainer.js b/lib/v2/u3c3/maintainer.js new file mode 100644 index 000000000..6283caeac --- /dev/null +++ b/lib/v2/u3c3/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:type?/:keyword?': ['noname1897'] +}; diff --git a/lib/v2/u3c3/radar.js b/lib/v2/u3c3/radar.js new file mode 100644 index 000000000..934926242 --- /dev/null +++ b/lib/v2/u3c3/radar.js @@ -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}`; + } + }, + }, + ], + }, +}; diff --git a/lib/v2/u3c3/router.js b/lib/v2/u3c3/router.js new file mode 100644 index 000000000..1b78935d6 --- /dev/null +++ b/lib/v2/u3c3/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/:type?/:keyword?', require('./index')); +};