Added referer to AnalVids requests.

This commit is contained in:
DebaucheryLibrarian 2024-11-01 00:38:49 +01:00
parent 54d4fbdddc
commit 341c6aed1e
1 changed files with 37 additions and 5 deletions

View File

@ -43,7 +43,7 @@ function scrapeAll(scenes, channel) {
}); });
} }
function scrapeScene({ query }, { url }) { function scrapeScene({ query }, url) {
const release = {}; const release = {};
release.entryId = new URL(url).pathname.match(/watch\/(\d+)/)?.[1]; release.entryId = new URL(url).pathname.match(/watch\/(\d+)/)?.[1];
@ -91,7 +91,15 @@ function scrapeProfile({ query }, url, channel) {
async function fetchLatest(channel, page) { 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(`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) { if (res.ok) {
return scrapeAll(res.context, channel); 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) { async function getActorUrl(actor, channel) {
if (actor.url) { if (actor.url) {
return 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) { if (!searchRes.ok) {
return searchRes.status; return searchRes.status;
@ -160,7 +188,11 @@ async function fetchProfile(actor, { channel }) {
return actorUrl; return actorUrl;
} }
const bioRes = await unprint.get(actorUrl); const bioRes = await unprint.get(actorUrl, {
headers: {
Referer: actor.url,
},
});
if (bioRes.ok) { if (bioRes.ok) {
return scrapeProfile(bioRes.context, actorUrl, channel); return scrapeProfile(bioRes.context, actorUrl, channel);
@ -171,6 +203,6 @@ async function fetchProfile(actor, { channel }) {
module.exports = { module.exports = {
fetchLatest, fetchLatest,
scrapeScene, fetchScene,
fetchProfile, fetchProfile,
}; };