diff --git a/src/scrapers/analvids.js b/src/scrapers/analvids.js index bb1b511d..4b3836de 100644 --- a/src/scrapers/analvids.js +++ b/src/scrapers/analvids.js @@ -43,7 +43,7 @@ function scrapeAll(scenes, channel) { }); } -function scrapeScene({ query }, { url }) { +function scrapeScene({ query }, url) { const release = {}; release.entryId = new URL(url).pathname.match(/watch\/(\d+)/)?.[1]; @@ -91,7 +91,15 @@ function scrapeProfile({ query }, url, channel) { async function fetchLatest(channel, page) { // const res = await unprint.get(`https://www.analvids.com/new-videos/${page}`, { selectAll: '.card-scene' }); // analvids as channel - const res = await unprint.get(`${channel.url}/latest/${page}`, { selectAll: '.card-scene' }); // studios as channels + // studios as channels + const url = `${channel.url}/latest/${page}`; + + const res = await unprint.get(url, { + selectAll: '.card-scene', + headers: { + Referer: url, + }, + }); if (res.ok) { return scrapeAll(res.context, channel); @@ -133,12 +141,32 @@ async function fetchLatest(channel, page) { } */ +async function fetchScene(url) { + const res = await unprint.get(url, { + headers: { + Referer: url, + }, + }); + + if (res.ok) { + return scrapeScene(res.context, url); + } + + return res.status; +} + async function getActorUrl(actor, channel) { if (actor.url) { return actor.url; } - const searchRes = await http.get(`${channel.url}/api/autocomplete/search?q=${slugify(actor.name, '+')}`); + const searchUrl = `${channel.url}/api/autocomplete/search?q=${slugify(actor.name, '+')}`; + + const searchRes = await http.get(searchUrl, { + headers: { + Referer: actor.url, + }, + }); if (!searchRes.ok) { return searchRes.status; @@ -160,7 +188,11 @@ async function fetchProfile(actor, { channel }) { return actorUrl; } - const bioRes = await unprint.get(actorUrl); + const bioRes = await unprint.get(actorUrl, { + headers: { + Referer: actor.url, + }, + }); if (bioRes.ok) { return scrapeProfile(bioRes.context, actorUrl, channel); @@ -171,6 +203,6 @@ async function fetchProfile(actor, { channel }) { module.exports = { fetchLatest, - scrapeScene, + fetchScene, fetchProfile, };