Added Insex fallback for Paintoy.

This commit is contained in:
2020-02-12 16:26:08 +01:00
parent 2b90a7a5c8
commit 98d29c0af0
4 changed files with 9 additions and 3 deletions

View File

@@ -4,7 +4,9 @@ const bhttp = require('bhttp');
const { get, exa, fd } = require('../utils/q');
function scrapeLatest(html, site) {
const scenes = exa(html, 'body > table');
const scenes = site.slug === 'paintoy'
? exa(html, '#articleTable table[cellspacing="2"]')
: exa(html, 'body > table');
return scenes.map(({ q, qd, qi, qu, ql }) => {
// if (q('.articleTitleText')) return scrapeFirstLatest(ctx(el), site);
@@ -77,14 +79,17 @@ function scrapeScene({ q, qd, ql, qu, qis, qp, qt }, site) {
}
async function fetchLatest(site, page = 1) {
const url = `${site.url}/scripts/switch_tour.php?type=brief&page=${page}`;
const url = site.slug === 'paintoy' // paintoy's site is partially broken, use front page
? `${site.url}/corporal/punishment/gallery.php?type=brief&page=${page}`
: `${site.url}/scripts/switch_tour.php?type=brief&page=${page}`;
const res = await bhttp.get(url, {
type: 'brief',
page,
});
if (res.statusCode === 200) {
return scrapeLatest(res.body.html, site);
return scrapeLatest(site.slug === 'paintoy' ? res.body.toString() : res.body.html, site);
}
return null;