Compare commits

...

2 Commits

Author SHA1 Message Date
ThePendulum 7d0cf0f100 1.62.4 2020-01-25 01:47:02 +01:00
ThePendulum ab82329171 Improved q so missing date element returns null. 2020-01-25 01:46:58 +01:00
4 changed files with 18 additions and 11 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "traxxx", "name": "traxxx",
"version": "1.62.3", "version": "1.62.4",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "traxxx", "name": "traxxx",
"version": "1.62.3", "version": "1.62.4",
"description": "All the latest porn releases in one place", "description": "All the latest porn releases in one place",
"main": "src/app.js", "main": "src/app.js",
"scripts": { "scripts": {

View File

@ -339,6 +339,7 @@ async function scrapeActors(actorNames) {
const sources = argv.sources ? argv.sources.map(source => [source, scrapers.actors[source]]) : Object.entries(scrapers.actors); const sources = argv.sources ? argv.sources.map(source => [source, scrapers.actors[source]]) : Object.entries(scrapers.actors);
const profiles = await Promise.map(sources, async ([scraperSlug, scraper]) => { const profiles = await Promise.map(sources, async ([scraperSlug, scraper]) => {
try {
const profile = await scraper.fetchProfile(actorEntry ? actorEntry.name : actorName); const profile = await scraper.fetchProfile(actorEntry ? actorEntry.name : actorName);
return { return {
@ -346,6 +347,10 @@ async function scrapeActors(actorNames) {
name: actorName, name: actorName,
scraper: scraperSlug, scraper: scraperSlug,
}; };
} catch (error) {
console.log(scraperSlug, error);
return null;
}
}); });
const profile = await mergeProfiles(profiles, actorEntry); const profile = await mergeProfiles(profiles, actorEntry);

View File

@ -7,9 +7,9 @@ function q(context, selector, attrArg, trim = true) {
const attr = attrArg === true ? 'textContent' : attrArg; const attr = attrArg === true ? 'textContent' : attrArg;
if (attr) { if (attr) {
const value = context.querySelector(selector)[attr]; const value = context.querySelector(selector)?.[attr];
return trim ? value.trim() : value; return trim ? value?.trim() : value;
} }
return context.querySelector(selector); return context.querySelector(selector);
@ -26,7 +26,9 @@ function qall(context, selector, attrArg, trim = true) {
} }
function qdate(context, selector, format, match, attr = 'textContent') { function qdate(context, selector, format, match, attr = 'textContent') {
const dateString = context.querySelector(selector)[attr]; const dateString = context.querySelector(selector)?.[attr];
if (!dateString) return null;
if (match) { if (match) {
const dateStamp = dateString.match(match); const dateStamp = dateString.match(match);