forked from DebaucheryLibrarian/traxxx
Added lazy loading to tag photos. Changed tag thumb location.
This commit is contained in:
@@ -7,6 +7,7 @@ const fs = require('fs').promises;
|
||||
const path = require('path');
|
||||
const nanoid = require('nanoid/non-secure');
|
||||
const mime = require('mime');
|
||||
const fileType = require('file-type');
|
||||
const sharp = require('sharp');
|
||||
const blake2 = require('blake2');
|
||||
|
||||
@@ -189,6 +190,10 @@ async function findHashDuplicates(medias) {
|
||||
const uniqueHashMedias = medias.filter(media => !media.entry && !existingHashMediaEntriesByHash[media.meta?.hash]);
|
||||
|
||||
const { selfDuplicateMedias, selfUniqueMediasByHash } = uniqueHashMedias.reduce((acc, media) => {
|
||||
if (!media.meta?.hash) {
|
||||
return acc;
|
||||
}
|
||||
|
||||
if (acc.selfUniqueMediasByHash[media.meta.hash]) {
|
||||
acc.selfDuplicateMedias.push({
|
||||
...media,
|
||||
@@ -307,7 +312,7 @@ async function fetchSource(source) {
|
||||
const { pathname } = new URL(source.src);
|
||||
const mimetype = mime.getType(pathname);
|
||||
const extension = mime.getExtension(mimetype);
|
||||
const type = mimetype.split('/')[0];
|
||||
const type = mimetype?.split('/')[0] || 'image';
|
||||
|
||||
const res = await http.get(source.src, {
|
||||
...(source.referer && { referer: source.referer }),
|
||||
|
||||
@@ -7,7 +7,7 @@ const moment = require('moment');
|
||||
|
||||
function extractTitle(originalTitle) {
|
||||
const titleComponents = originalTitle.split(' ');
|
||||
const sceneIdMatch = titleComponents.slice(-1)[0].match(/(AB|AF|GP|SZ|IV|GIO|RS|TW|MA|FM|SAL|NR|AA|GL|BZ|FS)\d+/); // detect studio prefixes
|
||||
const sceneIdMatch = titleComponents.slice(-1)[0].match(/(AB|AF|GP|SZ|IV|GIO|RS|TW|MA|FM|SAL|NR|AA|GL|BZ|FS|KS|OT)\d+/); // detect studio prefixes
|
||||
const shootId = sceneIdMatch ? sceneIdMatch[0] : null;
|
||||
const title = sceneIdMatch ? titleComponents.slice(0, -1).join(' ') : originalTitle;
|
||||
|
||||
@@ -73,8 +73,9 @@ function scrapeLatest(html, site) {
|
||||
|
||||
async function scrapeScene(html, url, site, useGallery) {
|
||||
const $ = cheerio.load(html, { normalizeWhitespace: true });
|
||||
const playerObject = $('script:contains("new VideoPlayer")').html();
|
||||
const data = JSON.parse(playerObject.slice(playerObject.indexOf('{"swf":'), playerObject.indexOf('} );') + 1));
|
||||
const playerObject = $('script:contains("new WatchPage")').html();
|
||||
const playerData = playerObject && playerObject.slice(playerObject.indexOf('{"swf":'), playerObject.lastIndexOf('},') + 1);
|
||||
const data = playerData && JSON.parse(playerData);
|
||||
|
||||
const release = { url };
|
||||
|
||||
@@ -122,12 +123,20 @@ async function scrapeScene(html, url, site, useGallery) {
|
||||
|
||||
release.poster = poster || release.photos.slice(Math.floor(release.photos.length / 3) * -1); // poster unavailable, try last 1/3rd of high res photos as fallback
|
||||
|
||||
const trailer = data.clip.qualities.find(clip => clip.quality === 'vga' || clip.quality === 'hd');
|
||||
release.trailer = {
|
||||
src: trailer.src,
|
||||
type: trailer.type,
|
||||
quality: trailer.quality === 'vga' ? 480 : 720,
|
||||
};
|
||||
if (data) {
|
||||
const qualityMap = {
|
||||
web: 240,
|
||||
vga: 480,
|
||||
hd: 720,
|
||||
'1080p': 1080,
|
||||
};
|
||||
|
||||
release.trailer = data.clip.qualities.map(trailer => ({
|
||||
src: trailer.src,
|
||||
type: trailer.type,
|
||||
quality: qualityMap[trailer.quality] || trailer.quality,
|
||||
}));
|
||||
}
|
||||
|
||||
const studioName = $('.watchpage-studioname').first().text().trim();
|
||||
release.studio = studioName.replace(/[\s.']+/g, '').toLowerCase();
|
||||
|
||||
Reference in New Issue
Block a user