From 1dfa0343322fe0daea1d03c8c318c2d51fbcf64b Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Mon, 7 Feb 2022 22:29:09 +0100 Subject: [PATCH] Handling 'page not found' with 200 OK in Gamma scraper. --- src/scrapers/gamma.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/scrapers/gamma.js b/src/scrapers/gamma.js index c5a76197..67fbffac 100644 --- a/src/scrapers/gamma.js +++ b/src/scrapers/gamma.js @@ -500,6 +500,10 @@ async function scrapeMovie({ query, el }, url, entity, baseRelease, options) { const rawData = dataLayer?.[0]?.dvdDetails; const data = rawData?.dvdId && rawData; // dvdDetails is mostly empty in some cache states + if (query.exists('.NotFound-Title')) { + return null; + } + release.entryId = new URL(url).pathname.match(/\/(\d+)(\/|$)/)?.[1]; release.covers = [ @@ -674,10 +678,14 @@ async function fetchSceneApi(url, site, baseRelease, options) { encodeJSON: true, }); - if (res.status === 200 && res.body.results?.[0]?.hits) { + if (res.status === 200 && res.body.results?.[0]?.hits.length > 0) { return scrapeReleaseApi(res.body.results[0].hits[0], site, options); } + if (res.status === 200) { + return null; + } + return res.status; } @@ -706,10 +714,14 @@ async function fetchMovieApi(url, site, baseRelease, options) { encodeJSON: true, }); - if (res.status === 200 && res.body.results?.[0]?.hits) { + if (res.status === 200 && res.body.results?.[0]?.hits.length > 0) { return scrapeReleaseApi(res.body.results[0].hits[0], site, options); } + if (res.status === 200) { + return null; + } + return res.status; }