From b8e94312250d8f5078e10194b49eaae2cd481f5a Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Fri, 18 Oct 2024 22:57:12 +0200 Subject: [PATCH] Fixed Snow Valley breaking on Transex Japan if no album is found for scene. --- src/scrapers/snowvalley.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/scrapers/snowvalley.js b/src/scrapers/snowvalley.js index a6743056..025f8202 100755 --- a/src/scrapers/snowvalley.js +++ b/src/scrapers/snowvalley.js @@ -232,6 +232,10 @@ async function fetchLatestCospuri(channel, page) { } function curatePhotos(sources) { + if (!sources) { + return null; + } + return sources .filter(Boolean).map((src) => [ src.replace(/(\d+)s.jpg/, (match, photoIndex) => `${photoIndex}.jpg`), @@ -410,7 +414,7 @@ async function fetchLatestFacefuck(channel, page) { } function scrapeAllTrans(scenes) { - return scenes.map(([{ query }, { query: albumQuery }]) => { + return scenes.map(([{ query }, albumContext]) => { const release = {}; release.title = query.content('.sample-info h1'); @@ -419,7 +423,7 @@ function scrapeAllTrans(scenes) { release.description = query.content('.sample-desc')?.replace('""', '') || null; // usually empty, but let's try it just in case release.duration = query.duration('.sample-info'); - release.photoCount = albumQuery.number('.sample-info', { match: /(\d+) photos/i, matchIndex: 1 }); + release.photoCount = albumContext?.query.number('.sample-info', { match: /(\d+) photos/i, matchIndex: 1 }); const posterBackground = query.style('.player'); const posterUrl = posterBackground?.background?.match(/url\((.*)\)/)?.[1]?.trim(); @@ -432,7 +436,7 @@ function scrapeAllTrans(scenes) { ]; } - release.photos = curatePhotos(albumQuery.styles('.sample-lg, .sample-thumb').map((style) => style['background-image']?.match(/url\((.*)\)/)?.[1])); + release.photos = curatePhotos(albumContext?.query.styles('.sample-lg, .sample-thumb').map((style) => style['background-image']?.match(/url\((.*)\)/)?.[1])); release.trailer = query.video(); release.entryId = entryIdFromMedia(release);