diff --git a/web/backend/src/MediaPlayer.ts b/web/backend/src/MediaPlayer.ts index 3dd28d8..ec5cf1f 100644 --- a/web/backend/src/MediaPlayer.ts +++ b/web/backend/src/MediaPlayer.ts @@ -121,10 +121,9 @@ export class MediaPlayer { const socketFilename = Math.random().toString(36).substring(2, 10); const socketPath = `/tmp/mpv-${socketFilename}`; const enableVideo = process.env.ENABLE_VIDEO || false; + const ytdlFormat = process.env.MPV_YTDL_FORMAT; const logfilePath = `/tmp/mpv-logfile.txt`; - - console.log("Starting player process (video: " + (enableVideo ? "enabled" : "disabled") + ")"); - this.playerProcess = spawn("mpv", [ + const playerArgs = [ "--video=" + (enableVideo ? "auto" : "no"), "--fullscreen", "--no-terminal", @@ -132,7 +131,14 @@ export class MediaPlayer { "--input-ipc-server=" + socketPath, "--log-file=" + logfilePath, "--msg-level=all=v" - ]); + ]; + + if (ytdlFormat) { + playerArgs.push("--ytdl-format=" + ytdlFormat); + } + + console.log("Starting player process (video: " + (enableVideo ? "enabled" : "disabled") + ")"); + this.playerProcess = spawn("mpv", playerArgs); let socketReady!: (s: Socket) => void; diff --git a/web/flake.nix b/web/flake.nix index 7f81fac..a53dcba 100644 --- a/web/flake.nix +++ b/web/flake.nix @@ -8,10 +8,76 @@ outputs = { self, nixpkgs, flake-utils }: let + mkQueuecube = pkgs: pkgs.buildNpmPackage { + pname = "queuecube"; + version = "0.1.0"; + + src = ./.; + + # Skip the standard buildPhase and provide our own + dontNpmBuild = true; + buildPhase = '' + # First install all dependencies + npm install + + # Then run the build with workspaces flag + npm run build --workspaces + ''; + + # Runtime dependencies + buildInputs = with pkgs; [ + mpv + yt-dlp + pulseaudio + ]; + + # Create a wrapper script to ensure runtime deps are available + postInstall = '' + # Create the necessary directories + mkdir -p $out/lib/node_modules/queuecube + + # Copy the entire project with built files + cp -r . $out/lib/node_modules/queuecube + + # Install the frontend build to the backend dist directory + mkdir -p $out/lib/node_modules/queuecube/backend/dist/ + cp -r frontend/dist $out/lib/node_modules/queuecube/backend/dist/frontend + + # Create bin directory if it doesn't exist + mkdir -p $out/bin + + # Create executable script + cat > $out/bin/queuecube < $out/bin/queuecube <