chore(*): use prettier for formatting
This commit is contained in:
parent
6c659fe1d0
commit
ce869012ef
73 changed files with 1393 additions and 794 deletions
|
@ -1,6 +1,12 @@
|
|||
import inquirer from 'inquirer';
|
||||
import { loadConfig } from '../config.js';
|
||||
import { initDirectusClient, getDirectusClient, searchItems, createItem, updateItem } from '../directus/client.js';
|
||||
import {
|
||||
initDirectusClient,
|
||||
getDirectusClient,
|
||||
searchItems,
|
||||
createItem,
|
||||
updateItem
|
||||
} from '../directus/client.js';
|
||||
|
||||
export const addEpisodeToShow = async () => {
|
||||
const config = await loadConfig();
|
||||
|
@ -10,7 +16,7 @@ export const addEpisodeToShow = async () => {
|
|||
const directus = getDirectusClient();
|
||||
const showResults = await inquirer.prompt({
|
||||
name: 'query',
|
||||
message: 'Search for a show:',
|
||||
message: 'Search for a show:'
|
||||
});
|
||||
const matches = await searchItems('shows', showResults.query);
|
||||
|
||||
|
@ -24,34 +30,35 @@ export const addEpisodeToShow = async () => {
|
|||
type: 'list',
|
||||
name: 'showId',
|
||||
message: 'Select a show:',
|
||||
choices: matches.map(s => ({
|
||||
choices: matches.map((s) => ({
|
||||
name: s.title || s.name || s.id,
|
||||
value: s.id,
|
||||
})),
|
||||
value: s.id
|
||||
}))
|
||||
});
|
||||
const { season_number, episode_number, plays } = await inquirer.prompt([
|
||||
{
|
||||
name: 'season_number',
|
||||
message: 'Season number:',
|
||||
validate: val => !isNaN(val),
|
||||
validate: (val) => !isNaN(val)
|
||||
},
|
||||
{
|
||||
name: 'episode_number',
|
||||
message: 'Episode number:',
|
||||
validate: val => !isNaN(val),
|
||||
validate: (val) => !isNaN(val)
|
||||
},
|
||||
{
|
||||
name: 'plays',
|
||||
message: 'Play count:',
|
||||
default: 0,
|
||||
validate: val => !isNaN(val),
|
||||
},
|
||||
validate: (val) => !isNaN(val)
|
||||
}
|
||||
]);
|
||||
const existing = await searchItems('episodes', `${season_number} ${episode_number}`);
|
||||
const match = existing.find(e =>
|
||||
Number(e.season_number) === Number(season_number) &&
|
||||
Number(e.episode_number) === Number(episode_number) &&
|
||||
e.show === showId
|
||||
const match = existing.find(
|
||||
(e) =>
|
||||
Number(e.season_number) === Number(season_number) &&
|
||||
Number(e.episode_number) === Number(episode_number) &&
|
||||
e.show === showId
|
||||
);
|
||||
|
||||
if (match) {
|
||||
|
@ -59,7 +66,7 @@ export const addEpisodeToShow = async () => {
|
|||
type: 'confirm',
|
||||
name: 'update',
|
||||
message: `Episode exists. Update play count from ${match.plays ?? 0} to ${plays}?`,
|
||||
default: true,
|
||||
default: true
|
||||
});
|
||||
|
||||
if (update) {
|
||||
|
@ -74,7 +81,7 @@ export const addEpisodeToShow = async () => {
|
|||
season_number: Number(season_number),
|
||||
episode_number: Number(episode_number),
|
||||
plays: Number(plays),
|
||||
show: showId,
|
||||
show: showId
|
||||
});
|
||||
|
||||
console.log(`📺 Created episode S${season_number}E${episode_number}`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue