fix(route): yystv change selector path, add radar and refactor to V2 (#9529)

* fix(route): change selector path, add radar and refactor to V2

* fix: use parse-date utils

* fix: use https
This commit is contained in:
Fatpandac
2022-04-13 17:23:23 +08:00
committed by GitHub
parent ae66123996
commit d63ece212f
6 changed files with 69 additions and 12 deletions

View File

@@ -1456,8 +1456,8 @@ router.get('/gamersky/news', lazyloadRouteHandler('./routes/gamersky/news'));
router.get('/gamersky/ent/:category', lazyloadRouteHandler('./routes/gamersky/ent'));
// 游研社
router.get('/yystv/category/:category', lazyloadRouteHandler('./routes/yystv/category'));
router.get('/yystv/docs', lazyloadRouteHandler('./routes/yystv/docs'));
// router.get('/yystv/category/:category', lazyloadRouteHandler('./routes/yystv/category'));
// router.get('/yystv/docs', lazyloadRouteHandler('./routes/yystv/docs'));
// konami
router.get('/konami/pesmobile/:lang?/:os?', lazyloadRouteHandler('./routes/konami/pesmobile'));

View File

@@ -1,10 +1,10 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const date = require('@/utils/date');
const { parseDate, parseRelativeDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const category = ctx.params.category;
const url = `http://www.yystv.cn/b/${category}`;
const url = `https://www.yystv.cn/b/${category}`;
const response = await got({
method: 'get',
url,
@@ -18,8 +18,8 @@ module.exports = async (ctx) => {
.map(function () {
const info = {
title: $(this).find('.b-main-info-title').text(),
link: 'http://www.yystv.cn' + $(this).find('.b-main-info-title a').attr('href'),
pubDate: date($(this).find('.b-main-createtime').text()),
link: 'https://www.yystv.cn' + $(this).find('.b-main-info-title a').attr('href'),
pubDate: parseRelativeDate($(this).find('.b-main-createtime').text()),
author: $(this).find('.b-author').text(),
};
return info;
@@ -31,8 +31,8 @@ module.exports = async (ctx) => {
.map(function () {
const info = {
title: $('.list-article-title', this).text(),
link: 'http://www.yystv.cn' + $('a', this).attr('href'),
pubDate: date($('.c-999', this).text()),
link: 'https://www.yystv.cn' + $('a', this).attr('href'),
pubDate: $('.c-999', this).text().includes('-') ? parseDate($('.c-999', this).text()) : parseRelativeDate($('.c-999', this).text()),
author: $('.handler-author-link', this).text(),
};
return info;
@@ -49,7 +49,7 @@ module.exports = async (ctx) => {
method: 'get',
});
const $ = cheerio.load(r.data);
return $('.doc-content div').html();
return $('.doc-content.rel').html();
});
return currentValue;
})
@@ -58,7 +58,7 @@ module.exports = async (ctx) => {
await getDescription(items).then(() => {
ctx.state.data = {
title: '游研社-' + $('title').text(),
link: `http://www.yystv.cn/b/${category}`,
link: `https://www.yystv.cn/b/${category}`,
item: items,
};
});

View File

@@ -1,6 +1,6 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const date = require('@/utils/date');
const { parseRelativeDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const url = `https://www.yystv.cn/docs`;
@@ -18,7 +18,7 @@ module.exports = async (ctx) => {
const info = {
title: $('.list-article-title', this).text(),
link: 'https://www.yystv.cn' + $('a', this).attr('href'),
pubDate: date($('.c-999', this).text()),
pubDate: parseRelativeDate($('.c-999', this).text()),
author: $('.handler-author-link', this).text(),
description: $('.list-article-intro', this).text(),
};

View File

@@ -0,0 +1,4 @@
module.exports = {
'/category/:category': ['LightStrawberry'],
'/docs': ['HaitianLiu'],
};

49
lib/v2/yystv/radar.js Normal file
View File

@@ -0,0 +1,49 @@
module.exports = {
'yystv.cn': {
_name: '游研社',
'.': [
{
title: '推游',
docs: 'https://docs.rsshub.app/game.html#you-yan-she',
source: '/b/recommend',
target: '/yystv/category/recommend',
},
{
title: '游戏史',
docs: 'https://docs.rsshub.app/game.html#you-yan-she',
source: '/b/history',
target: '/yystv/category/history',
},
{
title: '大事件',
docs: 'https://docs.rsshub.app/game.html#you-yan-she',
source: '/b/big',
target: '/yystv/category/big',
},
{
title: '文化',
docs: 'https://docs.rsshub.app/game.html#you-yan-she',
source: '/b/culture',
target: '/yystv/category/culture',
},
{
title: '趣闻',
docs: 'https://docs.rsshub.app/game.html#you-yan-she',
source: '/b/news',
target: '/yystv/category/news',
},
{
title: '经典回顾',
docs: 'https://docs.rsshub.app/game.html#you-yan-she',
source: '/b/retro',
target: '/yystv/category/retro',
},
{
title: '全部文章',
docs: 'https://docs.rsshub.app/game.html#you-yan-she',
source: '/docs',
target: '/yystv/docs',
},
],
},
};

4
lib/v2/yystv/router.js Normal file
View File

@@ -0,0 +1,4 @@
module.exports = function (router) {
router.get('/category/:category', require('./category'));
router.get('/docs', require('./docs'));
};