forked from DebaucheryLibrarian/traxxx
Removed outdated movie releases from API. Added API endpoint for scene posters.
This commit is contained in:
parent
7bc4a955ba
commit
0d41fb48dc
|
@ -11,7 +11,7 @@
|
||||||
<span class="copy">By entering, you agree to the following</span>
|
<span class="copy">By entering, you agree to the following</span>
|
||||||
|
|
||||||
<ul class="rules">
|
<ul class="rules">
|
||||||
<li class="rule">You are at least 18 years old, and legally permitted to consume adult material in your jurisdiction.</li>
|
<li class="rule">You are at least 18 years old, and legally permitted to view adult material in your jurisdiction.</li>
|
||||||
<li class="rule">You are prepared see, hear and read erotic and sexual material, and do not regard such content as obscene or offensive.</li>
|
<li class="rule">You are prepared see, hear and read erotic and sexual material, and do not regard such content as obscene or offensive.</li>
|
||||||
<li class="rule">You understand that most sexual scenarios depicted on this website are fictional, performed by professional actors for the purpose of entertainment, and not representative of real-life interactions.</li>
|
<li class="rule">You understand that most sexual scenarios depicted on this website are fictional, performed by professional actors for the purpose of entertainment, and not representative of real-life interactions.</li>
|
||||||
<li class="rule">Respect your sexual partners, communicate about each other's desires and limits, and take precautions to prevent sexually transmitted infections and unintended pregnancies.</li>
|
<li class="rule">Respect your sexual partners, communicate about each other's desires and limits, and take precautions to prevent sexually transmitted infections and unintended pregnancies.</li>
|
||||||
|
|
|
@ -99,7 +99,7 @@ function withRelations(queryBuilder, withMedia = false) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchRelease(releaseId) {
|
async function fetchScene(releaseId) {
|
||||||
const release = await knex('releases')
|
const release = await knex('releases')
|
||||||
.where('releases.id', releaseId)
|
.where('releases.id', releaseId)
|
||||||
.modify(withRelations, true)
|
.modify(withRelations, true)
|
||||||
|
@ -108,7 +108,7 @@ async function fetchRelease(releaseId) {
|
||||||
return curateRelease(release, true);
|
return curateRelease(release, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchReleases(limit = 100) {
|
async function fetchScenes(limit = 100) {
|
||||||
const releases = await knex('releases')
|
const releases = await knex('releases')
|
||||||
.modify(withRelations, false)
|
.modify(withRelations, false)
|
||||||
.limit(Math.min(limit, 1000000));
|
.limit(Math.min(limit, 1000000));
|
||||||
|
@ -116,7 +116,7 @@ async function fetchReleases(limit = 100) {
|
||||||
return releases.map(release => curateRelease(release));
|
return releases.map(release => curateRelease(release));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function searchReleases(query, limit = 100) {
|
async function searchScenes(query, limit = 100) {
|
||||||
const releases = await knex
|
const releases = await knex
|
||||||
.from(knex.raw('search_releases(?) as releases', [query]))
|
.from(knex.raw('search_releases(?) as releases', [query]))
|
||||||
.modify(withRelations, false)
|
.modify(withRelations, false)
|
||||||
|
@ -189,10 +189,10 @@ async function flushBatches(batchIds) {
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
curateRelease,
|
curateRelease,
|
||||||
fetchRelease,
|
fetchScene,
|
||||||
fetchReleases,
|
fetchScenes,
|
||||||
flushBatches,
|
flushBatches,
|
||||||
searchReleases,
|
searchScenes,
|
||||||
deleteScenes,
|
deleteScenes,
|
||||||
deleteMovies,
|
deleteMovies,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,49 +1,46 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { fetchRelease, fetchReleases, searchReleases } = require('../releases');
|
const config = require('config');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
async function fetchReleaseApi(req, res, type = 'scene') {
|
const { fetchScene, fetchScenes, searchScenes } = require('../releases');
|
||||||
const release = await fetchRelease(req.params.releaseId, type);
|
|
||||||
|
async function fetchSceneApi(req, res) {
|
||||||
|
const release = await fetchScene(req.params.releaseId);
|
||||||
|
|
||||||
if (release) {
|
if (release) {
|
||||||
res.send({ [type]: release });
|
res.send({ scene: release });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
res.status(404).send({ [type]: null });
|
res.status(404).send({ scene: null });
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchReleasesApi(req, res, type = 'scene') {
|
|
||||||
const query = req.query.query || req.query.q;
|
|
||||||
|
|
||||||
const releases = query
|
|
||||||
? await searchReleases(query, req.query.limit, type)
|
|
||||||
: await fetchReleases(req.query.limit, type);
|
|
||||||
|
|
||||||
res.send({ [`${type}s`]: releases });
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchSceneApi(req, res) {
|
|
||||||
return fetchReleaseApi(req, res, 'scene');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchScenesApi(req, res) {
|
async function fetchScenesApi(req, res) {
|
||||||
return fetchReleasesApi(req, res, 'scene');
|
const query = req.query.query || req.query.q;
|
||||||
|
|
||||||
|
const releases = query
|
||||||
|
? await searchScenes(query, req.query.limit)
|
||||||
|
: await fetchScenes(req.query.limit);
|
||||||
|
|
||||||
|
res.send({ scenes: releases });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchMovieApi(req, res) {
|
async function fetchScenePosterApi(req, res) {
|
||||||
return fetchReleaseApi(req, res, 'movie');
|
const scene = await fetchScene(req.params.releaseId);
|
||||||
|
const posterPath = scene?.poster?.path;
|
||||||
|
|
||||||
|
if (posterPath) {
|
||||||
|
res.sendFile(path.resolve(config.media.path, posterPath));
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchMoviesApi(req, res) {
|
res.status(404).send();
|
||||||
return fetchReleasesApi(req, res, 'movie');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
fetchRelease: fetchReleaseApi,
|
|
||||||
fetchReleases: fetchReleasesApi,
|
|
||||||
fetchScene: fetchSceneApi,
|
fetchScene: fetchSceneApi,
|
||||||
fetchMovie: fetchMovieApi,
|
|
||||||
fetchScenes: fetchScenesApi,
|
fetchScenes: fetchScenesApi,
|
||||||
fetchMovies: fetchMoviesApi,
|
fetchScenePoster: fetchScenePosterApi,
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,8 +17,7 @@ const { ActorPlugins, SitePlugins, ReleasePlugins } = require('./plugins/plugins
|
||||||
const {
|
const {
|
||||||
fetchScene,
|
fetchScene,
|
||||||
fetchScenes,
|
fetchScenes,
|
||||||
fetchMovie,
|
fetchScenePoster,
|
||||||
fetchMovies,
|
|
||||||
} = require('./releases');
|
} = require('./releases');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -81,9 +80,10 @@ async function initServer() {
|
||||||
|
|
||||||
router.get('/api/scenes', fetchScenes);
|
router.get('/api/scenes', fetchScenes);
|
||||||
router.get('/api/scenes/:releaseId', fetchScene);
|
router.get('/api/scenes/:releaseId', fetchScene);
|
||||||
|
router.get('/api/scenes/:releaseId/poster', fetchScenePoster);
|
||||||
|
|
||||||
router.get('/api/movies', fetchMovies);
|
// router.get('/api/movies', fetchMovies);
|
||||||
router.get('/api/movies/:releaseId', fetchMovie);
|
// router.get('/api/movies/:releaseId', fetchMovie);
|
||||||
|
|
||||||
router.get('/api/actors', fetchActors);
|
router.get('/api/actors', fetchActors);
|
||||||
router.get('/api/actors/:actorId', fetchActor);
|
router.get('/api/actors/:actorId', fetchActor);
|
||||||
|
|
Loading…
Reference in New Issue