Improved handling of failed video stream fetching. Added proper Little Caprice album URL retrieval.
This commit is contained in:
@@ -82,14 +82,37 @@ async function fetchLatest(channel) {
|
||||
return res.status;
|
||||
}
|
||||
|
||||
async function attachPhotos(url, release) {
|
||||
if (url) {
|
||||
const res = await unprint.get(url);
|
||||
async function fetchAlbumUrl(sceneUrl) {
|
||||
// Upjax-Action query is redundant, but imitates original request
|
||||
const res = await unprint.get(`${sceneUrl}?endpoint_request_timestamp=${Math.floor(Date.now() / 1000)}&Upjax-Action=lcd.project.actions`, {
|
||||
headers: {
|
||||
Referer: sceneUrl,
|
||||
'Upjax-Action': 'lcd.project.actions',
|
||||
'Upjax-Method': 'GET',
|
||||
},
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
const albumUrl = res.data.js?.match(/"(https.*?)"/)?.[1];
|
||||
|
||||
if (albumUrl) {
|
||||
return albumUrl;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
async function attachPhotos(sceneUrl, release) {
|
||||
const albumUrl = await fetchAlbumUrl(sceneUrl);
|
||||
|
||||
if (albumUrl) {
|
||||
const res = await unprint.get(albumUrl);
|
||||
|
||||
if (res.ok) {
|
||||
release.photos = res.context.query.imgs('.gallery img').map((imgUrl) => ({ // eslint-disable-line no-param-reassign
|
||||
src: imgUrl,
|
||||
referer: url,
|
||||
referer: sceneUrl,
|
||||
}));
|
||||
|
||||
release.photoCount = res.context.query.number('.image-amount'); // eslint-disable-line no-param-reassign
|
||||
@@ -126,7 +149,7 @@ async function scrapeScene({ query }, { url, include }) {
|
||||
};
|
||||
|
||||
if (include.photos) {
|
||||
await attachPhotos(url.replace(/(\/)?$/, '-2$1'), release);
|
||||
await attachPhotos(url, release);
|
||||
}
|
||||
|
||||
const trailerFrame = query.url('.video iframe', { attribute: 'src' });
|
||||
@@ -134,14 +157,12 @@ async function scrapeScene({ query }, { url, include }) {
|
||||
|
||||
if (trailerId) {
|
||||
release.trailer = {
|
||||
stream: `https://trailer.littlecaprice-dreams.com/${trailerId}/1920x1080/video.m3u8`,
|
||||
stream: `https://trailer.littlecaprice-dreams.com/${trailerId}/playlist.m3u8`,
|
||||
quality: 1080,
|
||||
referer: url,
|
||||
};
|
||||
}
|
||||
|
||||
console.log(release.trailer);
|
||||
|
||||
const channelSlug = slugify(query.content('.project-tags a[href*="collection/"]'), '');
|
||||
|
||||
release.channel = channelMap[channelSlug] || channelSlug;
|
||||
|
||||
Reference in New Issue
Block a user