Separated actor expand buttons. Refactored Brazzers scraper. Fixed actor releases not included in shallow scrape. Added number query and data-src default to qu img. Updated README. Removed post-install migrate and seed.

This commit is contained in:
2020-07-09 02:00:54 +02:00
parent 17d46e804e
commit 44a8ced30c
10 changed files with 289 additions and 326 deletions

View File

@@ -103,6 +103,12 @@ function text(context, selector, applyTrim = true) {
return applyTrim ? trim(textValue) : textValue;
}
function number(context, selector, attr = true) {
const value = q(context, selector, attr);
return value ? Number(value) : null;
}
function meta(context, selector, attrArg = 'content', applyTrim = true) {
if (/meta\[.*\]/.test(selector)) {
return q(context, selector, attrArg, applyTrim);
@@ -119,17 +125,22 @@ function date(context, selector, format, match, attr = 'textContent') {
return extractDate(dateString, format, match);
}
function image(context, selector = 'img', attr = 'src', origin, protocol = 'https') {
const imageEl = q(context, selector, attr);
function image(context, selector = 'img', attr, origin, protocol = 'https') {
const imageEl = (attr && q(context, selector, attr))
|| q(context, selector, 'src')
|| q(context, selector, 'data-src');
// no attribute means q output will be HTML element
return attr ? prefixUrl(imageEl, origin, protocol) : imageEl;
return prefixUrl(imageEl, origin, protocol);
}
function images(context, selector = 'img', attr = 'src', origin, protocol = 'https') {
const imageEls = all(context, selector, attr);
function images(context, selector = 'img', attr, origin, protocol = 'https') {
const attribute = attr
|| (q(context, selector, 'src') && 'src')
|| (q(context, selector, 'data-src') && 'data-src');
return attr ? imageEls.map(imageEl => prefixUrl(imageEl, origin, protocol)) : imageEls;
const imageEls = all(context, selector, attribute);
return imageEls.map(imageEl => prefixUrl(imageEl, origin, protocol));
}
function url(context, selector = 'a', attr = 'href', origin, protocol = 'https') {
@@ -225,6 +236,8 @@ const quFuncs = {
imgs: images,
length: duration,
meta,
number,
num: number,
poster,
q,
text,