import path from "node:path"; import type { ProbeData } from "./utils"; import commandExists from "command-exists"; export const coverRegex = process.env.COVER_REGEX || /(C|c)over.(png|jpg)$/; export const musicRoot = process.env.MUSIC_ROOT || ""; if (musicRoot === "") { console.error("Please define the environment variable MUSIC_ROOT"); process.exit(1); } if (!path.isAbsolute(musicRoot)) { console.error(`Music root ${musicRoot} is not absolute`); process.exit(1); } if (!commandExists.sync("ffmpeg")) { console.error("Required command ffmpeg not found in PATH"); process.exit(1); } if (!commandExists.sync("ffprobe")) { console.error("Required command ffprobe not found in PATH"); process.exit(1); } if (!commandExists.sync("tar")) { console.error("Required command tar not found in PATH"); process.exit(1); } export const mediaTypes = ["audio", "video"]; export const allowedTypes = [...mediaTypes, "image"]; export const fileTypeCache = new Map(); export const probeCache = new Map(); export const generatedPlaylistIds = new Map(); export class PathInfo { constructor(public mimeType: string) {} } export class ServerError { constructor( public status: number, public error: string, ) {} }