diff --git a/cli/lib/config.js b/cli/lib/config.js index f50ecfc..b5f92f8 100644 --- a/cli/lib/config.js +++ b/cli/lib/config.js @@ -8,7 +8,12 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url)); const rootDir = path.resolve(__dirname, '..'); const CACHE_DIR = path.join(rootDir, '.cache'); const CONFIG_PATH = path.join(CACHE_DIR, 'config.json'); -const MEDIA_TYPES = ['movie', 'show']; + +export const MEDIA_TYPES = [ + { key: 'movie', label: 'movie', folder: 'movies' }, + { key: 'show', label: 'tv show', folder: 'shows' } +]; + const ASSET_TYPES = ['poster', 'backdrop']; dotenv.config({ path: path.resolve(__dirname, '..', '..', '.env') }); @@ -61,20 +66,19 @@ export const initConfig = async () => { config.mediaPaths = {}; - for (const mediaType of MEDIA_TYPES) { - config.mediaPaths[mediaType] = {}; + for (const { key, label, folder } of MEDIA_TYPES) { + config.mediaPaths[key] = {}; for (const assetType of ASSET_TYPES) { - const mediaFolder = `${mediaType}s`; const assetFolder = assetType === 'poster' ? '' : `/${assetType}s`; - const defaultPath = `Media assets/${mediaFolder}${assetFolder}`.replace(/\/$/, ''); + const defaultPath = `Media assets/${folder}${assetFolder}`.replace(/\/$/, ''); let subpath = defaultPath; if (customize) { const response = await inquirer.prompt([ { name: 'subpath', - message: `Subpath for ${mediaType}/${assetType} (relative to storage root):`, + message: `Subpath for ${label}/${assetType} (relative to storage root):`, default: defaultPath } ]); @@ -82,7 +86,7 @@ export const initConfig = async () => { subpath = response.subpath; } - config.mediaPaths[mediaType][assetType] = subpath; + config.mediaPaths[key][assetType] = subpath; } } @@ -167,7 +171,7 @@ export const initConfig = async () => { export const loadConfig = async () => { if (!(await fs.pathExists(CONFIG_PATH))) { - console.error('❌ Config not found. Run `coryd init` first.'); + console.error('❌ Config not found. Run \`coryd init\` first.'); process.exit(1); } @@ -180,7 +184,6 @@ const fetchGlobals = async () => { if (!POSTGREST_URL || !POSTGREST_API_KEY) { console.warn('⚠️ Missing POSTGREST_URL or POSTGREST_API_KEY in env, skipping globals fetch.'); - return {}; } @@ -196,11 +199,9 @@ const fetchGlobals = async () => { if (!res.ok) throw new Error(await res.text()); const data = await res.json(); - return data[0] || {}; } catch (err) { console.error('❌ Error fetching globals:', err.message); - return {}; } }; diff --git a/cli/lib/download.js b/cli/lib/download.js index bb598fd..116bac8 100644 --- a/cli/lib/download.js +++ b/cli/lib/download.js @@ -3,7 +3,7 @@ import path from 'path'; import https from 'https'; import inquirer from 'inquirer'; import { fileURLToPath } from 'url'; -import { loadConfig } from './config.js'; +import { loadConfig, MEDIA_TYPES } from './config.js'; import { sanitizeMediaString } from './sanitize.js'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); @@ -51,8 +51,11 @@ export const downloadWatchingImages = async () => { const { mediaType } = await inquirer.prompt({ type: 'list', name: 'mediaType', - message: 'Movie or a show?', - choices: Object.keys(config.mediaPaths) + message: 'Movie or a tv show?', + choices: MEDIA_TYPES.map(({ key, label }) => ({ + name: label, + value: key + })) }); const { tmdbId } = await inquirer.prompt({ name: 'tmdbId', @@ -241,7 +244,7 @@ export const downloadAsset = async () => { type: 'list', name: 'type', message: 'What type of asset are you downloading?', - choices: ['movie/show', 'artist', 'album', 'book'] + choices: ['movie/tv show', 'artist', 'album', 'book'] }); if (type === 'artist') { diff --git a/cli/lib/jobs.js b/cli/lib/jobs.js index aa5c2fc..609543b 100644 --- a/cli/lib/jobs.js +++ b/cli/lib/jobs.js @@ -70,7 +70,7 @@ export const runJobsMenu = async () => { ] }, { - name: '📽 Import movie or show', + name: '📽 Import a movie or tv show', type: 'curl', apiUrl: `${config.url}/api/watching-import.php`, tokenEnvVar: 'WATCHING_IMPORT_TOKEN', @@ -86,8 +86,8 @@ export const runJobsMenu = async () => { { type: 'list', name: 'media_type', - message: 'Is this a movie or a show?', - choices: ['movie', 'show'] + message: 'Is this a movie or tv show?', + choices: ['movie', 'tv'] } ] }, diff --git a/cli/package-lock.json b/cli/package-lock.json index d3617fa..066f8ef 100644 --- a/cli/package-lock.json +++ b/cli/package-lock.json @@ -1,12 +1,12 @@ { "name": "coryd", - "version": "3.2.5", + "version": "3.2.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "coryd", - "version": "3.2.5", + "version": "3.2.6", "dependencies": { "@directus/sdk": "^19.1.0", "chalk": "^5.4.1", diff --git a/cli/package.json b/cli/package.json index 9adea6d..94d2f8d 100644 --- a/cli/package.json +++ b/cli/package.json @@ -1,6 +1,6 @@ { "name": "coryd", - "version": "3.2.5", + "version": "3.2.6", "description": "The CLI for my site to handle tasks, run commands or jobs and download things.", "type": "module", "bin": {