nyaa-jelly-tools/nyaa-tools-old/web/start.sh
2026-09-14 11:37:49 -04:00

37 lines
1.5 KiB
Bash
Executable file

#!/bin/bash
set -euo pipefail
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIG_DIR="$DIR/.config"
if ! python3 -c "import flask, toml, requests" 2>/dev/null; then
echo "Missing Python dependencies (flask/toml/requests)."
echo "Install them with:"
echo " sudo apt install python3-flask python3-toml python3-requests"
exit 1
fi
mkdir -p "$CONFIG_DIR"
[ -f "$CONFIG_DIR/release-groups.toml" ] || cat > "$CONFIG_DIR/release-groups.toml" <<'EOF'
# maps a release group tag (as seen in "[TAG] Show Name - 01.mkv") to a regex
# with named groups "title" and "episode" (and optionally "season") used to
# parse episode info out of the torrent title. Add one entry per group you
# want the search page to recognize.
SubsPlease = '^\[SubsPlease\] (?P<title>.+) - (?P<episode>\d+) \('
Erai-raws = '^\[Erai-raws\] (?P<title>.+) - (?P<episode>\d+) \['
EOF
[ -f "$CONFIG_DIR/batch-groups.toml" ] || cat > "$CONFIG_DIR/batch-groups.toml" <<'EOF'
# same idea as release-groups.toml, but for batch releases; regex should
# also expose "first" and "last" named groups for the episode range.
Judas = '^\[Judas\] (?P<title>.+) \((?P<first>\d+)-(?P<last>\d+)\)'
EOF
[ -f "$CONFIG_DIR/series.toml" ] || echo "tracking = []" > "$CONFIG_DIR/series.toml"
export NYAA_TOOLS_CONFIG_DIR="$CONFIG_DIR"
export DEV_ENV=true
export FLASK_APP="$DIR/server.py"
echo "Config dir: $CONFIG_DIR"
echo "Starting server in DEV_ENV mode (no login required) at http://127.0.0.1:5000"
cd "$DIR"
exec python3 server.py