Fixed Team Skeet deep scrape and URL format, added duration.
This commit is contained in:
+16
-19
@@ -33,7 +33,8 @@ async function fetchTrailerUrl(videoId, entity) {
|
||||
const token = res.data.token;
|
||||
|
||||
if (token) {
|
||||
return `https://customer-bk3o9te23pydwwcb.cloudflarestream.com/${token}/manifest/video.mpd?parentOrigin=${entity.origin}`;
|
||||
// ffmpeg fails to read the DASH manifest over a single connection, HLS works
|
||||
return `https://customer-bk3o9te23pydwwcb.cloudflarestream.com/${token}/manifest/video.m3u8?parentOrigin=${entity.origin}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,11 +47,12 @@ async function scrapeScene(scene, channel, _parameters, includeTrailers) {
|
||||
// release.entryId = scene.id; // legacy
|
||||
release.entryId = scene.itemId;
|
||||
|
||||
release.url = `${channel.type === 'network' || channel.parameters?.layout === 'organic' ? channel.url : channel.parent.url}/movies/${release.entryId}`;
|
||||
release.url = `${channel.type === 'network' || channel.parameters?.layout === 'organic' ? channel.url : channel.parent.url}/movies/${scene.id || release.entryId}`; // numeric item ID URL 404s, id is the slug
|
||||
|
||||
release.title = scene.title;
|
||||
release.description = scene.description;
|
||||
release.date = unprint.extractDate(scene.publishedDate, 'YYYY-MM-DD');
|
||||
release.duration = scene.d;
|
||||
|
||||
release.actors = scene.models?.map((model) => ({
|
||||
name: model.modelName || model.name || model.title,
|
||||
@@ -113,27 +115,22 @@ async function fetchScene(url, channel, baseScene, { parameters, includeTrailers
|
||||
return baseScene;
|
||||
}
|
||||
|
||||
const sceneSlug = new URL(url).pathname.match(/\/([\w-]+$)/)[1];
|
||||
const sceneSlug = new URL(url).pathname.match(/\/([\w-]+)\/?$/)?.[1];
|
||||
|
||||
const res = await unprint.get(url, {
|
||||
parser: {
|
||||
runScripts: 'dangerously',
|
||||
},
|
||||
});
|
||||
if (!sceneSlug) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (res.ok) {
|
||||
const videos = res.context.window.__INITIAL_STATE__?.content?.videosContent;
|
||||
// scene page no longer embeds state, look up the scene in the elastic API by its slug instead
|
||||
// legacy URLs use the numeric item ID, which 404s on the site but can still be looked up
|
||||
const isItemId = /^\d+$/.test(sceneSlug);
|
||||
const res = await unprint.get(`https://tours-store.psmcdn.net/${parameters.endpoint}/_search?q=(${isItemId ? `itemId:${sceneSlug}` : `id:"${sceneSlug}"`} AND type:video)&size=1`);
|
||||
|
||||
res.context.window.fetch = () => {}; // suppress fetch missing error
|
||||
if (res.ok && res.data?.hits) {
|
||||
const scene = res.data.hits.hits.find(({ _source: hit }) => (isItemId ? String(hit.itemId) : hit.id) === sceneSlug)?._source;
|
||||
|
||||
if (!videos) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const video = videos?.[sceneSlug] || Object.values(videos)[0];
|
||||
|
||||
if (video) {
|
||||
return scrapeScene(video, channel, parameters, includeTrailers);
|
||||
if (scene) {
|
||||
return scrapeScene(scene, channel, parameters, includeTrailers);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user