forked from DebaucheryLibrarian/traxxx
Added alias and privileges to metadata migration.
This commit is contained in:
parent
31f8bd4d84
commit
8749b464fd
|
@ -1,3 +1,5 @@
|
||||||
|
const config = require('config');
|
||||||
|
|
||||||
exports.up = async function up(knex) {
|
exports.up = async function up(knex) {
|
||||||
await knex.raw(`
|
await knex.raw(`
|
||||||
CREATE MATERIALIZED VIEW actors_meta AS (
|
CREATE MATERIALIZED VIEW actors_meta AS (
|
||||||
|
@ -40,9 +42,15 @@ exports.up = async function up(knex) {
|
||||||
LEFT JOIN movies_scenes ON movies_scenes.movie_id = movies.id
|
LEFT JOIN movies_scenes ON movies_scenes.movie_id = movies.id
|
||||||
LEFT JOIN stashes_scenes ON stashes_scenes.scene_id = movies_scenes.scene_id
|
LEFT JOIN stashes_scenes ON stashes_scenes.scene_id = movies_scenes.scene_id
|
||||||
GROUP BY movies.id
|
GROUP BY movies.id
|
||||||
)
|
) AS meta
|
||||||
);
|
);
|
||||||
`);
|
|
||||||
|
GRANT ALL ON actors_meta TO :visitor;
|
||||||
|
GRANT ALL ON scenes_meta TO :visitor;
|
||||||
|
GRANT ALL ON movies_meta TO :visitor;
|
||||||
|
`, {
|
||||||
|
visitor: knex.raw(config.database.query.user),
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.down = async function down(knex) {
|
exports.down = async function down(knex) {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { JSDOM } = require('jsdom');
|
const { JSDOM } = require('jsdom');
|
||||||
const unprint = require('unprint');
|
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
|
|
||||||
const http = require('../utils/http');
|
const http = require('../utils/http');
|
||||||
|
@ -51,16 +50,14 @@ function scrapeLatest(html, site) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(release);
|
|
||||||
|
|
||||||
return release;
|
return release;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function scrapeScene({ query }, { url, entity }) {
|
function scrapeScene(html, site, url) {
|
||||||
const release = {};
|
const { document } = new JSDOM(html).window;
|
||||||
|
const release = { site };
|
||||||
|
|
||||||
<<<<<<< Updated upstream
|
|
||||||
const scene = document.querySelector('#t2019-2col');
|
const scene = document.querySelector('#t2019-2col');
|
||||||
|
|
||||||
release.url = url;
|
release.url = url;
|
||||||
|
@ -81,46 +78,42 @@ function scrapeScene({ query }, { url, entity }) {
|
||||||
release.photos = Array.from(scene.querySelectorAll('#t2019-main .t2019-thumbs img'), (el) => ({
|
release.photos = Array.from(scene.querySelectorAll('#t2019-main .t2019-thumbs img'), (el) => ({
|
||||||
src: (/^http/.test(el.src) ? el.src : `https:${el.src}`),
|
src: (/^http/.test(el.src) ? el.src : `https:${el.src}`),
|
||||||
referer: site.url,
|
referer: site.url,
|
||||||
=======
|
|
||||||
release.entryId = new URL(url).pathname.match('video/(.*)')?.[1];
|
|
||||||
|
|
||||||
release.title = query.content('.scene-info .text-2xl');
|
|
||||||
release.description = query.content('.scene-info .space-x-4 span');
|
|
||||||
|
|
||||||
release.actors = query.all('.scene-info .link-list-with-commas a').map((el) => ({
|
|
||||||
name: unprint.query.content(el),
|
|
||||||
url: unprint.query.url(el, null, { origin: entity.url }),
|
|
||||||
}));
|
|
||||||
|
|
||||||
// unreliable CDN
|
|
||||||
release.photos = query.imgs('#trailer_player .flex-row img').filter((src) => src?.includes('cdn.')).map((src) => ({
|
|
||||||
src,
|
|
||||||
referer: entity.url,
|
|
||||||
>>>>>>> Stashed changes
|
|
||||||
attempts: 5,
|
attempts: 5,
|
||||||
interval: 5000,
|
interval: 5000,
|
||||||
concurrency: 1,
|
concurrency: 1,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
release.poster = {
|
const posterEl = scene.querySelector('#no-player-image');
|
||||||
src: query.img('#no-player-image') || query.poster('#player'),
|
const videoEl = scene.querySelector('video');
|
||||||
referer: entity.url,
|
const trailerEl = scene.querySelector('#t2019-video source');
|
||||||
attempts: 5,
|
|
||||||
interval: 5000,
|
|
||||||
concurrency: 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (query.exists('#player source')) {
|
if (posterEl) {
|
||||||
release.trailer = {
|
release.poster = {
|
||||||
src: query.video('#player source'),
|
src: /^http/.test(posterEl.src) ? posterEl.src : `https:${posterEl.src}`,
|
||||||
referer: entity.url,
|
referer: site.url,
|
||||||
|
attempts: 5,
|
||||||
|
interval: 5000,
|
||||||
|
concurrency: 1,
|
||||||
|
};
|
||||||
|
} else if (videoEl) {
|
||||||
|
release.poster = {
|
||||||
|
src: /^http/.test(videoEl.poster) ? videoEl.poster : `https:${videoEl.poster}`,
|
||||||
|
referer: site.url,
|
||||||
attempts: 5,
|
attempts: 5,
|
||||||
interval: 5000,
|
interval: 5000,
|
||||||
concurrency: 1,
|
concurrency: 1,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(release);
|
if (trailerEl) {
|
||||||
|
release.trailer = {
|
||||||
|
src: trailerEl.src,
|
||||||
|
referer: site.url,
|
||||||
|
attempts: 5,
|
||||||
|
interval: 5000,
|
||||||
|
concurrency: 1,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return release;
|
return release;
|
||||||
}
|
}
|
||||||
|
@ -136,10 +129,17 @@ async function fetchLatest(site, page = 1) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function fetchScene(url, site) {
|
||||||
|
const res = await http.get(url);
|
||||||
|
|
||||||
|
if (res.statusCode === 200) {
|
||||||
|
return scrapeScene(res.body.toString(), site, url);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
fetchLatest,
|
fetchLatest,
|
||||||
scrapeScene: {
|
fetchScene,
|
||||||
scraper: scrapeScene,
|
|
||||||
unprint: true,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue