From 3d80e9d77b8c695c6f378ce585471b5f492ba0d0 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Thu, 3 Feb 2022 00:04:48 +0100 Subject: [PATCH] Added movie URL file support. Fixed Gamma movie API scraper movie URL. --- assets/js/releases/actions.js | 4 ++++ src/app.js | 5 ++++- src/argv.js | 5 +++++ src/scrapers/gamma.js | 4 ++-- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/assets/js/releases/actions.js b/assets/js/releases/actions.js index bf337692..1c423e66 100644 --- a/assets/js/releases/actions.js +++ b/assets/js/releases/actions.js @@ -110,6 +110,8 @@ function initReleasesActions(store, router) { $query: String! $limit:Int = 20 $offset:Int = 0 + $hasAuth: Boolean! + $userId: Int ) { connection: searchMoviesConnection( query: $query @@ -126,6 +128,8 @@ function initReleasesActions(store, router) { } } `, { + hasAuth: !!store.state.auth.user, + userId: store.state.auth.user?.id, query, limit, offset: Math.max(0, (pageNumber - 1)) * limit, diff --git a/src/app.js b/src/app.js index c7d418d8..4a36daf2 100644 --- a/src/app.js +++ b/src/app.js @@ -174,8 +174,11 @@ async function init() { const storedScenes = argv.save ? await storeScenes(deepScenes) : []; + const moviesFromFile = argv.moviesFile && await getFileEntries(argv.moviesFile); + const movieUrls = (argv.movie || []).concat(moviesFromFile || []); + const sceneMovies = deepScenes ? deepScenes.filter((scene) => scene.movie).map((scene) => ({ ...scene.movie, entity: scene.entity })) : []; - const deepMovies = argv.sceneMovies || argv.movie ? await fetchMovies([...(argv.movie || []), ...(sceneMovies || [])]) : sceneMovies; + const deepMovies = argv.sceneMovies || argv.movie || movieUrls ? await fetchMovies([...movieUrls, ...(sceneMovies || []), ...[]]) : sceneMovies; const movieScenes = argv.movieScenes ? deepMovies.map((movie) => movie.scenes?.map((scene) => ({ ...scene, movie, entity: movie.entity }))).flat().filter(Boolean) : []; const deepMovieScenes = argv.deep ? await fetchScenes(movieScenes) : movieScenes; diff --git a/src/argv.js b/src/argv.js index 42522bd0..17e38a5e 100644 --- a/src/argv.js +++ b/src/argv.js @@ -107,6 +107,11 @@ const { argv } = yargs describe: 'Scrape movie info from URL', type: 'array', }) + .option('movie-file', { + describe: 'Scrape movie info from URLs in a file', + type: 'string', + alias: 'movies-file', + }) .option('deep', { describe: 'Fetch details for all releases', type: 'boolean', diff --git a/src/scrapers/gamma.js b/src/scrapers/gamma.js index 0ecdbd8d..c5a76197 100644 --- a/src/scrapers/gamma.js +++ b/src/scrapers/gamma.js @@ -448,8 +448,8 @@ async function scrapeReleaseApi(data, site, options) { if (data.cover_path) { release.covers = [ - getImageSources(`/${data.cover_path}_front_400x625.jpg?width=450&height=636&format=webp`), - getImageSources(`/${data.cover_path}_back_400x625.jpg?width=450&height=636&format=webp`), + getImageSources(`${data.cover_path}_front_400x625.jpg?width=450&height=636&format=webp`), + getImageSources(`${data.cover_path}_back_400x625.jpg?width=450&height=636&format=webp`), ]; }