fix(cli): more consistent labeling in movie/show download prompt
This commit is contained in:
parent
b316c58b1a
commit
a27c18101b
5 changed files with 25 additions and 21 deletions
|
@ -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 {};
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue