|
|
@@ -2,9 +2,13 @@ import chalk from "chalk";
|
|
|
import { Command } from "commander";
|
|
|
import inquirer from "inquirer";
|
|
|
import { del, get, post } from "./api.js";
|
|
|
+import { addIndexingCommands } from "./indexing-commands.js";
|
|
|
|
|
|
const program = new Command();
|
|
|
|
|
|
+// Add indexing and duplicate detection commands
|
|
|
+addIndexingCommands(program);
|
|
|
+
|
|
|
program
|
|
|
.option("-i, --interactive", "Run in interactive mode")
|
|
|
.name("watch-finished-cli")
|
|
|
@@ -78,7 +82,7 @@ program
|
|
|
const dirs = opts.dirs.split(",").map((d: string) => d.trim());
|
|
|
const result = await post("/maintenance/cleanup", {
|
|
|
file: opts.file,
|
|
|
- dirs
|
|
|
+ dirs,
|
|
|
});
|
|
|
console.log(result);
|
|
|
});
|
|
|
@@ -94,7 +98,7 @@ program
|
|
|
const result = await post("/maintenance/purge", {
|
|
|
dirs,
|
|
|
dayMs: opts.dayMs,
|
|
|
- cleanerMs: opts.cleanerMs
|
|
|
+ cleanerMs: opts.cleanerMs,
|
|
|
});
|
|
|
console.log(result);
|
|
|
});
|
|
|
@@ -128,7 +132,7 @@ program
|
|
|
const result = await post("/handbrake/process", {
|
|
|
input: opts.input,
|
|
|
output: opts.output,
|
|
|
- preset: opts.preset
|
|
|
+ preset: opts.preset,
|
|
|
});
|
|
|
console.log(result);
|
|
|
});
|
|
|
@@ -169,7 +173,7 @@ program
|
|
|
.option("--soft <soft>", "Soft delete (true/false)", "true")
|
|
|
.action(async (opts) => {
|
|
|
const result = await del(`/files/${opts.dataset}/${opts.file}`, {
|
|
|
- soft: opts.soft
|
|
|
+ soft: opts.soft,
|
|
|
});
|
|
|
console.log(result);
|
|
|
});
|
|
|
@@ -297,7 +301,7 @@ program
|
|
|
const dirs = opts.dirs.split(",").map((d: string) => d.trim());
|
|
|
const result = await post("/maintenance/cleanup", {
|
|
|
file: opts.file,
|
|
|
- dirs
|
|
|
+ dirs,
|
|
|
});
|
|
|
console.log(result);
|
|
|
});
|
|
|
@@ -313,7 +317,7 @@ program
|
|
|
const result = await post("/maintenance/purge", {
|
|
|
dirs,
|
|
|
dayMs: opts.dayMs,
|
|
|
- cleanerMs: opts.cleanerMs
|
|
|
+ cleanerMs: opts.cleanerMs,
|
|
|
});
|
|
|
console.log(result);
|
|
|
});
|
|
|
@@ -347,7 +351,7 @@ program
|
|
|
const result = await post("/handbrake/process", {
|
|
|
input: opts.input,
|
|
|
output: opts.output,
|
|
|
- preset: opts.preset
|
|
|
+ preset: opts.preset,
|
|
|
});
|
|
|
console.log(result);
|
|
|
});
|
|
|
@@ -388,7 +392,7 @@ program
|
|
|
.option("--soft <soft>", "Soft delete (true/false)", "true")
|
|
|
.action(async (opts) => {
|
|
|
const result = await del(`/files/${opts.dataset}/${opts.file}`, {
|
|
|
- soft: opts.soft
|
|
|
+ soft: opts.soft,
|
|
|
});
|
|
|
console.log(result);
|
|
|
});
|
|
|
@@ -502,9 +506,9 @@ async function runInteractive() {
|
|
|
{ name: "👀 Watcher Control", value: "watcher" },
|
|
|
{ name: "🧹 Maintenance", value: "maintenance" },
|
|
|
{ name: "🎬 HandBrake", value: "handbrake" },
|
|
|
- { name: "❌ Exit", value: "exit" }
|
|
|
- ]
|
|
|
- }
|
|
|
+ { name: "❌ Exit", value: "exit" },
|
|
|
+ ],
|
|
|
+ },
|
|
|
]);
|
|
|
|
|
|
if (category === "exit") {
|
|
|
@@ -552,9 +556,9 @@ async function handleTaskCommands() {
|
|
|
{ name: "📊 Queue status", value: "queue-status" },
|
|
|
{ name: "⚙️ Queue settings", value: "queue-settings" },
|
|
|
{ name: "🔧 Update queue settings", value: "queue-settings-update" },
|
|
|
- { name: "⬅️ Back to main menu", value: "back" }
|
|
|
- ]
|
|
|
- }
|
|
|
+ { name: "⬅️ Back to main menu", value: "back" },
|
|
|
+ ],
|
|
|
+ },
|
|
|
]);
|
|
|
|
|
|
if (command === "back") return;
|
|
|
@@ -567,7 +571,7 @@ async function handleTaskCommands() {
|
|
|
break;
|
|
|
case "get":
|
|
|
const { id } = await inquirer.prompt([
|
|
|
- { type: "input", name: "id", message: "Enter task ID:" }
|
|
|
+ { type: "input", name: "id", message: "Enter task ID:" },
|
|
|
]);
|
|
|
const task = await get(`/tasks/${id}`);
|
|
|
console.log(task);
|
|
|
@@ -577,8 +581,8 @@ async function handleTaskCommands() {
|
|
|
{
|
|
|
type: "input",
|
|
|
name: "deleteId",
|
|
|
- message: "Enter task ID to delete:"
|
|
|
- }
|
|
|
+ message: "Enter task ID to delete:",
|
|
|
+ },
|
|
|
]);
|
|
|
const result = await del(`/tasks/${deleteId}`);
|
|
|
console.log("Task deleted:", result);
|
|
|
@@ -597,38 +601,38 @@ async function handleTaskCommands() {
|
|
|
type: "number",
|
|
|
name: "batchSize",
|
|
|
message: "Batch size:",
|
|
|
- default: 1
|
|
|
+ default: 1,
|
|
|
},
|
|
|
{
|
|
|
type: "number",
|
|
|
name: "concurrency",
|
|
|
message: "Concurrency:",
|
|
|
- default: 1
|
|
|
+ default: 1,
|
|
|
},
|
|
|
{
|
|
|
type: "confirm",
|
|
|
name: "retryEnabled",
|
|
|
message: "Enable retries?",
|
|
|
- default: true
|
|
|
+ default: true,
|
|
|
},
|
|
|
{
|
|
|
type: "number",
|
|
|
name: "maxRetries",
|
|
|
message: "Max retries:",
|
|
|
- default: 3
|
|
|
+ default: 3,
|
|
|
},
|
|
|
{
|
|
|
type: "number",
|
|
|
name: "retryDelay",
|
|
|
message: "Retry delay (ms):",
|
|
|
- default: 5000
|
|
|
+ default: 5000,
|
|
|
},
|
|
|
{
|
|
|
type: "number",
|
|
|
name: "processingInterval",
|
|
|
message: "Processing interval (ms):",
|
|
|
- default: 5000
|
|
|
- }
|
|
|
+ default: 5000,
|
|
|
+ },
|
|
|
]);
|
|
|
|
|
|
const updateResult = await post("/tasks/queue/settings", answers);
|
|
|
@@ -643,7 +647,7 @@ async function handleTaskCommands() {
|
|
|
}
|
|
|
|
|
|
await inquirer.prompt([
|
|
|
- { type: "input", name: "continue", message: "Press Enter to continue..." }
|
|
|
+ { type: "input", name: "continue", message: "Press Enter to continue..." },
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
@@ -660,11 +664,11 @@ async function handleFileCommands() {
|
|
|
{ name: "🗑️ Remove file record", value: "remove" },
|
|
|
{
|
|
|
name: "📅 Get deleted files older than date",
|
|
|
- value: "deleted-older"
|
|
|
+ value: "deleted-older",
|
|
|
},
|
|
|
- { name: "⬅️ Back to main menu", value: "back" }
|
|
|
- ]
|
|
|
- }
|
|
|
+ { name: "⬅️ Back to main menu", value: "back" },
|
|
|
+ ],
|
|
|
+ },
|
|
|
]);
|
|
|
|
|
|
if (command === "back") return;
|
|
|
@@ -673,7 +677,7 @@ async function handleFileCommands() {
|
|
|
switch (command) {
|
|
|
case "list":
|
|
|
const { dataset } = await inquirer.prompt([
|
|
|
- { type: "input", name: "dataset", message: "Dataset name:" }
|
|
|
+ { type: "input", name: "dataset", message: "Dataset name:" },
|
|
|
]);
|
|
|
const files = await get(`/files?dataset=${dataset}`);
|
|
|
console.table(files);
|
|
|
@@ -681,7 +685,7 @@ async function handleFileCommands() {
|
|
|
case "get":
|
|
|
const getAnswers = await inquirer.prompt([
|
|
|
{ type: "input", name: "dataset", message: "Dataset name:" },
|
|
|
- { type: "input", name: "file", message: "File path:" }
|
|
|
+ { type: "input", name: "file", message: "File path:" },
|
|
|
]);
|
|
|
const file = await get(
|
|
|
`/files/${getAnswers.dataset}/${getAnswers.file}`
|
|
|
@@ -693,7 +697,7 @@ async function handleFileCommands() {
|
|
|
{ type: "input", name: "dataset", message: "Dataset name:" },
|
|
|
{ type: "input", name: "file", message: "File path:" },
|
|
|
{ type: "input", name: "output", message: "Output path (optional):" },
|
|
|
- { type: "input", name: "status", message: "Status (optional):" }
|
|
|
+ { type: "input", name: "status", message: "Status (optional):" },
|
|
|
]);
|
|
|
const payload: any = {};
|
|
|
if (setAnswers.output) payload.output = setAnswers.output;
|
|
|
@@ -712,13 +716,13 @@ async function handleFileCommands() {
|
|
|
type: "confirm",
|
|
|
name: "soft",
|
|
|
message: "Soft delete?",
|
|
|
- default: true
|
|
|
- }
|
|
|
+ default: true,
|
|
|
+ },
|
|
|
]);
|
|
|
const removeResult = await del(
|
|
|
`/files/${removeAnswers.dataset}/${removeAnswers.file}`,
|
|
|
{
|
|
|
- soft: removeAnswers.soft
|
|
|
+ soft: removeAnswers.soft,
|
|
|
}
|
|
|
);
|
|
|
console.log(removeResult);
|
|
|
@@ -729,8 +733,8 @@ async function handleFileCommands() {
|
|
|
{
|
|
|
type: "input",
|
|
|
name: "isoDate",
|
|
|
- message: "ISO date (e.g., 2024-01-01T00:00:00Z):"
|
|
|
- }
|
|
|
+ message: "ISO date (e.g., 2024-01-01T00:00:00Z):",
|
|
|
+ },
|
|
|
]);
|
|
|
const olderFiles = await get(
|
|
|
`/files/${olderAnswers.dataset}/deleted-older-than/${olderAnswers.isoDate}`
|
|
|
@@ -746,7 +750,7 @@ async function handleFileCommands() {
|
|
|
}
|
|
|
|
|
|
await inquirer.prompt([
|
|
|
- { type: "input", name: "continue", message: "Press Enter to continue..." }
|
|
|
+ { type: "input", name: "continue", message: "Press Enter to continue..." },
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
@@ -760,9 +764,9 @@ async function handleConfigCommands() {
|
|
|
{ name: "📋 List config files", value: "list" },
|
|
|
{ name: "⚙️ Get settings", value: "settings" },
|
|
|
{ name: "📄 Get config file", value: "file" },
|
|
|
- { name: "⬅️ Back to main menu", value: "back" }
|
|
|
- ]
|
|
|
- }
|
|
|
+ { name: "⬅️ Back to main menu", value: "back" },
|
|
|
+ ],
|
|
|
+ },
|
|
|
]);
|
|
|
|
|
|
if (command === "back") return;
|
|
|
@@ -778,8 +782,8 @@ async function handleConfigCommands() {
|
|
|
{
|
|
|
type: "input",
|
|
|
name: "key",
|
|
|
- message: "Setting key (leave empty for all):"
|
|
|
- }
|
|
|
+ message: "Setting key (leave empty for all):",
|
|
|
+ },
|
|
|
]);
|
|
|
const settings = await get(
|
|
|
"/config/settings",
|
|
|
@@ -789,7 +793,7 @@ async function handleConfigCommands() {
|
|
|
break;
|
|
|
case "file":
|
|
|
const { name } = await inquirer.prompt([
|
|
|
- { type: "input", name: "name", message: "Config file name:" }
|
|
|
+ { type: "input", name: "name", message: "Config file name:" },
|
|
|
]);
|
|
|
const file = await get(`/config/files/${name}`);
|
|
|
console.log(file);
|
|
|
@@ -803,7 +807,7 @@ async function handleConfigCommands() {
|
|
|
}
|
|
|
|
|
|
await inquirer.prompt([
|
|
|
- { type: "input", name: "continue", message: "Press Enter to continue..." }
|
|
|
+ { type: "input", name: "continue", message: "Press Enter to continue..." },
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
@@ -817,9 +821,9 @@ async function handleWatcherCommands() {
|
|
|
{ name: "▶️ Start watcher", value: "start" },
|
|
|
{ name: "⏹️ Stop watcher", value: "stop" },
|
|
|
{ name: "📊 Get status", value: "status" },
|
|
|
- { name: "⬅️ Back to main menu", value: "back" }
|
|
|
- ]
|
|
|
- }
|
|
|
+ { name: "⬅️ Back to main menu", value: "back" },
|
|
|
+ ],
|
|
|
+ },
|
|
|
]);
|
|
|
|
|
|
if (command === "back") return;
|
|
|
@@ -831,8 +835,8 @@ async function handleWatcherCommands() {
|
|
|
{
|
|
|
type: "input",
|
|
|
name: "watches",
|
|
|
- message: "Watch paths (comma-separated):"
|
|
|
- }
|
|
|
+ message: "Watch paths (comma-separated):",
|
|
|
+ },
|
|
|
]);
|
|
|
const watchList = watches.split(",").map((w: string) => w.trim());
|
|
|
const result = await post("/watcher/start", { watches: watchList });
|
|
|
@@ -855,7 +859,7 @@ async function handleWatcherCommands() {
|
|
|
}
|
|
|
|
|
|
await inquirer.prompt([
|
|
|
- { type: "input", name: "continue", message: "Press Enter to continue..." }
|
|
|
+ { type: "input", name: "continue", message: "Press Enter to continue..." },
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
@@ -869,9 +873,9 @@ async function handleMaintenanceCommands() {
|
|
|
{ name: "🧹 Cleanup missing files", value: "cleanup" },
|
|
|
{ name: "🗑️ Purge old records", value: "purge" },
|
|
|
{ name: "✂️ Prune processed files", value: "prune" },
|
|
|
- { name: "⬅️ Back to main menu", value: "back" }
|
|
|
- ]
|
|
|
- }
|
|
|
+ { name: "⬅️ Back to main menu", value: "back" },
|
|
|
+ ],
|
|
|
+ },
|
|
|
]);
|
|
|
|
|
|
if (command === "back") return;
|
|
|
@@ -883,11 +887,11 @@ async function handleMaintenanceCommands() {
|
|
|
{
|
|
|
type: "input",
|
|
|
name: "cleanupFile",
|
|
|
- message: "File path to cleanup:"
|
|
|
- }
|
|
|
+ message: "File path to cleanup:",
|
|
|
+ },
|
|
|
]);
|
|
|
const cleanupResult = await post("/maintenance/cleanup", {
|
|
|
- file: cleanupFile
|
|
|
+ file: cleanupFile,
|
|
|
});
|
|
|
console.log(cleanupResult);
|
|
|
break;
|
|
|
@@ -896,8 +900,8 @@ async function handleMaintenanceCommands() {
|
|
|
{
|
|
|
type: "input",
|
|
|
name: "threshold",
|
|
|
- message: "Threshold (e.g., 30d, 1w):"
|
|
|
- }
|
|
|
+ message: "Threshold (e.g., 30d, 1w):",
|
|
|
+ },
|
|
|
]);
|
|
|
const purgeResult = await post("/maintenance/purge", { threshold });
|
|
|
console.log(purgeResult);
|
|
|
@@ -915,7 +919,7 @@ async function handleMaintenanceCommands() {
|
|
|
}
|
|
|
|
|
|
await inquirer.prompt([
|
|
|
- { type: "input", name: "continue", message: "Press Enter to continue..." }
|
|
|
+ { type: "input", name: "continue", message: "Press Enter to continue..." },
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
@@ -928,9 +932,9 @@ async function handleHandbrakeCommands() {
|
|
|
choices: [
|
|
|
{ name: "📋 List presets", value: "presets" },
|
|
|
{ name: "🎬 Process file", value: "process" },
|
|
|
- { name: "⬅️ Back to main menu", value: "back" }
|
|
|
- ]
|
|
|
- }
|
|
|
+ { name: "⬅️ Back to main menu", value: "back" },
|
|
|
+ ],
|
|
|
+ },
|
|
|
]);
|
|
|
|
|
|
if (command === "back") return;
|
|
|
@@ -949,8 +953,8 @@ async function handleHandbrakeCommands() {
|
|
|
type: "input",
|
|
|
name: "preset",
|
|
|
message: "Preset name:",
|
|
|
- default: "Fast 1080p30"
|
|
|
- }
|
|
|
+ default: "Fast 1080p30",
|
|
|
+ },
|
|
|
]);
|
|
|
const processResult = await post("/handbrake/process", processAnswers);
|
|
|
console.log(processResult);
|
|
|
@@ -964,7 +968,7 @@ async function handleHandbrakeCommands() {
|
|
|
}
|
|
|
|
|
|
await inquirer.prompt([
|
|
|
- { type: "input", name: "continue", message: "Press Enter to continue..." }
|
|
|
+ { type: "input", name: "continue", message: "Press Enter to continue..." },
|
|
|
]);
|
|
|
}
|
|
|
|