Adjusting tooltip arrow position, added open and close events. Fixed search tooltip layout.

This commit is contained in:
DebaucheryLibrarian
2020-12-29 00:42:02 +01:00
parent 442e69187b
commit 8dd10f7e77
6 changed files with 123 additions and 54 deletions

View File

@@ -1,6 +1,7 @@
'use strict';
const qu = require('../utils/qu');
const http = require('../utils/http');
function scrapeAll(scenes) {
return scenes.map(({ query }) => {
@@ -33,13 +34,11 @@ function scrapeAll(scenes) {
async function scrapeScene({ query }, url) {
const release = { director: 'Mike Adriano' };
if (query.exists('a[href*="stackpath.com"]')) {
throw new Error('URL blocked by StackPath');
}
const pathname = new URL(url).pathname;
release.entryId = pathname.match(/\/view\/(\d+)/)?.[1] || pathname.match(/\/view\/([\w-]+)/)?.[1];
console.log(release);
release.title = query.cnt('.content-page-info .title');
release.description = query.cnt('.content-page-info .desc');
release.date = query.date('.content-page-info .date, .content-page-info .hide, .post-date', 'Do MMM YYYY');
@@ -71,10 +70,40 @@ async function fetchLatest(channel, page = 1) {
}
async function fetchScene(url, channel) {
const res = await qu.get(url);
const cookieJar = http.cookieJar();
const session = http.session({ cookieJar });
console.log(cookieJar);
const resA = await http.get(url, {
session,
extract: {
cookieJar,
// runScripts: 'dangerously',
},
});
console.log(resA.headers, cookieJar.getCookiesSync(url));
const cookie = cookieJar.getCookieStringSync(url);
console.log(cookie);
const res = await http.get(url, {
headers: {
cookie,
},
});
// console.log(res.req);
if (res.ok) {
return scrapeScene(res.item, url, channel);
const item = qu.init(res.document);
if (item.query.exists('a[href*="stackpath.com"]')) {
throw new Error('URL blocked by StackPath');
}
return scrapeScene(item, url, channel);
}
return res.status;