diff --git a/src/scrapers/vixen.js b/src/scrapers/vixen.js index aa9e0426..d5084670 100755 --- a/src/scrapers/vixen.js +++ b/src/scrapers/vixen.js @@ -256,12 +256,20 @@ async function scrapeSceneData(data, channel, options) { release.channel = data.site; release.stars = data.rating; + console.log(release); + return release; } async function fetchGraphqlScene(release, channel) { const slug = new URL(release.url).pathname.match(/\/videos\/(.*)/)?.[1]; + + if (!slug) { + return null; + } + // the API won't reliable return results when the query is over ~30 characters for some reason + // it may still occasionally fail to return the relevant result, first, such as Blacked Raw - After the Show const query = slug.split('-').reduce((acc, word) => { const newAcc = `${acc} ${word}`; @@ -272,21 +280,19 @@ async function fetchGraphqlScene(release, channel) { return newAcc; }, '').trim(); - if (!slug) { - return null; - } - const res = await http.post(`${channel.url}/graphql`, { operationName: 'searchVideos', variables: { site: channel.slug.toUpperCase(), query, }, + // ranking can be weird, use higher limit to increase likelihood of finding scene query: ` query searchVideos($site: Site!, $query: String!) { searchVideos(input: { query: $query site: $site + first: 50 }) { edges { node { @@ -349,9 +355,12 @@ async function fetchGraphqlScene(release, channel) { }); if (res.ok) { + console.log(res.body.data.searchVideos.edges); return res.body.data?.searchVideos?.edges?.find((edge) => edge.node.slug === slug)?.node || null; } + console.log(res.body); + return null; }