From 2542a684791388196a162a1e1121430df9321883 Mon Sep 17 00:00:00 2001 From: nose Date: Wed, 24 Dec 2025 23:31:05 -0800 Subject: [PATCH] jhj --- docs/tutorial.md | 8 +++++++ readme.md | 2 +- scripts/bootstrap.ps1 | 52 +++++++++++++++++++++++++++++++++++++++++++ scripts/bootstrap.sh | 52 +++++++++++++++++++++++++++++++++++++++++++ scripts/setup.py | 5 ++++- 5 files changed, 117 insertions(+), 2 deletions(-) diff --git a/docs/tutorial.md b/docs/tutorial.md index 51d9671..3824b36 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -72,5 +72,13 @@ to access your file and view it, you can run either or if you have mpv installed (the preferred way for video files) +(Tip: the bootstrap/setup scripts will try to install `mpv` for you if it's not found on PATH. If it isn't available, install `mpv` manually and ensure `mpv` is on your PATH.) + @1 | .pipe +# Bandcamp downloading (provider method) +
+
<🜂🜄|🜁🜃>
+
search-provider -provider bandcamp "artist:altrusian grace media"
+
+
diff --git a/readme.md b/readme.md index 550788a..538e5a6 100644 --- a/readme.md +++ b/readme.md @@ -11,7 +11,7 @@ Medios-Macina is a CLI media manager and toolkit focused on downloading, tagging ## Quick start ⚡ - `docs/BOOTSTRAP.md` and use `scripts/bootstrap.ps1` (Windows) or `scripts/bootstrap.sh` (Linux/macOS) to create a venv and install the project. Alternatively, simply run the opinionated helper: `python ./scripts/setup.py`. By default (no flags), `setup.py` will auto-detect your platform and run the matching bootstrap script in **non-interactive (quiet)** mode so you don't need to run the platform-specific script yourself. Note: the Deno installer can require interactive input on some systems; if the automated Deno install fails, the script will warn and you can install Deno manually by following `docs/BOOTSTRAP.md`. + `docs/BOOTSTRAP.md` and use `scripts/bootstrap.ps1` (Windows) or `scripts/bootstrap.sh` (Linux/macOS) to create a venv and install the project. Alternatively, simply run the opinionated helper: `python ./scripts/setup.py`. By default (no flags), `setup.py` will auto-detect your platform and run the matching bootstrap script in **non-interactive (quiet)** mode so you don't need to run the platform-specific script yourself. The bootstrap scripts also attempt (best-effort) to install `mpv` if it's missing from PATH. Note: the Deno installer can require interactive input on some systems; if the automated Deno install fails, the script will warn and you can install Deno manually by following `docs/BOOTSTRAP.md`. 1. Install Python requirements: diff --git a/scripts/bootstrap.ps1 b/scripts/bootstrap.ps1 index 538bafd..3eb5763 100644 --- a/scripts/bootstrap.ps1 +++ b/scripts/bootstrap.ps1 @@ -1,6 +1,58 @@ <# .SYNOPSIS Bootstrap a Python virtualenv and install the project on Windows (PowerShell). +function Ensure-Mpv { + # mpv is used by some pipelines; try to ensure it's available on PATH. + try { + $mpvCmd = Get-Command mpv -ErrorAction SilentlyContinue + if ($mpvCmd) { + try { + $v = & mpv --version 2>$null | Select-Object -First 1 + if ($v) { Write-Log "mpv found: $v" "INFO" } else { Write-Log "mpv found: $($mpvCmd.Path)" "INFO" } + } catch { + Write-Log "mpv found: $($mpvCmd.Path)" "INFO" + } + return + } + } catch {} + + Write-Log "mpv not found on PATH; attempting to install..." "INFO" + + try { + if (Get-Command choco -ErrorAction SilentlyContinue) { + & choco install mpv -y --no-progress | Out-Null + } elseif (Get-Command scoop -ErrorAction SilentlyContinue) { + & scoop install mpv | Out-Null + } elseif (Get-Command winget -ErrorAction SilentlyContinue) { + # Best-effort: winget may require a specific id depending on environment. + & winget install --silent --accept-package-agreements --accept-source-agreements mpv | Out-Null + } else { + Write-Log "mpv not found and no supported package manager found (choco/scoop/winget). Install mpv and ensure it's on PATH." "ERROR" + return + } + } catch { + Write-Log "mpv install attempt failed: $_" "ERROR" + return + } + + try { + $mpvCmd2 = Get-Command mpv -ErrorAction SilentlyContinue + if ($mpvCmd2) { + try { + $v2 = & mpv --version 2>$null | Select-Object -First 1 + if ($v2) { Write-Log "mpv installed: $v2" "INFO" } else { Write-Log "mpv installed: $($mpvCmd2.Path)" "INFO" } + } catch { + Write-Log "mpv installed: $($mpvCmd2.Path)" "INFO" + } + } else { + Write-Log "mpv install attempted but mpv is still not on PATH. Install mpv manually." "ERROR" + } + } catch {} +} + +if ($IsWindowsPlatform) { + Ensure-Mpv +} .DESCRIPTION Creates a Python virtual environment (default: .venv), upgrades pip, installs the project diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index b470a6a..4273b0e 100644 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -476,6 +476,58 @@ else fi fi +# Ensure mpv is available (used by some pipelines). Best-effort install if missing. +install_mpv_if_missing() { + if command -v mpv >/dev/null 2>&1; then + echo "mpv found: $(mpv --version 2>/dev/null | head -n 1 || echo 'mpv')" + return 0 + fi + + echo "mpv not found on PATH; attempting to install..." >&2 + + local prefix="" + if [[ $(id -u) -ne 0 ]]; then + if command -v sudo >/dev/null 2>&1; then + prefix="sudo" + else + echo "Warning: mpv is missing and sudo is not available; install mpv manually and ensure it's on PATH." >&2 + return 0 + fi + fi + + # Try a few common package managers. + if command -v apt-get >/dev/null 2>&1; then + $prefix apt-get update -y >/dev/null 2>&1 || $prefix apt-get update || true + $prefix env DEBIAN_FRONTEND=noninteractive apt-get install -y mpv || true + elif command -v apt >/dev/null 2>&1; then + $prefix apt update -y >/dev/null 2>&1 || $prefix apt update || true + $prefix env DEBIAN_FRONTEND=noninteractive apt install -y mpv || true + elif command -v dnf >/dev/null 2>&1; then + $prefix dnf install -y mpv || true + elif command -v yum >/dev/null 2>&1; then + $prefix yum install -y mpv || true + elif command -v pacman >/dev/null 2>&1; then + $prefix pacman -S --noconfirm mpv || true + elif command -v zypper >/dev/null 2>&1; then + $prefix zypper --non-interactive install mpv || true + elif command -v apk >/dev/null 2>&1; then + $prefix apk add --no-interactive mpv || $prefix apk add mpv || true + elif command -v brew >/dev/null 2>&1; then + brew install mpv || true + else + echo "Warning: mpv is missing and no supported package manager was found. Install mpv manually and ensure it's on PATH." >&2 + return 0 + fi + + if command -v mpv >/dev/null 2>&1; then + echo "mpv installed: $(mpv --version 2>/dev/null | head -n 1 || echo 'mpv')" + else + echo "Warning: attempted to install mpv but it is still not on PATH. Install mpv manually." >&2 + fi +} + +install_mpv_if_missing + if [[ "$DESKTOP" == "true" ]]; then echo "Creating desktop launcher..." EXEC_PATH="$VENV_PATH/bin/mm" diff --git a/scripts/setup.py b/scripts/setup.py index 1314991..207950d 100644 --- a/scripts/setup.py +++ b/scripts/setup.py @@ -13,6 +13,9 @@ run the platform-specific bootstrap helper (`scripts/bootstrap.ps1` on Windows or `scripts/bootstrap.sh` on POSIX) in **non-interactive (quiet)** mode so a single `python ./scripts/setup.py` call does the usual bootstrap on your OS. +The platform bootstrap scripts also attempt (best-effort) to install `mpv` if +it is not found on your PATH, since some workflows use it. + Usage: python ./scripts/setup.py # install deps and playwright browsers (or run platform bootstrap if no args) python ./scripts/setup.py --skip-deps @@ -409,7 +412,7 @@ python -m medeia_macina.cli_entry @args bat_text = ( "@echo off\r\n" "set SCRIPT_DIR=%~dp0\r\n" - "set PATH=%SCRIPT_DIR%\.venv\Scripts;%PATH%\r\n" + "set PATH=%SCRIPT_DIR%\\.venv\\Scripts;%PATH%\r\n" "if exist \"%SCRIPT_DIR%\\.venv\\Scripts\\python.exe\" \"%SCRIPT_DIR%\\.venv\\Scripts\\python.exe\" -m medeia_macina.cli_entry %*\r\n" "if exist \"%SCRIPT_DIR%\\CLI.py\" python \"%SCRIPT_DIR%\\CLI.py\" %*\r\n" "python -m medeia_macina.cli_entry %*\r\n"