Using channel URL for Dogfart photos and network URL as fallback.
This commit is contained in:
parent
f1c9ac4207
commit
b00b8f4a96
|
@ -3,7 +3,7 @@
|
|||
const slugify = require('../utils/slugify');
|
||||
const qu = require('../utils/qu');
|
||||
|
||||
async function getPhotos(albumUrl) {
|
||||
async function getPhotos(albumUrl, channel) {
|
||||
const res = await qu.get(albumUrl);
|
||||
|
||||
if (!res.ok) {
|
||||
|
@ -14,12 +14,21 @@ async function getPhotos(albumUrl) {
|
|||
const lastPhotoIndex = parseInt(lastPhotoPage.match(/\d+.jpg/)[0], 10);
|
||||
|
||||
const photoUrls = Array.from({ length: lastPhotoIndex }, (value, index) => {
|
||||
const pageUrl = `https://blacksonblondes.com${lastPhotoPage.replace(/\d+.jpg/, `${(index + 1).toString().padStart(3, '0')}.jpg`)}`;
|
||||
const pageUrl = `${channel.url}${lastPhotoPage.replace(/\d+.jpg/, `${(index + 1).toString().padStart(3, '0')}.jpg`)}`;
|
||||
const networkPageUrl = `https://dogfartnetwork.com${lastPhotoPage.replace('tourx', 'tour').replace(/\d+.jpg/, `${(index + 1).toString().padStart(3, '0')}.jpg`)}`;
|
||||
|
||||
return {
|
||||
url: pageUrl,
|
||||
extract: ({ query }) => query.img('.scenes-module img'),
|
||||
};
|
||||
const extract = ({ query }) => query.img('.scenes-module img');
|
||||
|
||||
return [
|
||||
{
|
||||
url: pageUrl,
|
||||
extract,
|
||||
},
|
||||
{
|
||||
url: networkPageUrl,
|
||||
extract,
|
||||
},
|
||||
];
|
||||
});
|
||||
|
||||
return photoUrls;
|
||||
|
@ -90,6 +99,8 @@ async function scrapeScene({ query }, url, channel, baseScene, parameters) {
|
|||
|
||||
release.stars = Number(((query.number('span[itemprop="average"], span[itemprop="ratingValue"]') || query.number('canvas[data-score]', null, 'data-score')) / 2).toFixed(2));
|
||||
|
||||
console.log(release.photos);
|
||||
|
||||
return release;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue