forked from DebaucheryLibrarian/traxxx
Moved missing slug return in Vixen scraper.
This commit is contained in:
parent
6e79112f3a
commit
8bb46c5a6d
|
@ -256,12 +256,20 @@ async function scrapeSceneData(data, channel, options) {
|
||||||
release.channel = data.site;
|
release.channel = data.site;
|
||||||
release.stars = data.rating;
|
release.stars = data.rating;
|
||||||
|
|
||||||
|
console.log(release);
|
||||||
|
|
||||||
return release;
|
return release;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchGraphqlScene(release, channel) {
|
async function fetchGraphqlScene(release, channel) {
|
||||||
const slug = new URL(release.url).pathname.match(/\/videos\/(.*)/)?.[1];
|
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
|
// 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 query = slug.split('-').reduce((acc, word) => {
|
||||||
const newAcc = `${acc} ${word}`;
|
const newAcc = `${acc} ${word}`;
|
||||||
|
|
||||||
|
@ -272,21 +280,19 @@ async function fetchGraphqlScene(release, channel) {
|
||||||
return newAcc;
|
return newAcc;
|
||||||
}, '').trim();
|
}, '').trim();
|
||||||
|
|
||||||
if (!slug) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const res = await http.post(`${channel.url}/graphql`, {
|
const res = await http.post(`${channel.url}/graphql`, {
|
||||||
operationName: 'searchVideos',
|
operationName: 'searchVideos',
|
||||||
variables: {
|
variables: {
|
||||||
site: channel.slug.toUpperCase(),
|
site: channel.slug.toUpperCase(),
|
||||||
query,
|
query,
|
||||||
},
|
},
|
||||||
|
// ranking can be weird, use higher limit to increase likelihood of finding scene
|
||||||
query: `
|
query: `
|
||||||
query searchVideos($site: Site!, $query: String!) {
|
query searchVideos($site: Site!, $query: String!) {
|
||||||
searchVideos(input: {
|
searchVideos(input: {
|
||||||
query: $query
|
query: $query
|
||||||
site: $site
|
site: $site
|
||||||
|
first: 50
|
||||||
}) {
|
}) {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
|
@ -349,9 +355,12 @@ async function fetchGraphqlScene(release, channel) {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
|
console.log(res.body.data.searchVideos.edges);
|
||||||
return res.body.data?.searchVideos?.edges?.find((edge) => edge.node.slug === slug)?.node || null;
|
return res.body.data?.searchVideos?.edges?.find((edge) => edge.node.slug === slug)?.node || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(res.body);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue