diff --git a/docs/anime.md b/docs/anime.md index ea29b6ae0..8472823fe 100644 --- a/docs/anime.md +++ b/docs/anime.md @@ -436,6 +436,56 @@ Sources +## QooApp + +### 遊戲庫 - 評論 + + + +| 中文 | English | 한국어 | Español | 日本語 | ไทย | Tiếng Việt | +| -- | ------- | --- | ------- | --- | --- | ---------- | +| | en | ko | es | ja | th | vi | + + + +### 遊戲庫 - 情報 + + + +### 遊戲庫 - 筆記 + + + +### 遊戲庫 - 曬卡 + + + +### 資訊 + + + +| 中文 | English | +| -- | ------- | +| | en | + + + +### 筆記留言 + + + +### 熱門話題 + + + +### 用户遊戲評論 + + + +### 用户筆記 + + + ## say 花火 ### 文章 diff --git a/docs/en/anime.md b/docs/en/anime.md index 6c0dc4e1e..3181e88a7 100644 --- a/docs/en/anime.md +++ b/docs/en/anime.md @@ -120,6 +120,56 @@ The RSS routing has not been rigorously tested and the information provided cann +## QooApp + +### Game Store - Review + + + +| 中文 | English | 한국어 | Español | 日本語 | ไทย | Tiếng Việt | +| -- | ------- | --- | ------- | --- | --- | ---------- | +| | en | ko | es | ja | th | vi | + + + +### Game Store - Article + + + +### Game Store - Notes + + + +### Game Store - Cards + + + +### News + + + +| 中文 | English | +| -- | ------- | +| | en | + + + +### Note Comments + + + +### Hot Hashtags + + + +### User Game Comments + + + +### User Notes + + + ## THBWiki ### Calendar diff --git a/lib/v2/qoo-app/apps/card.js b/lib/v2/qoo-app/apps/card.js new file mode 100644 index 000000000..30809e107 --- /dev/null +++ b/lib/v2/qoo-app/apps/card.js @@ -0,0 +1,38 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); +const { appsUrl } = require('../utils'); + +module.exports = async (ctx) => { + const { id, lang = '' } = ctx.params; + const link = `${appsUrl}${lang ? `/${lang}` : ''}/app-card/${id}`; + + const { data: response } = await got(link); + const $ = cheerio.load(response); + + const items = $('.qoo-post-item') + .toArray() + .map((item) => { + item = $(item); + const name = item.find('.qoo-clearfix .name a'); + const author = name.eq(0).text(); + const pubDate = timezone(parseDate(item.find('time').text(), 'YYYY-MM-DD HH:mm:ss'), 8); + item.find('a.icon, .qoo-clearfix, footer, article.qoo-comment-panel, div.slot').remove(); + item.find('.img-list').attr('data-target', ''); + return { + title: `${author} ▶ ${name.eq(1).text()}`, + description: item.html(), + pubDate, + author, + guid: `qoo-app:apps:card:7675:${item.attr('data-id')}`, + }; + }); + + ctx.state.data = { + title: $('head title').text(), + link, + language: $('html').attr('lang'), + item: items, + }; +}; diff --git a/lib/v2/qoo-app/apps/comment.js b/lib/v2/qoo-app/apps/comment.js new file mode 100644 index 000000000..78fa1afe6 --- /dev/null +++ b/lib/v2/qoo-app/apps/comment.js @@ -0,0 +1,43 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); +const { appsUrl } = require('../utils'); +const { art } = require('@/utils/render'); +const path = require('path'); + +module.exports = async (ctx) => { + const { id, lang = '' } = ctx.params; + const link = `${appsUrl}${lang ? `/${lang}` : ''}/app-comment/${id}`; + + const { data: response } = await got(link, { + searchParams: { + sort: 'create', + }, + }); + const $ = cheerio.load(response); + + const items = $('.qoo-post-item') + .toArray() + .map((item) => { + item = $(item); + const author = item.find('.qoo-clearfix .name a').eq(0).text(); + return { + title: `${author} ▶ ${item.find('.qoo-clearfix .name a').eq(1).text()}`, + link: item.find('a.bg-click-wrap').attr('href'), + description: art(path.join(__dirname, '../templates/comment.art'), { + rating: item.find('.qoo-rating-bar').text().trim(), + text: item.find('.text-view').html(), + }), + pubDate: timezone(parseDate(item.find('time').text(), 'YYYY-MM-DD HH:mm:ss'), 8), + author, + }; + }); + + ctx.state.data = { + title: $('head title').text(), + link, + language: $('html').attr('lang'), + item: items, + }; +}; diff --git a/lib/v2/qoo-app/apps/note.js b/lib/v2/qoo-app/apps/note.js new file mode 100644 index 000000000..8d911f96d --- /dev/null +++ b/lib/v2/qoo-app/apps/note.js @@ -0,0 +1,47 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); +const { appsUrl } = require('../utils'); + +module.exports = async (ctx) => { + const { id, lang = '' } = ctx.params; + const link = `${appsUrl}${lang ? `/${lang}` : ''}/app-note/${id}`; + + const { data: response } = await got(link); + const $ = cheerio.load(response); + + const list = $('.qoo-note-wrap') + .toArray() + .map((item) => { + item = $(item); + return { + title: item.find('.content-title').text() || item.find('.description').text(), + link: item.find('a.link-wrap').attr('href'), + description: item.find('.description').text(), + pubDate: timezone(parseDate(item.find('time').text(), 'YYYY-MM-DD HH:mm'), 8), + author: item.find('cite.name').text(), + }; + }); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const { data: response } = await got(item.link); + const $ = cheerio.load(response); + + $('footer').remove(); + item.description = $('article .content').html(); + + return item; + }) + ) + ); + + ctx.state.data = { + title: $('head title').text(), + link, + language: $('html').attr('lang'), + item: items, + }; +}; diff --git a/lib/v2/qoo-app/apps/post.js b/lib/v2/qoo-app/apps/post.js new file mode 100644 index 000000000..c7f1b5f8a --- /dev/null +++ b/lib/v2/qoo-app/apps/post.js @@ -0,0 +1,51 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); +const { appsUrl, newsUrl, fixImg } = require('../utils'); + +module.exports = async (ctx) => { + const { id, lang = '' } = ctx.params; + const link = `${appsUrl}${lang ? `/${lang}` : ''}/app-post/${id}`; + + const { data: response } = await got(link); + const $ = cheerio.load(response); + + const list = $('.qoo-post-item') + .toArray() + .map((item) => { + item = $(item); + const a = item.find('a'); + return { + title: a.attr('title'), + link: a.attr('href'), + // description: item.find('.img-list').html() + item.find('.text-view').html(), + pubDate: timezone(parseDate(item.find('time').text(), 'YYYY-MM-DD HH:mm'), 8), + author: item.find('cite.name').text(), + postId: a.attr('href').split('/').pop(), + }; + }); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const { data } = await got(`${newsUrl}${lang ? `/${lang}` : ''}/wp-json/wp/v2/posts/${item.postId}`); + const $ = cheerio.load(data.content.rendered, null, false); + + fixImg($); + + item.description = $.html(); + item.pubDate = parseDate(data.date_gmt); + + return item; + }) + ) + ); + + ctx.state.data = { + title: $('head title').text(), + link, + language: $('html').attr('lang'), + item: items, + }; +}; diff --git a/lib/v2/qoo-app/maintainer.js b/lib/v2/qoo-app/maintainer.js new file mode 100644 index 000000000..30f1f44a5 --- /dev/null +++ b/lib/v2/qoo-app/maintainer.js @@ -0,0 +1,11 @@ +module.exports = { + '/apps/:lang?/card/:id': ['TonyRL'], + '/apps/:lang?/comment/:id': ['TonyRL'], + '/apps/:lang?/note/:id': ['TonyRL'], + '/apps/:lang?/post/:id': ['TonyRL'], + '/notes/:lang?/note/:id': ['TonyRL'], + '/notes/:lang?/topic/:topic': ['TonyRL'], + '/notes/:lang?/user/:uid': ['TonyRL'], + '/news/:lang?': ['TonyRL'], + '/user/:lang?/appComment/:uid': ['TonyRL'], +}; diff --git a/lib/v2/qoo-app/news.js b/lib/v2/qoo-app/news.js new file mode 100644 index 000000000..2506c2c40 --- /dev/null +++ b/lib/v2/qoo-app/news.js @@ -0,0 +1,41 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +const { newsUrl, siteIcon, fixImg } = require('./utils'); + +module.exports = async (ctx) => { + const { lang = '' } = ctx.params; + const apiUrl = `${newsUrl}${lang ? `/${lang}` : ''}/wp-json/wp/v2/posts`; + + const { data } = await got(apiUrl, { + searchParams: { + per_page: ctx.query.limit ? parseInt(ctx.query.limit) : 100, + }, + }); + + const items = data.map((item) => { + const $ = cheerio.load(item.content.rendered, null, false); + + fixImg($); + + return { + title: item.title.rendered, + link: item.link.substring(0, item.link.lastIndexOf('/')), + description: $.html(), + pubDate: parseDate(item.date_gmt), + }; + }); + + ctx.state.data = { + title: 'QooApp : Anime Game Platform', + description: + lang !== 'en' + ? 'QooApp 是專注二次元的專業平台,旨在聚集世界各地熱愛ACG的用戶,為他們創造有價值的服務和產品。從遊戲商店、新聞資訊、玩家社群,到線下聚會、漫畫閱讀、遊戲發行——QooApp不斷進化中,拓展突破次元的遊玩體驗。' + : 'QooApp is a professional platform specialising in Anime, Comics and Games (ACG) culture. We aim to unite ACG fans around the globe and help them as thoroughly as we can.', + image: siteIcon, + link: `${newsUrl}${lang ? `/${lang}` : ''}`, + language: lang !== 'en' ? 'zh' : 'en', + item: items, + }; +}; diff --git a/lib/v2/qoo-app/notes/note.js b/lib/v2/qoo-app/notes/note.js new file mode 100644 index 000000000..e4a148c3a --- /dev/null +++ b/lib/v2/qoo-app/notes/note.js @@ -0,0 +1,43 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const { ssoUrl, notesUrl } = require('../utils'); +const { art } = require('@/utils/render'); +const path = require('path'); + +module.exports = async (ctx) => { + const { id } = ctx.params; + const api = `${ssoUrl}/api/v1/comments`; + const link = `${notesUrl}/note/${id}`; + + const { data: response } = await got(link); + const $ = cheerio.load(response); + + const { data } = await got(api, { + searchParams: { + sort: 'newest', + for: 'web', + limit: ctx.query.limit ? parseInt(ctx.query.limit) : 100, + type: 'note', + object_id: id, + }, + }); + + const items = data.data.map((item) => ({ + title: item.content, + description: art(path.join(__dirname, '../templates/note.art'), { + content: item.content, + picture: item.picture, + }), + pubDate: parseDate(item.created_timestamp), + author: item.user.name, + guid: `qoo-app:notes:note:${id}:${item.id}`, + })); + + ctx.state.data = { + title: $('head title').text(), + link, + language: $('html').attr('lang'), + item: items, + }; +}; diff --git a/lib/v2/qoo-app/notes/topic.js b/lib/v2/qoo-app/notes/topic.js new file mode 100644 index 000000000..0f99cba5d --- /dev/null +++ b/lib/v2/qoo-app/notes/topic.js @@ -0,0 +1,20 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { notesUrl, extractNotes } = require('../utils'); + +module.exports = async (ctx) => { + const { topic, lang } = ctx.params; + const link = `${notesUrl}${lang ? `/${lang}` : ''}/topic/${topic}`; + + const { data: response } = await got(link); + const $ = cheerio.load(response); + + const items = extractNotes($); + + ctx.state.data = { + title: $('head title').text(), + link, + language: $('html').attr('lang'), + item: items, + }; +}; diff --git a/lib/v2/qoo-app/notes/user.js b/lib/v2/qoo-app/notes/user.js new file mode 100644 index 000000000..cd721fd8e --- /dev/null +++ b/lib/v2/qoo-app/notes/user.js @@ -0,0 +1,20 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { notesUrl, extractNotes } = require('../utils'); + +module.exports = async (ctx) => { + const { uid, lang } = ctx.params; + const link = `${notesUrl}${lang ? `/${lang}` : ''}/user/${uid}`; + + const { data: response } = await got(link); + const $ = cheerio.load(response); + + const items = extractNotes($); + + ctx.state.data = { + title: $('head title').text(), + link, + language: $('html').attr('lang'), + item: items, + }; +}; diff --git a/lib/v2/qoo-app/radar.js b/lib/v2/qoo-app/radar.js new file mode 100644 index 000000000..df7ae894b --- /dev/null +++ b/lib/v2/qoo-app/radar.js @@ -0,0 +1,73 @@ +module.exports = { + 'qoo-app.com': { + _name: 'QooApp', + apps: [ + { + title: '遊戲庫 - 評論', + docs: 'https://docs.rsshub.app/anime.html#qooapp', + source: ['/:lang/app-comment/:id', '/app-comment/:id', '/app/:id'], + target: (params) => `/qoo-app/apps${params.lang ? `/${params.lang}` : ''}/comment/:id`, + }, + { + title: '遊戲庫 - 情報', + docs: 'https://docs.rsshub.app/anime.html#qooapp', + source: ['/:lang/app-post/:id', '/app-post/:id', '/app/:id'], + target: (params) => `/qoo-app/apps${params.lang ? `/${params.lang}` : ''}/post/:id`, + }, + { + title: '遊戲庫 - 筆記', + docs: 'https://docs.rsshub.app/anime.html#qooapp', + source: ['/:lang/app-note/:id', '/app-note/:id', '/app/:id'], + target: (params) => `/qoo-app/apps${params.lang ? `/${params.lang}` : ''}/note/:id`, + }, + { + title: '遊戲庫 - 曬卡', + docs: 'https://docs.rsshub.app/anime.html#qooapp', + source: ['/:lang/app-card/:id', '/app-card/:id', '/app/:id'], + target: (params) => `/qoo-app/apps${params.lang ? `/${params.lang}` : ''}/card/:id`, + }, + ], + news: [ + { + title: '資訊', + docs: 'https://docs.rsshub.app/anime.html#qooapp', + source: ['/:lang', '/'], + target: (params) => `/qoo-app/news${params.lang ? `/${params.lang}` : ''}`, + }, + ], + notes: [ + { + title: '筆記留言', + docs: 'https://docs.rsshub.app/anime.html#qooapp', + source: ['/:lang/note/:id', '/note/:id'], + target: (params) => `/qoo-app/notes${params.lang ? `/${params.lang}` : ''}/note/:id`, + }, + { + title: '熱門話題', + docs: 'https://docs.rsshub.app/anime.html#qooapp', + source: ['/:lang/topic/:topic', '/topic/:topic'], + target: (params) => `/qoo-app/notes${params.lang ? `/${params.lang}` : ''}/topic/:topic`, + }, + { + title: '用户筆記', + docs: 'https://docs.rsshub.app/anime.html#qooapp', + source: ['/:lang/user/:uid', '/user/:uid'], + target: (params) => `/qoo-app/notes${params.lang ? `/${params.lang}` : ''}/user/:uid`, + }, + ], + user: [ + { + title: '遊戲評論', + docs: 'https://docs.rsshub.app/anime.html#qooapp', + source: ['/:lang/:uid', '/:uid'], + target: (params) => `/qoo-app/user${params.lang ? `/${params.lang}` : ''}/appComment/:uid`, + }, + { + title: '用户筆記', + docs: 'https://docs.rsshub.app/anime.html#qooapp', + source: ['/:lang/:uid', '/:uid'], + target: (params) => `/qoo-app/notes${params.lang ? `/${params.lang}` : ''}/user/:uid`, + }, + ], + }, +}; diff --git a/lib/v2/qoo-app/router.js b/lib/v2/qoo-app/router.js new file mode 100644 index 000000000..ba23c0252 --- /dev/null +++ b/lib/v2/qoo-app/router.js @@ -0,0 +1,11 @@ +module.exports = (router) => { + router.get('/apps/:lang?/card/:id', require('./apps/card')); + router.get('/apps/:lang?/comment/:id', require('./apps/comment')); + router.get('/apps/:lang?/note/:id', require('./apps/note')); + router.get('/apps/:lang?/post/:id', require('./apps/post')); + router.get('/news/:lang?', require('./news')); + router.get('/notes/:lang?/note/:id', require('./notes/note')); + router.get('/notes/:lang?/topic/:topic', require('./notes/topic')); + router.get('/notes/:lang?/user/:uid', require('./notes/user')); + router.get('/user/:lang?/appComment/:uid', require('./user/appComment')); +}; diff --git a/lib/v2/qoo-app/templates/comment.art b/lib/v2/qoo-app/templates/comment.art new file mode 100644 index 000000000..6e0b42c6c --- /dev/null +++ b/lib/v2/qoo-app/templates/comment.art @@ -0,0 +1,3 @@ +{{ rating }}/5.0 +
+{{@ text }} diff --git a/lib/v2/qoo-app/templates/note.art b/lib/v2/qoo-app/templates/note.art new file mode 100644 index 000000000..db298159c --- /dev/null +++ b/lib/v2/qoo-app/templates/note.art @@ -0,0 +1,5 @@ +{{ content }} +{{ if picture }} +
+ +{{ /if }} diff --git a/lib/v2/qoo-app/user/appComment.js b/lib/v2/qoo-app/user/appComment.js new file mode 100644 index 000000000..14fbf0ad5 --- /dev/null +++ b/lib/v2/qoo-app/user/appComment.js @@ -0,0 +1,41 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); +const { userUrl, appsUrl } = require('../utils'); +const { art } = require('@/utils/render'); +const path = require('path'); + +module.exports = async (ctx) => { + const { uid, lang = '' } = ctx.params; + const link = `${userUrl}${lang ? `/${lang}` : ''}/${uid}`; + + const { data: response } = await got(link); + const { data } = await got(`${userUrl}/getUserAppCommentList`, { + searchParams: { + fid: uid, + }, + }); + + const $ = cheerio.load(response); + const username = $('.person .name').text(); + + const items = data.list.map((item) => ({ + title: `${username} ▶ ${item.app.name}`, + link: `${appsUrl}/comment-detail/${item.comment.id}`, + description: art(path.join(__dirname, '../templates/comment.art'), { + rating: item.score, + text: item.comment.content, + }), + pubDate: timezone(parseDate(item.comment.created_at, 'YYYY-MM-DD'), 8), + author: username, + })); + + ctx.state.data = { + title: $('head title').text(), + link, + image: decodeURIComponent($('.person div.slot').attr('data-args')).replace('avatar=', '').split('?')[0], + language: $('html').attr('lang'), + item: items, + }; +}; diff --git a/lib/v2/qoo-app/utils.js b/lib/v2/qoo-app/utils.js new file mode 100644 index 000000000..f47f4d939 --- /dev/null +++ b/lib/v2/qoo-app/utils.js @@ -0,0 +1,57 @@ +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); + +const appsUrl = 'https://apps.qoo-app.com'; +const newsUrl = 'https://news.qoo-app.com'; +const notesUrl = 'https://notes.qoo-app.com'; +const ssoUrl = 'https://sso.qoo-app.com'; +const userUrl = 'https://user.qoo-app.com'; + +const siteIcon = 'https://o.qoo-img.com/statics.qoo-app.com/cdn/img/QooApp_512.v-0d0fd2.png'; + +const fixImg = ($) => { + $('img').each((_, img) => { + if (img.attribs['data-orig-file']) { + img.attribs.src = img.attribs['data-orig-file'].replace('i0.wp.com/', '').split('?')[0]; + delete img.attribs['data-orig-file']; + delete img.attribs['data-orig-size']; + delete img.attribs['data-image-meta']; + delete img.attribs['data-comments-opened']; + delete img.attribs['data-full-url']; + delete img.attribs['data-medium-file']; + delete img.attribs['data-large-file']; + } + img.attribs.src = img.attribs.src.replace('i0.wp.com/', '').split('?')[0]; + delete img.attribs.srcset; + }); +}; + +const extractNotes = ($) => { + $('.qoo-note-wrap') + .toArray() + .map((item) => { + item = $(item); + const title = item.find('.qoo-note-view .content-title').text(); + const author = item.find('cite.name').text(); + const pubDate = timezone(parseDate(item.find('time').text(), 'YYYY-MM-DD HH:mm'), 8); + item.find('cite.name, time, footer').remove(); + return { + title, + description: item.find('.qoo-note-view').html(), + link: item.find('a.link-wrap').attr('href'), + pubDate, + author, + }; + }); +}; + +module.exports = { + appsUrl, + newsUrl, + notesUrl, + ssoUrl, + userUrl, + siteIcon, + fixImg, + extractNotes, +};