diff --git a/docs/anime.md b/docs/anime.md index c0cf6e16e3..af3891b158 100644 --- a/docs/anime.md +++ b/docs/anime.md @@ -79,6 +79,18 @@ pageClass: routes 见 [#bilibili](/social-media.html#bilibili) +## DLsite + +### 当前日期发售产品 + + + +| 同人 | 漫画 | 软件 | 同人(R18) | 漫画(R18) | 美少女游戏 | 乙女 | BL | +| ---- | ----- | ---- | --------- | --------- | ---------- | ----- | --- | +| home | comic | soft | maniax | books | pro | girls | bl | + + + ## ebb.io ### ebb diff --git a/lib/router.js b/lib/router.js index b3aa25d664..378497aeef 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1861,6 +1861,9 @@ router.get('/hatena/anonymous_diary/archive', require('./routes/hatena/anonymous // kaggle router.get('/kaggle/discussion/:forumId/:sort?', require('./routes/kaggle/discussion')); +// dlsite +router.get('/dlsite/new/:type', require('./routes/dlsite/new')); + // mcbbs router.get('/mcbbs/forum/:type', require('./routes/mcbbs/forum')); router.get('/mcbbs/post/:tid/:authorid?', require('./routes/mcbbs/post')); diff --git a/lib/routes/dlsite/new.js b/lib/routes/dlsite/new.js new file mode 100644 index 0000000000..757885a084 --- /dev/null +++ b/lib/routes/dlsite/new.js @@ -0,0 +1,108 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +const host = 'https://www.dlsite.com'; +const infos = { + // 全年齢向け + home: { + type: 'home', + name: '「DLsite 同人」', + url: '/home/new', + }, + comic: { + type: 'comic', + name: '「DLsite コミック」', + url: '/comic/new', + }, + soft: { + type: 'soft', + name: '「DLsite PCソフト」', + url: '/soft/new', + }, + // 成人向け( R18 ) + maniax: { + type: 'maniax', + name: '「DLsite 同人 - R18」', + url: '/maniax/new', + }, + books: { + type: 'books', + name: '「DLsite 成年コミック - R18」', + url: '/books/new', + }, + pro: { + type: 'pro', + name: '「DLsite 美少女ゲーム」', + url: '/pro/new', + }, + // 女性向け + girls: { + type: 'girls', + name: '「DLsite 乙女」', + url: '/girls/new', + }, + bl: { + type: 'bl', + name: '「DLsite BL」', + url: '/bl/new', + }, +}; + +module.exports = async (ctx) => { + const info = infos[ctx.params.type]; + // 判断参数是否合理 + if (info === undefined) { + throw Error('不支持指定类型!'); + } + + const response = await got(info.url, { + method: 'GET', + baseUrl: host, + }); + const data = response.data; + const $ = cheerio.load(data); + + const title = $('title').text(); + const link = response.requestUrl; + const description = $('meta[name="description"]').attr('content'); + const list = $('.n_worklist_item'); + const dateText = $('.work_update') + .text() + .replace(/(年 |月)/g, '-') + .substring(0, 10); + const pubDate = new Date(`${dateText} GMT+0900`).toUTCString(); + const item = list + .map((index, element) => { + const title = $('.work_name', element).text(); + const link = $('.work_name > a', element).attr('href'); + // 使链接 + $('a', element).each((index, element) => { + $(element).attr('target', '_blank'); + }); + const description = $(element).html(); + const arr = $('.search_tag', element); + const category = $('a', arr) + .map((index, a) => $(a).text()) + .get(); + const author = $('.maker_name', element).text(); + + const signle = { + title: title, + link: link, + description: description, + category: category, + author: author, + pubDate: pubDate, + }; + return signle; + }) + .get(); + + ctx.state.data = { + title: title, + link: link, + description: description, + language: 'ja-jp', + item: item, + }; +};