setup for server
This commit is contained in:
parent
30afcf5d59
commit
5116f57287
13 changed files with 131 additions and 4 deletions
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
nyaa-tools-old/web/.venv/
|
||||
nyaa-tools-old/web/.config/
|
||||
nyaa-tools-old/config/
|
||||
nyaa-tools-old/.env
|
||||
__pycache__/
|
||||
*.pyc
|
||||
6
nyaa-tools-old/.dockerignore
Normal file
6
nyaa-tools-old/.dockerignore
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
web/.venv/
|
||||
web/.config/
|
||||
config-example/
|
||||
systemd/
|
||||
__pycache__/
|
||||
*.pyc
|
||||
19
nyaa-tools-old/Dockerfile
Normal file
19
nyaa-tools-old/Dockerfile
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
FROM python:3.13-slim
|
||||
|
||||
RUN pip install --no-cache-dir flask toml requests transmission-rpc gunicorn
|
||||
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
|
||||
RUN chmod +x /app/fetch.py /app/helper.py /app/batch.py \
|
||||
&& ln -s /app/batch.py /usr/local/bin/nyaa-batch \
|
||||
&& ln -s /app/fetch.py /usr/local/bin/nyaa-fetch \
|
||||
&& ln -s /app/helper.py /usr/local/bin/nyaa-helper \
|
||||
&& chmod +x /app/docker/entrypoint-fetch.sh
|
||||
|
||||
ENV NYAA_TOOLS_CONFIG_DIR=/etc/nyaa-tools
|
||||
|
||||
EXPOSE 5000
|
||||
|
||||
# default: run the web UI; the fetch service overrides this in compose
|
||||
CMD ["gunicorn", "--chdir", "web", "--bind", "0.0.0.0:5000", "server:app"]
|
||||
0
nyaa-tools-old/batch.py
Normal file → Executable file
0
nyaa-tools-old/batch.py
Normal file → Executable file
3
nyaa-tools-old/config-example/batch-groups.toml
Normal file
3
nyaa-tools-old/config-example/batch-groups.toml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# 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+)\)'
|
||||
10
nyaa-tools-old/config-example/config.toml
Normal file
10
nyaa-tools-old/config-example/config.toml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
[library]
|
||||
# root folder your Jellyfin library points at
|
||||
base_path = "/mnt/media/anime"
|
||||
|
||||
[transmission]
|
||||
# host running transmission-daemon with RPC enabled
|
||||
host = "127.0.0.1"
|
||||
# transmission's own download directory, used to hardlink finished files
|
||||
# into the library layout above
|
||||
download_path = "/var/lib/transmission-daemon/downloads"
|
||||
6
nyaa-tools-old/config-example/release-groups.toml
Normal file
6
nyaa-tools-old/config-example/release-groups.toml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# 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 and fetch job to recognize.
|
||||
SubsPlease = '^\[SubsPlease\] (?P<title>.+) - (?P<episode>\d+) \('
|
||||
Erai-raws = '^\[Erai-raws\] (?P<title>.+) - (?P<episode>\d+) \['
|
||||
1
nyaa-tools-old/config-example/series.toml
Normal file
1
nyaa-tools-old/config-example/series.toml
Normal file
|
|
@ -0,0 +1 @@
|
|||
tracking = []
|
||||
3
nyaa-tools-old/config-example/web.env
Normal file
3
nyaa-tools-old/config-example/web.env
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# copy to /etc/nyaa-tools/web.env, chmod 600, and set a real password.
|
||||
# referenced by nyaa-tools-old/systemd/nyaa-web.service
|
||||
PASSWORD=change-me
|
||||
26
nyaa-tools-old/docker-compose.yml
Normal file
26
nyaa-tools-old/docker-compose.yml
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
services:
|
||||
web:
|
||||
build: .
|
||||
image: nyaa-tools:latest
|
||||
ports:
|
||||
- "5000:5000"
|
||||
environment:
|
||||
- PASSWORD=${NYAA_WEB_PASSWORD}
|
||||
volumes:
|
||||
- ./config:/etc/nyaa-tools
|
||||
restart: unless-stopped
|
||||
|
||||
fetch:
|
||||
build: .
|
||||
image: nyaa-tools:latest
|
||||
entrypoint: ["/app/docker/entrypoint-fetch.sh"]
|
||||
environment:
|
||||
- FETCH_INTERVAL=600
|
||||
volumes:
|
||||
- ./config:/etc/nyaa-tools
|
||||
# transmission's download dir and the jellyfin library base_path (set
|
||||
# in config/config.toml) must resolve to the SAME bind mount below —
|
||||
# fetch.py hardlinks finished files, which only works within one
|
||||
# filesystem/mount. Point both at a shared host media root, e.g.:
|
||||
- /path/to/host/media:/mnt/media
|
||||
restart: unless-stopped
|
||||
9
nyaa-tools-old/docker/entrypoint-fetch.sh
Normal file
9
nyaa-tools-old/docker/entrypoint-fetch.sh
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
INTERVAL="${FETCH_INTERVAL:-600}"
|
||||
|
||||
while true; do
|
||||
python3 /app/fetch.py
|
||||
sleep "$INTERVAL"
|
||||
done
|
||||
|
|
@ -20,8 +20,9 @@ from flask import (
|
|||
|
||||
app = Flask(__name__)
|
||||
|
||||
release_groups = toml.load("/etc/nyaa-tools/release-groups.toml")
|
||||
batch_groups = toml.load("/etc/nyaa-tools/batch-groups.toml")
|
||||
CONFIG_DIR = os.environ.get("NYAA_TOOLS_CONFIG_DIR", "/etc/nyaa-tools")
|
||||
release_groups = toml.load(os.path.join(CONFIG_DIR, "release-groups.toml"))
|
||||
batch_groups = toml.load(os.path.join(CONFIG_DIR, "batch-groups.toml"))
|
||||
|
||||
DEV_ENV = bool(os.environ.get("DEV_ENV", default=False))
|
||||
if not DEV_ENV:
|
||||
|
|
@ -170,14 +171,14 @@ def series():
|
|||
except ValueError:
|
||||
return "Invalid season", 400
|
||||
|
||||
series = toml.load("/etc/nyaa-tools/series.toml")
|
||||
series = toml.load(os.path.join(CONFIG_DIR, "series.toml"))
|
||||
if "tracking" not in series.keys():
|
||||
series["tracking"] = []
|
||||
|
||||
# TODO: Do not allow duplicates
|
||||
entry = {"name": title, "release_group": release_group, "season": season}
|
||||
series["tracking"].append(entry)
|
||||
with open("/etc/nyaa-tools/series.toml", "w") as f:
|
||||
with open(os.path.join(CONFIG_DIR, "series.toml"), "w") as f:
|
||||
toml.dump(series, f)
|
||||
return "OK", 200
|
||||
else:
|
||||
|
|
|
|||
37
nyaa-tools-old/web/start.sh
Executable file
37
nyaa-tools-old/web/start.sh
Executable file
|
|
@ -0,0 +1,37 @@
|
|||
#!/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
|
||||
Loading…
Add table
Reference in a new issue