forked from DebaucheryLibrarian/traxxx
Fixed Gamma movie scraper failing when data object is not available.
This commit is contained in:
parent
523c36ecd4
commit
65e2b72c6a
|
@ -24,6 +24,19 @@ function getApiUrl(appId, apiKey) {
|
|||
};
|
||||
}
|
||||
|
||||
function getAvatarFallbacks(avatar) {
|
||||
if (!avatar) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
avatar.replace(/\d+x\d+/, '500x750'),
|
||||
avatar.replace(/\d+x\d+/, '240x360'),
|
||||
avatar.replace(/\d+x\d+/, '200x300'),
|
||||
avatar,
|
||||
];
|
||||
}
|
||||
|
||||
async function fetchApiCredentials(referer, site) {
|
||||
if (site?.parameters?.appId && site?.parameters?.apiKey) {
|
||||
return getApiUrl(site.parameters.appId, site.parameters.apiKey);
|
||||
|
@ -450,7 +463,8 @@ async function fetchMovieTrailer(release) {
|
|||
|
||||
async function scrapeMovie({ query, el }, window, url, entity, options) {
|
||||
const release = {};
|
||||
const data = window.dataLayer[0]?.dvdDetails;
|
||||
const rawData = window.dataLayer[0]?.dvdDetails;
|
||||
const data = rawData.dvdId && rawData; // dvdDetails is mostly empty in some cache states
|
||||
|
||||
release.entryId = new URL(url).pathname.match(/\/(\d+)(\/|$)/)?.[1];
|
||||
|
||||
|
@ -460,12 +474,19 @@ async function scrapeMovie({ query, el }, window, url, entity, options) {
|
|||
];
|
||||
|
||||
release.description = query.cnt('.descriptionText');
|
||||
release.date = qu.extractDate(data.dvdReleaseDate);
|
||||
release.title = data.dvdName;
|
||||
release.date = qu.extractDate(data?.dvdReleaseDate) || query.date('.updatedOn', 'YYYY-MM-DD');
|
||||
release.title = data?.dvdName || query.cnt('.dvdTitle');
|
||||
release.director = query.el('.directedBy a', 'title');
|
||||
|
||||
release.actors = data?.dvdActors.map((actor) => ({ name: actor.actorName, entryId: actor.actorId }))
|
||||
|| query.all('.actorCarousel a[href*="/pornstar"]').map((actorEl) => ({
|
||||
entryId: query.url(actorEl, null).match(/\/(\d+)/)?.[1],
|
||||
name: query.cnt(actorEl, 'span'),
|
||||
href: query.url(actorEl, null, 'href', { origin: entity.url }),
|
||||
avatar: getAvatarFallbacks(query.img(actorEl)),
|
||||
}));
|
||||
|
||||
release.actors = data.dvdActors.map((actor) => ({ name: actor.actorName, entryId: actor.actorId }));
|
||||
release.tags = query.cnts('.dvdCol a');
|
||||
|
||||
release.scenes = scrapeAll(qu.initAll(el, 'div[data-itemtype*=scene], li[data-itemtype*=scene]'), entity, entity.url);
|
||||
|
||||
if (options.includeTrailers) {
|
||||
|
@ -510,7 +531,7 @@ async function fetchActorReleases(profileUrl, getActorReleasesUrl, page = 1, acc
|
|||
}
|
||||
|
||||
async function scrapeProfile({ query }, url, actorName, _siteSlug, getActorReleasesUrl, withReleases, context) {
|
||||
const avatar = query.el('img.actorPicture');
|
||||
const avatar = query.img('img.actorPicture');
|
||||
const hair = query.cnt('.actorProfile .attribute_hair_color');
|
||||
const height = query.cnt('.actorProfile .attribute_height');
|
||||
const weight = query.cnt('.actorProfile .attribute_weight');
|
||||
|
@ -523,12 +544,7 @@ async function scrapeProfile({ query }, url, actorName, _siteSlug, getActorRelea
|
|||
|
||||
if (avatar) {
|
||||
// larger sizes usually available, provide fallbacks
|
||||
const avatars = [
|
||||
avatar.src.replace(/\d+x\d+/, '500x750'),
|
||||
avatar.src.replace(/\d+x\d+/, '240x360'),
|
||||
avatar.src.replace(/\d+x\d+/, '200x300'),
|
||||
avatar.src,
|
||||
];
|
||||
const avatars = getAvatarFallbacks(avatar);
|
||||
|
||||
profile.avatar = avatars;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue