fix(route): ComicsKingdom changed their UI elements (#11168)

* fix(11167): ComicsKingdom changed their UI elements

* refactor: migrate to v2
This commit is contained in:
St. John Johnson 2022-10-27 15:11:13 -07:00 committed by GitHub
parent 6fe52ef253
commit 167b11dfb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 45 additions and 24 deletions

View File

@ -18,6 +18,12 @@ For more tags, please go to [Search torrent](https://bangumi.moe/search/index)
</RouteEn>
## Comics Kingdom
### Archive
<RouteEn author="stjohnjohnson" example="/comicskingdom/pardon-my-planet" path="/comicskingdom/:name" :paramsDesc="['URL path of the strip on comicskingdom.com']" />
## Hanime.tv
### Recently updated

View File

@ -104,10 +104,6 @@ pageClass: routes
<RouteEn author="FHYunCai" example="/bing" path="/bing" radar="1" rssbud="1"/>
## ComicsKingdom Comic Strips
<RouteEn author="stjohnjohnson" example="/comicskingdom/baby-blues" path="/comicskingdom/:strip" :paramsDesc="['URL path of the strip on comicskingdom.com']" />
## DailyArt
<RouteEn author="zphw" example="/dailyart/en" path="/dailyart/:language?" :paramsDesc="['Support en, es, fr, de, it, zh, jp, etc. English by default.']" />

View File

@ -3681,7 +3681,7 @@ router.get('/mcdonalds/:category', lazyloadRouteHandler('./routes/mcdonalds/news
router.get('/gocomics/:name', lazyloadRouteHandler('./routes/gocomics/index'));
// Comics Kingdom
router.get('/comicskingdom/:name', lazyloadRouteHandler('./routes/comicskingdom/index'));
// router.get('/comicskingdom/:name', lazyloadRouteHandler('./routes/comicskingdom/index'));
// Media Digest
router.get('/mediadigest/:range/:category?', lazyloadRouteHandler('./routes/mediadigest/category'));

View File

@ -1,27 +1,25 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');
module.exports = async (ctx) => {
const baseURL = 'https://www.comicskingdom.com';
const baseURL = 'https://comicskingdom.com';
const name = ctx.params.name;
const url = `${baseURL}/${name}/archive`;
const response = await got({
method: 'get',
url,
});
const { data } = await got(url);
const data = response.data;
const $ = cheerio.load(data);
// Determine Comic and Author from main page
const comic = $('title').text().replace('Comics Kingdom - ', '').trim();
const author = $('div.author p').text();
const author = $('.feature-title h2').text();
// Find the links for all non-archived items
const links = $('div.archive-tile[data-is-blocked=false]')
.map((i, el) => $(el).find('a[data-prem="Comic Tile"]').first().attr('href'))
.get()
.map((url) => `${baseURL}${url}`);
const links = $('div.tile')
.toArray()
.map((el) => $(el).find('a').first().attr('href'));
if (links.length === 0) {
throw `Comic Not Found - ${name}`;
@ -29,17 +27,16 @@ module.exports = async (ctx) => {
const items = await Promise.all(
links.map((link) =>
ctx.cache.tryGet(link, async () => {
const detailResponse = await got({
method: 'get',
url: link,
});
const detailResponse = await got(link);
const content = cheerio.load(detailResponse.data);
const title = content('title').text();
const title = content('meta[property="og:description"]').attr('content');
const image = content('meta[property="og:image"]').attr('content');
const description = `<img src="${image}" />`;
const description = art(path.join(__dirname, 'templates/desc.art'), {
image,
});
// Pull the date out of the URL
const pubDate = new Date(link.split('/').slice(-3).join('/')).toUTCString();
const pubDate = parseDate(link.substring(link.lastIndexOf('/') + 1), 'YYYY-MM-DD');
return {
title,
@ -54,8 +51,10 @@ module.exports = async (ctx) => {
);
ctx.state.data = {
title: `${comic} - Comics Kingdom`,
title: comic,
link: url,
image: $('.feature-logo').attr('src'),
item: items,
language: 'en-US',
};
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/:name': ['stjohnjohnson'],
};

View File

@ -0,0 +1,13 @@
module.exports = {
'comicskingdom.com': {
_name: 'Comics Kingdom',
'.': [
{
title: 'Archive',
docs: 'https://docs.rsshub.app/anime.html#comics-kingdom',
source: ['/:name/*', '/:name'],
target: '/comicskingdom/:name',
},
],
},
};

View File

@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/:name', require('./index'));
};

View File

@ -0,0 +1 @@
<img src="{{ image }}">