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>
|
||||
|
||||
<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 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>
|
||||
|
|
|
@ -99,7 +99,7 @@ function withRelations(queryBuilder, withMedia = false) {
|
|||
}
|
||||
}
|
||||
|
||||
async function fetchRelease(releaseId) {
|
||||
async function fetchScene(releaseId) {
|
||||
const release = await knex('releases')
|
||||
.where('releases.id', releaseId)
|
||||
.modify(withRelations, true)
|
||||
|
@ -108,7 +108,7 @@ async function fetchRelease(releaseId) {
|
|||
return curateRelease(release, true);
|
||||
}
|
||||
|
||||
async function fetchReleases(limit = 100) {
|
||||
async function fetchScenes(limit = 100) {
|
||||
const releases = await knex('releases')
|
||||
.modify(withRelations, false)
|
||||
.limit(Math.min(limit, 1000000));
|
||||
|
@ -116,7 +116,7 @@ async function fetchReleases(limit = 100) {
|
|||
return releases.map(release => curateRelease(release));
|
||||
}
|
||||
|
||||
async function searchReleases(query, limit = 100) {
|
||||
async function searchScenes(query, limit = 100) {
|
||||
const releases = await knex
|
||||
.from(knex.raw('search_releases(?) as releases', [query]))
|
||||
.modify(withRelations, false)
|
||||
|
@ -189,10 +189,10 @@ async function flushBatches(batchIds) {
|
|||
|
||||
module.exports = {
|
||||
curateRelease,
|
||||
fetchRelease,
|
||||
fetchReleases,
|
||||
fetchScene,
|
||||
fetchScenes,
|
||||
flushBatches,
|
||||
searchReleases,
|
||||
searchScenes,
|
||||
deleteScenes,
|
||||
deleteMovies,
|
||||
};
|
||||
|
|
|
@ -1,49 +1,46 @@
|
|||
'use strict';
|
||||
|
||||
const { fetchRelease, fetchReleases, searchReleases } = require('../releases');
|
||||
const config = require('config');
|
||||
const path = require('path');
|
||||
|
||||
async function fetchReleaseApi(req, res, type = 'scene') {
|
||||
const release = await fetchRelease(req.params.releaseId, type);
|
||||
const { fetchScene, fetchScenes, searchScenes } = require('../releases');
|
||||
|
||||
async function fetchSceneApi(req, res) {
|
||||
const release = await fetchScene(req.params.releaseId);
|
||||
|
||||
if (release) {
|
||||
res.send({ [type]: release });
|
||||
res.send({ scene: release });
|
||||
return;
|
||||
}
|
||||
|
||||
res.status(404).send({ [type]: 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');
|
||||
res.status(404).send({ scene: null });
|
||||
}
|
||||
|
||||
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) {
|
||||
return fetchReleaseApi(req, res, 'movie');
|
||||
async function fetchScenePosterApi(req, res) {
|
||||
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) {
|
||||
return fetchReleasesApi(req, res, 'movie');
|
||||
res.status(404).send();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
fetchRelease: fetchReleaseApi,
|
||||
fetchReleases: fetchReleasesApi,
|
||||
fetchScene: fetchSceneApi,
|
||||
fetchMovie: fetchMovieApi,
|
||||
fetchScenes: fetchScenesApi,
|
||||
fetchMovies: fetchMoviesApi,
|
||||
fetchScenePoster: fetchScenePosterApi,
|
||||
};
|
||||
|
|
|
@ -17,8 +17,7 @@ const { ActorPlugins, SitePlugins, ReleasePlugins } = require('./plugins/plugins
|
|||
const {
|
||||
fetchScene,
|
||||
fetchScenes,
|
||||
fetchMovie,
|
||||
fetchMovies,
|
||||
fetchScenePoster,
|
||||
} = require('./releases');
|
||||
|
||||
const {
|
||||
|
@ -81,9 +80,10 @@ async function initServer() {
|
|||
|
||||
router.get('/api/scenes', fetchScenes);
|
||||
router.get('/api/scenes/:releaseId', fetchScene);
|
||||
router.get('/api/scenes/:releaseId/poster', fetchScenePoster);
|
||||
|
||||
router.get('/api/movies', fetchMovies);
|
||||
router.get('/api/movies/:releaseId', fetchMovie);
|
||||
// router.get('/api/movies', fetchMovies);
|
||||
// router.get('/api/movies/:releaseId', fetchMovie);
|
||||
|
||||
router.get('/api/actors', fetchActors);
|
||||
router.get('/api/actors/:actorId', fetchActor);
|
||||
|
|
Loading…
Reference in New Issue