From 22864105ace2a3e349079fd81822724b6ca6c5ec Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Sun, 30 Jan 2022 17:05:18 +0100 Subject: [PATCH] Writing media associations to disk for debugging. --- src/media.js | 1 + src/scrapers/gamma.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/media.js b/src/media.js index a2ec606f..035d55d9 100644 --- a/src/media.js +++ b/src/media.js @@ -846,6 +846,7 @@ async function associateReleaseMedia(releases, type = 'release') { } } catch (error) { console.log(associations); + await fs.promises.writeFile(`./associations-${Date.now()}`, JSON.stringify(associations, null, 4)); throw error; } } catch (error) { diff --git a/src/scrapers/gamma.js b/src/scrapers/gamma.js index 97f782dc..53855647 100644 --- a/src/scrapers/gamma.js +++ b/src/scrapers/gamma.js @@ -489,7 +489,7 @@ async function scrapeMovie({ query, el }, url, entity, baseRelease, options) { const { dataLayer } = query.exec('//script[contains(text(), "dataLayer")]', ['dataLayer']); const rawData = dataLayer?.[0]?.dvdDetails; - const data = rawData.dvdId && rawData; // dvdDetails is mostly empty in some cache states + const data = rawData?.dvdId && rawData; // dvdDetails is mostly empty in some cache states release.entryId = new URL(url).pathname.match(/\/(\d+)(\/|$)/)?.[1];