Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bcf9e15d40 | ||
|
|
0c17499efa | ||
|
|
e84ef16f7d | ||
|
|
4e980220b1 | ||
|
|
d8ed64bd64 |
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
- always bump up the VERSION unless its changes to Dockerfile, *.md files
|
- always bump up the VERSION unless its changes to Dockerfile, *.md files
|
||||||
- always document changes in simple CHANGELOG.md unless modifiing Dockerfile, *.md, VERSION
|
- always document changes in simple CHANGELOG.md unless modifiing Dockerfile, *.md, VERSION
|
||||||
- when needed you may install any tools using pip if the project reqires it
|
- when needed you may install any tools using pip if the project reqires it
|
||||||
|
|||||||
+5
-6
@@ -1,14 +1,13 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## 0.46.2 - 2026-07-09
|
## 0.47.1 - 2026-07-09
|
||||||
|
|
||||||
- Changed the backup downloader setting on the Config page from a hard-to-spot select field into a dedicated checkbox toggle so the enable/disable control is clearly visible.
|
- Fixed `anipy-cli` fallback renaming for queued TV downloads so retried jobs now keep the requested episode numbers from the queue, avoiding cases like a retried `S02E11` being renamed as `S02E01`.
|
||||||
|
|
||||||
## 0.46.1 - 2026-07-09
|
## 0.47.0 - 2026-07-09
|
||||||
|
|
||||||
- Added a Config-page backup download toggle that lets queue jobs retry failed `ani-cli` downloads automatically with `anikoto-cli`.
|
- Added an optional `anipy-cli` fallback toggle on the Config page so failed `ani-cli` queue jobs can automatically retry once with `anipy-cli`.
|
||||||
- Installed `anikoto-cli` system-wide in the container image alongside `ani-cli`, and added the extra `jq` and `mpv` packages it currently needs even for download-only runs.
|
- Exposed `anipy-cli` availability and version in Config page runtime checks, and updated queue processing so fallback downloads still finalize into the same TV or movie library layout.
|
||||||
- Exposed `anikoto-cli` in Runtime info and dependency checks so it is easier to verify that the backup downloader is available.
|
|
||||||
|
|
||||||
## 0.46.0 - 2026-06-14
|
## 0.46.0 - 2026-06-14
|
||||||
|
|
||||||
|
|||||||
+6
-12
@@ -2,19 +2,16 @@ FROM python:3.12-slim
|
|||||||
|
|
||||||
ARG ANI_CLI=https://github.com/pystardust/ani-cli.git
|
ARG ANI_CLI=https://github.com/pystardust/ani-cli.git
|
||||||
ARG ANI_CLI_BRANCH=master
|
ARG ANI_CLI_BRANCH=master
|
||||||
ARG ANIKOTO_CLI=https://github.com/Slimyslushy/anikoto-cli.git
|
|
||||||
ARG ANIKOTO_CLI_BRANCH=main
|
|
||||||
ARG ANI_CLI_WEB=https://gitea.coreplay.eu/Dymas/ani-cli-web.git
|
ARG ANI_CLI_WEB=https://gitea.coreplay.eu/Dymas/ani-cli-web.git
|
||||||
|
ARG ANI_CLI_WEB_BRANCH=main
|
||||||
ARG YT_DLP_RELEASE_URL=https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp
|
ARG YT_DLP_RELEASE_URL=https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp
|
||||||
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive \
|
ENV DEBIAN_FRONTEND=noninteractive \
|
||||||
ANI_CLI_REPO=${ANI_CLI} \
|
ANI_CLI_REPO=${ANI_CLI} \
|
||||||
ANI_CLI_BRANCH=${ANI_CLI_BRANCH} \
|
ANI_CLI_BRANCH=${ANI_CLI_BRANCH} \
|
||||||
ANIKOTO_CLI_REPO=${ANIKOTO_CLI} \
|
|
||||||
ANIKOTO_CLI_BRANCH=${ANIKOTO_CLI_BRANCH} \
|
|
||||||
ANI_CLI_WEB_REPO=${ANI_CLI_WEB} \
|
ANI_CLI_WEB_REPO=${ANI_CLI_WEB} \
|
||||||
|
ANI_CLI_WEB_BRANCH=${ANI_CLI_WEB_BRANCH} \
|
||||||
ANI_CLI_BIN=ani-cli \
|
ANI_CLI_BIN=ani-cli \
|
||||||
ANIKOTO_CLI_BIN=anikoto-cli \
|
|
||||||
ANI_CLI_DOWNLOAD_DIR=/downloads \
|
ANI_CLI_DOWNLOAD_DIR=/downloads \
|
||||||
ANI_CLI_WEB_HOST=0.0.0.0 \
|
ANI_CLI_WEB_HOST=0.0.0.0 \
|
||||||
ANI_CLI_WEB_PORT=8421 \
|
ANI_CLI_WEB_PORT=8421 \
|
||||||
@@ -31,8 +28,6 @@ RUN apt-get update \
|
|||||||
fzf \
|
fzf \
|
||||||
git \
|
git \
|
||||||
grep \
|
grep \
|
||||||
jq \
|
|
||||||
mpv \
|
|
||||||
openssl \
|
openssl \
|
||||||
patch \
|
patch \
|
||||||
sed \
|
sed \
|
||||||
@@ -49,15 +44,14 @@ RUN git clone --depth 1 --branch "${ANI_CLI_BRANCH}" "${ANI_CLI}" /tmp/ani-cli-s
|
|||||||
esac \
|
esac \
|
||||||
&& rm -rf /tmp/ani-cli-src
|
&& rm -rf /tmp/ani-cli-src
|
||||||
|
|
||||||
RUN git clone --depth 1 --branch "${ANIKOTO_CLI_BRANCH}" "${ANIKOTO_CLI}" /tmp/anikoto-cli-src \
|
|
||||||
&& install -m 0755 /tmp/anikoto-cli-src/anikoto-cli /usr/local/bin/anikoto-cli \
|
|
||||||
&& rm -rf /tmp/anikoto-cli-src
|
|
||||||
|
|
||||||
RUN curl -fL "${YT_DLP_RELEASE_URL}" -o /usr/local/bin/yt-dlp \
|
RUN curl -fL "${YT_DLP_RELEASE_URL}" -o /usr/local/bin/yt-dlp \
|
||||||
&& chmod 0755 /usr/local/bin/yt-dlp \
|
&& chmod 0755 /usr/local/bin/yt-dlp \
|
||||||
&& yt-dlp --version
|
&& yt-dlp --version
|
||||||
|
|
||||||
RUN git clone --depth 1 "${ANI_CLI_WEB}" /app \
|
RUN python3 -m pip install --no-cache-dir anipy-cli \
|
||||||
|
&& anipy-cli --version
|
||||||
|
|
||||||
|
RUN git clone --depth 1 --branch "${ANI_CLI_WEB_BRANCH}" "${ANI_CLI_WEB}" /app \
|
||||||
&& rm -rf /app/.git \
|
&& rm -rf /app/.git \
|
||||||
&& rm -f \
|
&& rm -f \
|
||||||
/app/.dockerignore \
|
/app/.dockerignore \
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
Local web UI for a system-wide `ani-cli` install.
|
Local web UI for a system-wide `ani-cli` install.
|
||||||
|
|
||||||
Current version: `0.46.2`
|
Current version: `0.47.1`
|
||||||
|
|
||||||
## What it does
|
## What it does
|
||||||
|
|
||||||
- Search anime in `sub` or `dub`, with poster-style results shown below the selection panel and the first English alternate title when available
|
- Search anime in `sub` or `dub`, with poster-style results shown below the selection panel and the first English alternate title when available
|
||||||
- Queue downloads with folder, quality, media type, season, and episode controls
|
- Queue downloads with folder, quality, media type, season, and episode controls
|
||||||
- Optionally retry failed `ani-cli` downloads with system-wide `anikoto-cli` as a backup downloader
|
- Optionally retry failed `ani-cli` downloads with `anipy-cli`
|
||||||
- Track shows in a watchlist with `Watching`, `Planned`, `Finished`, and `Dropped` categories
|
- Track shows in a watchlist with `Watching`, `Planned`, `Finished`, and `Dropped` categories
|
||||||
- Expose a small JSON summary endpoint for Homepage dashboard widgets
|
- Expose a small JSON summary endpoint for Homepage dashboard widgets
|
||||||
- Refresh watchlist episode counts manually or on a schedule
|
- Refresh watchlist episode counts manually or on a schedule
|
||||||
@@ -21,15 +21,15 @@ Current version: `0.46.2`
|
|||||||
- `/`: Search and queue downloads, with poster-card search results below the selection box and alternate English titles under the main name when available
|
- `/`: Search and queue downloads, with poster-card search results below the selection box and alternate English titles under the main name when available
|
||||||
- `/queue`: Monitor jobs, inspect logs, retry failed jobs, remove finished jobs
|
- `/queue`: Monitor jobs, inspect logs, retry failed jobs, remove finished jobs
|
||||||
- `/watchlist`: Track shows, refresh them, download all available episodes, and manage auto-download settings such as `Source name`, library `Name`, season, and episode offset
|
- `/watchlist`: Track shows, refresh them, download all available episodes, and manage auto-download settings such as `Source name`, library `Name`, season, and episode offset
|
||||||
- `/config`: Save defaults, schedule refreshes, configure Jellyfin and Discord, monitor Jellyfin handoff progress, and view runtime info and the changelog
|
- `/config`: Save defaults, toggle `anipy-cli` fallback retries, schedule refreshes, configure Jellyfin and Discord, monitor Jellyfin handoff progress, and view runtime info and the changelog
|
||||||
|
|
||||||
## Quick start
|
## Quick start
|
||||||
|
|
||||||
Requirements:
|
Requirements:
|
||||||
|
|
||||||
- `ani-cli` installed and available in `PATH`
|
- `ani-cli` installed and available in `PATH`
|
||||||
- Optional: `anikoto-cli` installed in `PATH` if you want backup downloads
|
- Optional: `anipy-cli` installed and available in `PATH` if you want automatic fallback retries outside Docker
|
||||||
- Common runtime tools used by `ani-cli` and `anikoto-cli`, especially `curl`, `ffmpeg`, `fzf`, `grep`, `jq`, `mpv`, `openssl`, `sed`, `aria2c`, and `yt-dlp`
|
- Common runtime tools used by `ani-cli`, especially `curl`, `ffmpeg`, `fzf`, `grep`, `openssl`, `sed`, `aria2c`, and `yt-dlp`
|
||||||
|
|
||||||
Run locally:
|
Run locally:
|
||||||
|
|
||||||
@@ -49,6 +49,7 @@ Useful flags and env:
|
|||||||
- `ANI_CLI_WEB_HOST=0.0.0.0`
|
- `ANI_CLI_WEB_HOST=0.0.0.0`
|
||||||
- `ANI_CLI_WEB_PORT=8421`
|
- `ANI_CLI_WEB_PORT=8421`
|
||||||
- `ANI_CLI_BIN=/path/to/ani-cli`
|
- `ANI_CLI_BIN=/path/to/ani-cli`
|
||||||
|
- `ANIPY_CLI_BIN=/path/to/anipy-cli`
|
||||||
|
|
||||||
## Docker
|
## Docker
|
||||||
|
|
||||||
@@ -58,6 +59,14 @@ Build:
|
|||||||
docker build -t ani-cli-web .
|
docker build -t ani-cli-web .
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Build a specific `ani-cli-web` branch:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker build \
|
||||||
|
--build-arg ANI_CLI_WEB_BRANCH=anipy_backup \
|
||||||
|
-t ani-cli-web .
|
||||||
|
```
|
||||||
|
|
||||||
Run:
|
Run:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@@ -83,7 +92,8 @@ Docker notes:
|
|||||||
- App state is stored under `/app/.ani-cli-web`
|
- App state is stored under `/app/.ani-cli-web`
|
||||||
- `USER_UID` and `USER_GID` help keep mounted files owned by your host user
|
- `USER_UID` and `USER_GID` help keep mounted files owned by your host user
|
||||||
- `UPDATE_ON_START=true` runs `ani-cli --update` before startup
|
- `UPDATE_ON_START=true` runs `ani-cli --update` before startup
|
||||||
- The image installs both `ani-cli` and `anikoto-cli` system-wide under `/usr/local/bin`
|
- `ANI_CLI_WEB_BRANCH` lets the image clone a specific `ani-cli-web` branch at build time
|
||||||
|
- `anipy-cli` is installed systemwide inside the container, so fallback retries are available without extra container setup
|
||||||
|
|
||||||
## Key behavior
|
## Key behavior
|
||||||
|
|
||||||
@@ -102,11 +112,12 @@ Docker notes:
|
|||||||
- Uses the per-show language, quality, `Source name` search override, season, library name, and optional episode offset settings
|
- Uses the per-show language, quality, `Source name` search override, season, library name, and optional episode offset settings
|
||||||
- Can queue backlog episodes that were already available before the show was first tracked
|
- Can queue backlog episodes that were already available before the show was first tracked
|
||||||
|
|
||||||
### Backup downloads
|
### Download fallback
|
||||||
|
|
||||||
- Configure the global backup toggle from `/config`
|
- Optional and configured from `/config`
|
||||||
- When enabled, any failed `ani-cli` queue job automatically retries with `anikoto-cli`
|
- When enabled, a failed `ani-cli` queue job retries once with `anipy-cli`
|
||||||
- `anikoto-cli` ignores the saved quality setting, so backup attempts use the source's default stream quality
|
- Fallback retries keep the queued episode numbers when the downloaded `anipy-cli` filenames are renumbered from `1`
|
||||||
|
- Docker images install `anipy-cli` automatically; non-Docker installs should provide it in `PATH` themselves
|
||||||
|
|
||||||
### Jellyfin handoff
|
### Jellyfin handoff
|
||||||
|
|
||||||
@@ -144,6 +155,7 @@ The Config page runtime panel shows:
|
|||||||
|
|
||||||
- `ani-cli-web` version loaded from `VERSION`
|
- `ani-cli-web` version loaded from `VERSION`
|
||||||
- Installed `ani-cli` version
|
- Installed `ani-cli` version
|
||||||
|
- Installed `anipy-cli` version and dependency status
|
||||||
- A `Changelog` button that opens a scrollable viewer backed by `CHANGELOG.md`
|
- A `Changelog` button that opens a scrollable viewer backed by `CHANGELOG.md`
|
||||||
|
|
||||||
## Remote access
|
## Remote access
|
||||||
@@ -191,7 +203,7 @@ ANI_CLI_DOWNLOAD_DIR/movie/Movie Name/Movie Name.mp4
|
|||||||
Most users only need these environment variables:
|
Most users only need these environment variables:
|
||||||
|
|
||||||
- `ANI_CLI_BIN`
|
- `ANI_CLI_BIN`
|
||||||
- `ANIKOTO_CLI_BIN`
|
- `ANIPY_CLI_BIN`
|
||||||
- `ANI_CLI_WEB_HOST`
|
- `ANI_CLI_WEB_HOST`
|
||||||
- `ANI_CLI_WEB_PORT`
|
- `ANI_CLI_WEB_PORT`
|
||||||
- `ANI_CLI_WEB_ALLOW_REMOTE`
|
- `ANI_CLI_WEB_ALLOW_REMOTE`
|
||||||
|
|||||||
+64
-29
@@ -23,7 +23,7 @@ from uuid import uuid4
|
|||||||
|
|
||||||
PROJECT_ROOT = Path(__file__).resolve().parent
|
PROJECT_ROOT = Path(__file__).resolve().parent
|
||||||
ANI_CLI = os.environ.get("ANI_CLI_BIN") or shutil.which("ani-cli") or "ani-cli"
|
ANI_CLI = os.environ.get("ANI_CLI_BIN") or shutil.which("ani-cli") or "ani-cli"
|
||||||
ANIKOTO_CLI = os.environ.get("ANIKOTO_CLI_BIN") or shutil.which("anikoto-cli") or "anikoto-cli"
|
ANIPY_CLI = os.environ.get("ANIPY_CLI_BIN") or shutil.which("anipy-cli") or "anipy-cli"
|
||||||
APP_NAME = "ani-cli-web"
|
APP_NAME = "ani-cli-web"
|
||||||
VERSION_FILE = PROJECT_ROOT / "VERSION"
|
VERSION_FILE = PROJECT_ROOT / "VERSION"
|
||||||
CHANGELOG_FILE = PROJECT_ROOT / "CHANGELOG.md"
|
CHANGELOG_FILE = PROJECT_ROOT / "CHANGELOG.md"
|
||||||
@@ -291,7 +291,7 @@ DEFAULT_CONFIG = {
|
|||||||
"download_dir": default_download_dir(),
|
"download_dir": default_download_dir(),
|
||||||
"mode": os.environ.get("ANI_CLI_MODE", "sub"),
|
"mode": os.environ.get("ANI_CLI_MODE", "sub"),
|
||||||
"quality": os.environ.get("ANI_CLI_QUALITY", "best"),
|
"quality": os.environ.get("ANI_CLI_QUALITY", "best"),
|
||||||
"download_backup_enabled": False,
|
"anipy_cli_fallback_enabled": False,
|
||||||
"watchlist_auto_refresh_enabled": False,
|
"watchlist_auto_refresh_enabled": False,
|
||||||
"watchlist_auto_refresh_minutes": WATCHLIST_AUTO_REFRESH_DEFAULT_MINUTES,
|
"watchlist_auto_refresh_minutes": WATCHLIST_AUTO_REFRESH_DEFAULT_MINUTES,
|
||||||
"watchlist_refresh_delay_seconds": WATCHLIST_REFRESH_DELAY_DEFAULT_SECONDS,
|
"watchlist_refresh_delay_seconds": WATCHLIST_REFRESH_DELAY_DEFAULT_SECONDS,
|
||||||
@@ -447,10 +447,10 @@ def normalize_config(data):
|
|||||||
if quality.endswith("p") and quality[:-1].isdigit():
|
if quality.endswith("p") and quality[:-1].isdigit():
|
||||||
quality = quality[:-1]
|
quality = quality[:-1]
|
||||||
download_dir = str(config.get("download_dir") or DEFAULT_CONFIG["download_dir"])
|
download_dir = str(config.get("download_dir") or DEFAULT_CONFIG["download_dir"])
|
||||||
|
anipy_cli_fallback_enabled = config.get("anipy_cli_fallback_enabled")
|
||||||
auto_refresh_enabled = config.get("watchlist_auto_refresh_enabled")
|
auto_refresh_enabled = config.get("watchlist_auto_refresh_enabled")
|
||||||
auto_refresh_minutes = config.get("watchlist_auto_refresh_minutes")
|
auto_refresh_minutes = config.get("watchlist_auto_refresh_minutes")
|
||||||
refresh_delay_seconds = config.get("watchlist_refresh_delay_seconds")
|
refresh_delay_seconds = config.get("watchlist_refresh_delay_seconds")
|
||||||
download_backup_enabled = config.get("download_backup_enabled")
|
|
||||||
auto_download_enabled = config.get("auto_download_enabled")
|
auto_download_enabled = config.get("auto_download_enabled")
|
||||||
auto_download_mode = str(config.get("auto_download_mode", "dub")).lower()
|
auto_download_mode = str(config.get("auto_download_mode", "dub")).lower()
|
||||||
auto_download_quality = str(config.get("auto_download_quality", "best")).lower()
|
auto_download_quality = str(config.get("auto_download_quality", "best")).lower()
|
||||||
@@ -464,6 +464,10 @@ def normalize_config(data):
|
|||||||
auth_username = str(config.get("auth_username") or "").strip()
|
auth_username = str(config.get("auth_username") or "").strip()
|
||||||
auth_password = str(config.get("auth_password") or "").strip()
|
auth_password = str(config.get("auth_password") or "").strip()
|
||||||
|
|
||||||
|
if isinstance(anipy_cli_fallback_enabled, str):
|
||||||
|
anipy_cli_fallback_enabled = anipy_cli_fallback_enabled.strip().lower() in {"1", "true", "yes", "on"}
|
||||||
|
else:
|
||||||
|
anipy_cli_fallback_enabled = bool(anipy_cli_fallback_enabled)
|
||||||
if isinstance(auto_refresh_enabled, str):
|
if isinstance(auto_refresh_enabled, str):
|
||||||
auto_refresh_enabled = auto_refresh_enabled.strip().lower() in {"1", "true", "yes", "on"}
|
auto_refresh_enabled = auto_refresh_enabled.strip().lower() in {"1", "true", "yes", "on"}
|
||||||
else:
|
else:
|
||||||
@@ -472,10 +476,6 @@ def normalize_config(data):
|
|||||||
auto_download_enabled = auto_download_enabled.strip().lower() in {"1", "true", "yes", "on"}
|
auto_download_enabled = auto_download_enabled.strip().lower() in {"1", "true", "yes", "on"}
|
||||||
else:
|
else:
|
||||||
auto_download_enabled = bool(auto_download_enabled)
|
auto_download_enabled = bool(auto_download_enabled)
|
||||||
if isinstance(download_backup_enabled, str):
|
|
||||||
download_backup_enabled = download_backup_enabled.strip().lower() in {"1", "true", "yes", "on"}
|
|
||||||
else:
|
|
||||||
download_backup_enabled = bool(download_backup_enabled)
|
|
||||||
if isinstance(jellyfin_sync_enabled, str):
|
if isinstance(jellyfin_sync_enabled, str):
|
||||||
jellyfin_sync_enabled = jellyfin_sync_enabled.strip().lower() in {"1", "true", "yes", "on"}
|
jellyfin_sync_enabled = jellyfin_sync_enabled.strip().lower() in {"1", "true", "yes", "on"}
|
||||||
else:
|
else:
|
||||||
@@ -501,7 +501,7 @@ def normalize_config(data):
|
|||||||
config["mode"] = mode if mode in MODE_CHOICES else "sub"
|
config["mode"] = mode if mode in MODE_CHOICES else "sub"
|
||||||
config["quality"] = quality if quality in QUALITY_CHOICES else "best"
|
config["quality"] = quality if quality in QUALITY_CHOICES else "best"
|
||||||
config["download_dir"] = str(Path(download_dir).expanduser())
|
config["download_dir"] = str(Path(download_dir).expanduser())
|
||||||
config["download_backup_enabled"] = download_backup_enabled
|
config["anipy_cli_fallback_enabled"] = anipy_cli_fallback_enabled
|
||||||
config["watchlist_auto_refresh_enabled"] = auto_refresh_enabled
|
config["watchlist_auto_refresh_enabled"] = auto_refresh_enabled
|
||||||
config["watchlist_auto_refresh_minutes"] = auto_refresh_minutes
|
config["watchlist_auto_refresh_minutes"] = auto_refresh_minutes
|
||||||
config["watchlist_refresh_delay_seconds"] = refresh_delay_seconds
|
config["watchlist_refresh_delay_seconds"] = refresh_delay_seconds
|
||||||
@@ -969,6 +969,13 @@ def strip_control(value):
|
|||||||
return re.sub(r"\x1b\[[0-9;?]*[A-Za-z]", "", str(value)).replace("\r", "\n")
|
return re.sub(r"\x1b\[[0-9;?]*[A-Za-z]", "", str(value)).replace("\r", "\n")
|
||||||
|
|
||||||
|
|
||||||
|
def cli_executable_exists(command):
|
||||||
|
text = str(command or "").strip()
|
||||||
|
if not text:
|
||||||
|
return False
|
||||||
|
return bool(shutil.which(text) or (Path(text).exists() and os.access(text, os.X_OK)))
|
||||||
|
|
||||||
|
|
||||||
def printable_command(command):
|
def printable_command(command):
|
||||||
return " ".join(sh_quote(part) for part in command)
|
return " ".join(sh_quote(part) for part in command)
|
||||||
|
|
||||||
@@ -1069,6 +1076,26 @@ def extract_episode_from_filename(path):
|
|||||||
return match.group(1) if match else None
|
return match.group(1) if match else None
|
||||||
|
|
||||||
|
|
||||||
|
def episode_values_from_spec(value):
|
||||||
|
spec = str(value or "").strip()
|
||||||
|
if not spec:
|
||||||
|
return []
|
||||||
|
values = []
|
||||||
|
for part in re.split(r"\s+", spec):
|
||||||
|
if not part:
|
||||||
|
continue
|
||||||
|
if "-" in part:
|
||||||
|
start_text, end_text = [piece.strip() for piece in part.split("-", 1)]
|
||||||
|
if start_text.isdigit() and end_text.isdigit():
|
||||||
|
start = int(start_text, 10)
|
||||||
|
end = int(end_text, 10)
|
||||||
|
if start <= end:
|
||||||
|
values.extend(str(number) for number in range(start, end + 1))
|
||||||
|
continue
|
||||||
|
values.append(part)
|
||||||
|
return values
|
||||||
|
|
||||||
|
|
||||||
def unique_destination(path):
|
def unique_destination(path):
|
||||||
if not path.exists():
|
if not path.exists():
|
||||||
return path
|
return path
|
||||||
@@ -1089,19 +1116,25 @@ def finalize_library_files(job):
|
|||||||
episode_offset = normalize_episode_offset(job.get("episode_offset"))
|
episode_offset = normalize_episode_offset(job.get("episode_offset"))
|
||||||
target_dir.mkdir(parents=True, exist_ok=True)
|
target_dir.mkdir(parents=True, exist_ok=True)
|
||||||
files = sorted(
|
files = sorted(
|
||||||
[path for path in staging_dir.iterdir() if path.is_file()],
|
[path for path in staging_dir.rglob("*") if path.is_file()],
|
||||||
key=lambda path: (path.stat().st_mtime, path.name),
|
key=lambda path: (path.stat().st_mtime, str(path.relative_to(staging_dir)).lower()),
|
||||||
)
|
)
|
||||||
if not files:
|
if not files:
|
||||||
raise RuntimeError("No downloaded files were found in the staging folder")
|
raise RuntimeError("No downloaded files were found in the staging folder")
|
||||||
|
|
||||||
moved = []
|
moved = []
|
||||||
fallback_episode = 1
|
fallback_episode = 1
|
||||||
|
requested_episode_values = episode_values_from_spec(job.get("episodes"))
|
||||||
|
backend = str(job.get("download_backend") or "").strip().lower()
|
||||||
for source in files:
|
for source in files:
|
||||||
if media_type == "movie":
|
if media_type == "movie":
|
||||||
final_name = f"{library_name}{source.suffix}"
|
final_name = f"{library_name}{source.suffix}"
|
||||||
else:
|
else:
|
||||||
ep = extract_episode_from_filename(source)
|
ep = None
|
||||||
|
if backend == "anipy-cli" and requested_episode_values:
|
||||||
|
ep = requested_episode_values.pop(0)
|
||||||
|
if ep is None:
|
||||||
|
ep = extract_episode_from_filename(source)
|
||||||
if ep is None:
|
if ep is None:
|
||||||
ep = str(fallback_episode)
|
ep = str(fallback_episode)
|
||||||
fallback_episode += 1
|
fallback_episode += 1
|
||||||
@@ -1111,10 +1144,7 @@ def finalize_library_files(job):
|
|||||||
shutil.move(str(source), str(destination))
|
shutil.move(str(source), str(destination))
|
||||||
moved.append(str(destination))
|
moved.append(str(destination))
|
||||||
|
|
||||||
try:
|
shutil.rmtree(staging_dir, ignore_errors=True)
|
||||||
staging_dir.rmdir()
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
return moved
|
return moved
|
||||||
|
|
||||||
|
|
||||||
@@ -1161,21 +1191,26 @@ def build_job(payload, config):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def command_for_job(job, downloader="ani-cli"):
|
def anipy_search_spec(job):
|
||||||
if str(downloader or "ani-cli").strip().lower() == "anikoto-cli":
|
query = re.sub(r"\s+", " ", str(job.get("query") or "").replace(":", " ")).strip()
|
||||||
command = [
|
mode = "dub" if str(job.get("mode") or "").strip().lower() == "dub" else "sub"
|
||||||
ANIKOTO_CLI,
|
return f"{query}:{job['episodes']}:{mode}"
|
||||||
"-d",
|
|
||||||
"-e",
|
|
||||||
job["episodes"],
|
|
||||||
]
|
|
||||||
if job["mode"] == "dub":
|
|
||||||
command.append("--dub")
|
|
||||||
else:
|
|
||||||
command.append("--sub")
|
|
||||||
command.append(job["query"])
|
|
||||||
return command
|
|
||||||
|
|
||||||
|
|
||||||
|
def command_for_job(job, backend="ani-cli", download_path=None):
|
||||||
|
normalized_backend = str(backend or "ani-cli").strip().lower()
|
||||||
|
if normalized_backend == "anipy-cli":
|
||||||
|
command = [
|
||||||
|
ANIPY_CLI,
|
||||||
|
"-D",
|
||||||
|
"-s",
|
||||||
|
anipy_search_spec(job),
|
||||||
|
"-q",
|
||||||
|
job["quality"],
|
||||||
|
]
|
||||||
|
if download_path:
|
||||||
|
command.extend(["-l", str(download_path)])
|
||||||
|
return command
|
||||||
command = [
|
command = [
|
||||||
ANI_CLI,
|
ANI_CLI,
|
||||||
"-d",
|
"-d",
|
||||||
|
|||||||
+22
-11
@@ -461,7 +461,7 @@ CONFIG_HTML = r"""<!doctype html>
|
|||||||
<div class="stack muted">
|
<div class="stack muted">
|
||||||
<p id="versionLine">Loading version...</p>
|
<p id="versionLine">Loading version...</p>
|
||||||
<p id="aniCliVersionLine">Detecting ani-cli version...</p>
|
<p id="aniCliVersionLine">Detecting ani-cli version...</p>
|
||||||
<p id="anikotoCliVersionLine">Detecting anikoto-cli version...</p>
|
<p id="anipyCliVersionLine">Detecting anipy-cli fallback...</p>
|
||||||
<p>Saved settings live in `.ani-cli-web/config.json` inside this project.</p>
|
<p>Saved settings live in `.ani-cli-web/config.json` inside this project.</p>
|
||||||
</div>
|
</div>
|
||||||
<button class="ghost wide-button" id="openChangelogBtn" type="button">Changelog</button>
|
<button class="ghost wide-button" id="openChangelogBtn" type="button">Changelog</button>
|
||||||
@@ -504,14 +504,25 @@ CONFIG_HTML = r"""<!doctype html>
|
|||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="stack">
|
<div class="field-hint">Tip: these are the saved defaults only. The active search form can still be adjusted per download.</div>
|
||||||
<label>Backup downloader</label>
|
</section>
|
||||||
<label class="check-item" for="downloadBackupEnabled">
|
|
||||||
<input id="downloadBackupEnabled" type="checkbox">
|
<section class="settings settings-main">
|
||||||
<span>Retry failed `ani-cli` downloads with `anikoto-cli`</span>
|
<div class="toolbar">
|
||||||
|
<div>
|
||||||
|
<h2>Download fallback</h2>
|
||||||
|
<p class="muted">If a queued `ani-cli` download fails, optionally retry it once with `anipy-cli`.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-grid">
|
||||||
|
<label>Automatic retry with anipy-cli
|
||||||
|
<select id="anipyCliFallbackEnabled">
|
||||||
|
<option value="false">Disabled</option>
|
||||||
|
<option value="true">Enabled</option>
|
||||||
|
</select>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="field-hint">Tip: these are the saved defaults only. The active search form can still be adjusted per download. When backup downloads are enabled, failed `ani-cli` jobs retry automatically with `anikoto-cli`.</div>
|
<div class="field-hint">This only kicks in after an `ani-cli` failure. Install `anipy-cli` separately and keep it in `PATH` if you enable this option.</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="settings settings-main">
|
<section class="settings settings-main">
|
||||||
@@ -674,7 +685,7 @@ CONFIG_HTML = r"""<!doctype html>
|
|||||||
mode: "sub",
|
mode: "sub",
|
||||||
quality: "best",
|
quality: "best",
|
||||||
download_dir: "",
|
download_dir: "",
|
||||||
download_backup_enabled: false,
|
anipy_cli_fallback_enabled: false,
|
||||||
watchlist_auto_refresh_enabled: false,
|
watchlist_auto_refresh_enabled: false,
|
||||||
watchlist_auto_refresh_minutes: 60,
|
watchlist_auto_refresh_minutes: 60,
|
||||||
watchlist_refresh_delay_seconds: 5,
|
watchlist_refresh_delay_seconds: 5,
|
||||||
@@ -741,7 +752,7 @@ CONFIG_HTML = r"""<!doctype html>
|
|||||||
download_dir: $("downloadDir").value,
|
download_dir: $("downloadDir").value,
|
||||||
mode: $("configMode").value,
|
mode: $("configMode").value,
|
||||||
quality: $("configQuality").value,
|
quality: $("configQuality").value,
|
||||||
download_backup_enabled: $("downloadBackupEnabled").checked,
|
anipy_cli_fallback_enabled: $("anipyCliFallbackEnabled").value === "true",
|
||||||
watchlist_auto_refresh_enabled: $("watchlistAutoRefreshEnabled").value === "true",
|
watchlist_auto_refresh_enabled: $("watchlistAutoRefreshEnabled").value === "true",
|
||||||
watchlist_auto_refresh_minutes: $("watchlistAutoRefreshMinutes").value,
|
watchlist_auto_refresh_minutes: $("watchlistAutoRefreshMinutes").value,
|
||||||
watchlist_refresh_delay_seconds: $("watchlistRefreshDelaySeconds").value,
|
watchlist_refresh_delay_seconds: $("watchlistRefreshDelaySeconds").value,
|
||||||
@@ -761,7 +772,7 @@ CONFIG_HTML = r"""<!doctype html>
|
|||||||
$("downloadDir").value = data.download_dir;
|
$("downloadDir").value = data.download_dir;
|
||||||
$("configMode").value = data.mode;
|
$("configMode").value = data.mode;
|
||||||
$("configQuality").value = data.quality;
|
$("configQuality").value = data.quality;
|
||||||
$("downloadBackupEnabled").checked = Boolean(data.download_backup_enabled);
|
$("anipyCliFallbackEnabled").value = String(Boolean(data.anipy_cli_fallback_enabled));
|
||||||
$("watchlistAutoRefreshEnabled").value = String(Boolean(data.watchlist_auto_refresh_enabled));
|
$("watchlistAutoRefreshEnabled").value = String(Boolean(data.watchlist_auto_refresh_enabled));
|
||||||
$("watchlistAutoRefreshMinutes").value = data.watchlist_auto_refresh_minutes;
|
$("watchlistAutoRefreshMinutes").value = data.watchlist_auto_refresh_minutes;
|
||||||
$("watchlistRefreshDelaySeconds").value = data.watchlist_refresh_delay_seconds;
|
$("watchlistRefreshDelaySeconds").value = data.watchlist_refresh_delay_seconds;
|
||||||
@@ -971,7 +982,7 @@ CONFIG_HTML = r"""<!doctype html>
|
|||||||
const data = await api("/api/version");
|
const data = await api("/api/version");
|
||||||
$("versionLine").textContent = `${data.name} ${data.version}`;
|
$("versionLine").textContent = `${data.name} ${data.version}`;
|
||||||
$("aniCliVersionLine").textContent = `ani-cli ${data.ani_cli_version || "Unavailable"}`;
|
$("aniCliVersionLine").textContent = `ani-cli ${data.ani_cli_version || "Unavailable"}`;
|
||||||
$("anikotoCliVersionLine").textContent = `anikoto-cli ${data.anikoto_cli_version || "Unavailable"}`;
|
$("anipyCliVersionLine").textContent = `anipy-cli ${data.anipy_cli_version || "Unavailable"}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function openChangelog() {
|
async function openChangelog() {
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ services:
|
|||||||
args:
|
args:
|
||||||
ANI_CLI: ${ANI_CLI:-https://github.com/pystardust/ani-cli.git}
|
ANI_CLI: ${ANI_CLI:-https://github.com/pystardust/ani-cli.git}
|
||||||
ANI_CLI_BRANCH: ${ANI_CLI_BRANCH:-master}
|
ANI_CLI_BRANCH: ${ANI_CLI_BRANCH:-master}
|
||||||
ANIKOTO_CLI: ${ANIKOTO_CLI:-https://github.com/Slimyslushy/anikoto-cli.git}
|
|
||||||
ANIKOTO_CLI_BRANCH: ${ANIKOTO_CLI_BRANCH:-main}
|
|
||||||
ANI_CLI_WEB: ${ANI_CLI_WEB:-https://gitea.coreplay.eu/Dymas/ani-cli-web.git}
|
ANI_CLI_WEB: ${ANI_CLI_WEB:-https://gitea.coreplay.eu/Dymas/ani-cli-web.git}
|
||||||
image: ani-cli-web:latest
|
image: ani-cli-web:latest
|
||||||
container_name: ani-cli-web
|
container_name: ani-cli-web
|
||||||
|
|||||||
+8
-7
@@ -20,8 +20,8 @@ from pathlib import Path
|
|||||||
from urllib.parse import parse_qs, unquote, urlencode, urlparse, urlunparse
|
from urllib.parse import parse_qs, unquote, urlencode, urlparse, urlunparse
|
||||||
|
|
||||||
from app_support import (
|
from app_support import (
|
||||||
ANIKOTO_CLI,
|
|
||||||
ANI_CLI,
|
ANI_CLI,
|
||||||
|
ANIPY_CLI,
|
||||||
APP_NAME,
|
APP_NAME,
|
||||||
CHANGELOG_FILE,
|
CHANGELOG_FILE,
|
||||||
CLIENT_DISCONNECT_ERRORS,
|
CLIENT_DISCONNECT_ERRORS,
|
||||||
@@ -33,6 +33,7 @@ from app_support import (
|
|||||||
debug_enabled,
|
debug_enabled,
|
||||||
debug_log,
|
debug_log,
|
||||||
load_project_text_file,
|
load_project_text_file,
|
||||||
|
cli_executable_exists,
|
||||||
normalize_config,
|
normalize_config,
|
||||||
path_is_within_roots,
|
path_is_within_roots,
|
||||||
remote_access_allowed,
|
remote_access_allowed,
|
||||||
@@ -86,10 +87,10 @@ def build_handler_class(context):
|
|||||||
|
|
||||||
|
|
||||||
def dependency_status():
|
def dependency_status():
|
||||||
checks = ["curl", "sed", "grep", "openssl", "fzf", "aria2c", "ffmpeg", "yt-dlp", "jq", "mpv"]
|
checks = ["curl", "sed", "grep", "openssl", "fzf", "aria2c", "ffmpeg", "yt-dlp"]
|
||||||
result = {name: bool(shutil.which(name)) for name in checks}
|
result = {name: bool(shutil.which(name)) for name in checks}
|
||||||
result["ani-cli"] = bool(shutil.which(ANI_CLI) or (Path(ANI_CLI).exists() and os.access(ANI_CLI, os.X_OK)))
|
result["ani-cli"] = cli_executable_exists(ANI_CLI)
|
||||||
result["anikoto-cli"] = bool(shutil.which(ANIKOTO_CLI) or (Path(ANIKOTO_CLI).exists() and os.access(ANIKOTO_CLI, os.X_OK)))
|
result["anipy-cli"] = cli_executable_exists(ANIPY_CLI)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@@ -169,10 +170,10 @@ def installed_ani_cli_version():
|
|||||||
|
|
||||||
|
|
||||||
@lru_cache(maxsize=1)
|
@lru_cache(maxsize=1)
|
||||||
def installed_anikoto_cli_version():
|
def installed_anipy_cli_version():
|
||||||
try:
|
try:
|
||||||
completed = subprocess.run(
|
completed = subprocess.run(
|
||||||
[ANIKOTO_CLI, "--version"],
|
[ANIPY_CLI, "--version"],
|
||||||
check=True,
|
check=True,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
@@ -558,7 +559,7 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
"name": APP_NAME,
|
"name": APP_NAME,
|
||||||
"version": VERSION,
|
"version": VERSION,
|
||||||
"ani_cli_version": installed_ani_cli_version(),
|
"ani_cli_version": installed_ani_cli_version(),
|
||||||
"anikoto_cli_version": installed_anikoto_cli_version(),
|
"anipy_cli_version": installed_anipy_cli_version(),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
elif parsed.path == "/api/changelog":
|
elif parsed.path == "/api/changelog":
|
||||||
|
|||||||
+113
-84
@@ -13,13 +13,14 @@ import time
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from app_support import (
|
from app_support import (
|
||||||
ANIKOTO_CLI,
|
ANIPY_CLI,
|
||||||
MAX_LOG_LINES,
|
MAX_LOG_LINES,
|
||||||
PROJECT_ROOT,
|
PROJECT_ROOT,
|
||||||
QUEUE_PATH,
|
QUEUE_PATH,
|
||||||
STATE_DB_PATH,
|
STATE_DB_PATH,
|
||||||
WORKER_SHUTDOWN_TIMEOUT_SECONDS,
|
WORKER_SHUTDOWN_TIMEOUT_SECONDS,
|
||||||
build_job,
|
build_job,
|
||||||
|
cli_executable_exists,
|
||||||
command_for_job,
|
command_for_job,
|
||||||
debug_log,
|
debug_log,
|
||||||
finalize_library_files,
|
finalize_library_files,
|
||||||
@@ -1336,16 +1337,6 @@ class DownloadQueue:
|
|||||||
debug_log("queue.cleanup.staging_failed", job_id=job.get("id"), staging_dir=staging_dir, error=exc)
|
debug_log("queue.cleanup.staging_failed", job_id=job.get("id"), staging_dir=staging_dir, error=exc)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _command_available(self, command_name):
|
|
||||||
return bool(shutil.which(command_name) or (os.path.exists(command_name) and os.access(command_name, os.X_OK)))
|
|
||||||
|
|
||||||
def _download_attempts(self):
|
|
||||||
config = normalize_config(self.config_getter() or {})
|
|
||||||
attempts = [("ani-cli", command_for_job)]
|
|
||||||
if config.get("download_backup_enabled"):
|
|
||||||
attempts.append(("anikoto-cli", lambda job: command_for_job(job, downloader="anikoto-cli")))
|
|
||||||
return attempts
|
|
||||||
|
|
||||||
def _fail_job_startup(self, job, exc):
|
def _fail_job_startup(self, job, exc):
|
||||||
message = f"Could not start download: {exc}"
|
message = f"Could not start download: {exc}"
|
||||||
with self.lock:
|
with self.lock:
|
||||||
@@ -1384,6 +1375,36 @@ class DownloadQueue:
|
|||||||
self._save_job_locked(job)
|
self._save_job_locked(job)
|
||||||
self._cleanup_staging_dir(job)
|
self._cleanup_staging_dir(job)
|
||||||
|
|
||||||
|
def _command_attempts(self, job, staging_dir):
|
||||||
|
config = normalize_config(self.config_getter() or {})
|
||||||
|
attempts = [
|
||||||
|
{
|
||||||
|
"backend": "ani-cli",
|
||||||
|
"command": command_for_job(job, backend="ani-cli"),
|
||||||
|
"env": {
|
||||||
|
**os.environ.copy(),
|
||||||
|
"ANI_CLI_DOWNLOAD_DIR": str(staging_dir),
|
||||||
|
"ANI_CLI_MODE": job["mode"],
|
||||||
|
"ANI_CLI_QUALITY": job["quality"],
|
||||||
|
"TERM": os.environ.get("TERM", "xterm-256color"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
]
|
||||||
|
fallback_enabled = bool(config.get("anipy_cli_fallback_enabled"))
|
||||||
|
fallback_available = cli_executable_exists(ANIPY_CLI)
|
||||||
|
if fallback_enabled and fallback_available:
|
||||||
|
attempts.append(
|
||||||
|
{
|
||||||
|
"backend": "anipy-cli",
|
||||||
|
"command": command_for_job(job, backend="anipy-cli", download_path=staging_dir),
|
||||||
|
"env": {
|
||||||
|
**os.environ.copy(),
|
||||||
|
"TERM": os.environ.get("TERM", "xterm-256color"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
return attempts, fallback_enabled, fallback_available
|
||||||
|
|
||||||
def _run(self):
|
def _run(self):
|
||||||
while not self.stop_event.is_set():
|
while not self.stop_event.is_set():
|
||||||
job = self._next_pending()
|
job = self._next_pending()
|
||||||
@@ -1396,19 +1417,10 @@ class DownloadQueue:
|
|||||||
def _run_job(self, job):
|
def _run_job(self, job):
|
||||||
staging_dir = job_staging_dir(job)
|
staging_dir = job_staging_dir(job)
|
||||||
target_dir = job_output_dir(job)
|
target_dir = job_output_dir(job)
|
||||||
env = os.environ.copy()
|
|
||||||
env.update(
|
|
||||||
{
|
|
||||||
"ANI_CLI_DOWNLOAD_DIR": str(staging_dir),
|
|
||||||
"ANI_CLI_MODE": job["mode"],
|
|
||||||
"ANI_CLI_QUALITY": job["quality"],
|
|
||||||
"TERM": env.get("TERM", "xterm-256color"),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
staging_dir.mkdir(parents=True, exist_ok=True)
|
staging_dir.mkdir(parents=True, exist_ok=True)
|
||||||
target_dir.mkdir(parents=True, exist_ok=True)
|
target_dir.mkdir(parents=True, exist_ok=True)
|
||||||
attempts = self._download_attempts()
|
attempts, fallback_enabled, fallback_available = self._command_attempts(job, staging_dir)
|
||||||
primary_command = attempts[0][1](job)
|
primary_command = attempts[0]["command"]
|
||||||
|
|
||||||
with self.lock:
|
with self.lock:
|
||||||
job["status"] = "running"
|
job["status"] = "running"
|
||||||
@@ -1417,48 +1429,48 @@ class DownloadQueue:
|
|||||||
job["command"] = printable_command(primary_command)
|
job["command"] = printable_command(primary_command)
|
||||||
job["staging_dir"] = str(staging_dir)
|
job["staging_dir"] = str(staging_dir)
|
||||||
job["target_dir"] = str(target_dir)
|
job["target_dir"] = str(target_dir)
|
||||||
|
job["download_backend"] = "ani-cli"
|
||||||
|
job["fallback_used"] = False
|
||||||
job["log"] = [
|
job["log"] = [
|
||||||
f"Starting: {job['command']}",
|
f"Starting: {job['command']}",
|
||||||
f"Staging in: {job['staging_dir']}",
|
f"Staging in: {job['staging_dir']}",
|
||||||
f"Final folder: {job['target_dir']}",
|
f"Final folder: {job['target_dir']}",
|
||||||
]
|
]
|
||||||
if len(attempts) > 1:
|
if fallback_enabled and fallback_available:
|
||||||
job["log"].append("Backup downloads are enabled. Failed ani-cli jobs will retry with anikoto-cli.")
|
job["log"].append("anipy-cli fallback is enabled and will retry automatically if ani-cli fails.")
|
||||||
|
elif fallback_enabled:
|
||||||
|
job["log"].append("anipy-cli fallback is enabled, but anipy-cli is not installed or not executable.")
|
||||||
job["cancel_requested"] = False
|
job["cancel_requested"] = False
|
||||||
job["_dirty_log_lines"] = 0
|
job["_dirty_log_lines"] = 0
|
||||||
self._save_job_locked(job)
|
self._save_job_locked(job)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
last_exit_code = 1
|
exit_code = 1
|
||||||
last_finalize_error = None
|
successful_backend = None
|
||||||
|
finalize_error = None
|
||||||
moved_files = []
|
moved_files = []
|
||||||
watchlist_sync_error = None
|
watchlist_sync_error = None
|
||||||
synced_watchlist_item = None
|
synced_watchlist_item = None
|
||||||
canceled = False
|
cleanup_staging = False
|
||||||
download_succeeded = False
|
for index, attempt in enumerate(attempts):
|
||||||
|
backend = attempt["backend"]
|
||||||
for attempt_index, (downloader_name, command_builder) in enumerate(attempts):
|
command = attempt["command"]
|
||||||
command = command_builder(job)
|
should_fallback = index + 1 < len(attempts)
|
||||||
if attempt_index > 0:
|
|
||||||
self._cleanup_staging_dir(job)
|
|
||||||
staging_dir.mkdir(parents=True, exist_ok=True)
|
|
||||||
self._append_log(job, f"Retrying with backup downloader: {downloader_name}.")
|
|
||||||
self._append_log(job, "anikoto-cli does not support ani-cli quality flags, so the saved quality preference is ignored for the backup attempt.")
|
|
||||||
if downloader_name == "anikoto-cli" and not self._command_available(ANIKOTO_CLI):
|
|
||||||
self._append_log(job, "Backup downloader anikoto-cli is not installed or not executable.")
|
|
||||||
continue
|
|
||||||
|
|
||||||
with self.lock:
|
with self.lock:
|
||||||
|
job["download_backend"] = backend
|
||||||
job["command"] = printable_command(command)
|
job["command"] = printable_command(command)
|
||||||
|
if index > 0:
|
||||||
|
job["fallback_used"] = True
|
||||||
|
job["pid"] = None
|
||||||
job["updated_at"] = now_iso()
|
job["updated_at"] = now_iso()
|
||||||
|
if index > 0:
|
||||||
|
job.setdefault("log", []).append(f"Retrying with {backend}: {job['command']}")
|
||||||
self._save_job_locked(job)
|
self._save_job_locked(job)
|
||||||
self._append_log(job, f"Launching {downloader_name}: {job['command']}")
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
process = subprocess.Popen(
|
process = subprocess.Popen(
|
||||||
command,
|
command,
|
||||||
cwd=str(PROJECT_ROOT),
|
cwd=str(PROJECT_ROOT),
|
||||||
env=env,
|
env=attempt["env"],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
text=True,
|
text=True,
|
||||||
@@ -1466,10 +1478,14 @@ class DownloadQueue:
|
|||||||
start_new_session=True,
|
start_new_session=True,
|
||||||
)
|
)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
last_exit_code = 1
|
if should_fallback:
|
||||||
last_finalize_error = None
|
self._append_log(job, f"ani-cli could not start: {exc}")
|
||||||
self._append_log(job, f"Could not start {downloader_name}: {exc}")
|
self._append_log(job, "Retrying with anipy-cli fallback.")
|
||||||
continue
|
self._cleanup_staging_dir(job)
|
||||||
|
staging_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
continue
|
||||||
|
self._fail_job_startup(job, exc)
|
||||||
|
return
|
||||||
with self.lock:
|
with self.lock:
|
||||||
self.current_process = process
|
self.current_process = process
|
||||||
self.current_job_id = job["id"]
|
self.current_job_id = job["id"]
|
||||||
@@ -1487,53 +1503,65 @@ class DownloadQueue:
|
|||||||
self.current_job_id = None
|
self.current_job_id = None
|
||||||
self.current_job = None
|
self.current_job = None
|
||||||
self._save_job_locked(job)
|
self._save_job_locked(job)
|
||||||
canceled = bool(job.get("cancel_requested"))
|
|
||||||
if canceled:
|
if job.get("cancel_requested"):
|
||||||
last_exit_code = exit_code
|
|
||||||
break
|
break
|
||||||
if exit_code != 0:
|
|
||||||
last_exit_code = exit_code
|
if backend == "ani-cli" and exit_code != 0 and should_fallback:
|
||||||
last_finalize_error = None
|
self._append_log(job, f"ani-cli failed with exit code {exit_code}.")
|
||||||
self._append_log(job, f"{downloader_name} failed with exit code {exit_code}.")
|
self._append_log(job, "Retrying with anipy-cli fallback.")
|
||||||
|
self._cleanup_staging_dir(job)
|
||||||
|
staging_dir.mkdir(parents=True, exist_ok=True)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
if exit_code == 0:
|
||||||
moved_files = finalize_library_files(job)
|
|
||||||
except Exception as exc:
|
|
||||||
last_exit_code = 1
|
|
||||||
last_finalize_error = exc
|
|
||||||
message = str(exc).strip()
|
|
||||||
if "No downloaded files were found in the staging folder" in message:
|
|
||||||
self._append_log(
|
|
||||||
job,
|
|
||||||
f"{downloader_name} exited without downloading any files. The selected result or episodes may not be downloadable.",
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
self._append_log(job, f"Library rename failed after {downloader_name}: {exc}")
|
|
||||||
continue
|
|
||||||
|
|
||||||
download_succeeded = True
|
|
||||||
last_exit_code = 0
|
|
||||||
last_finalize_error = None
|
|
||||||
if self.watchlist_sync_fn is not None:
|
|
||||||
try:
|
try:
|
||||||
synced_watchlist_item = self.watchlist_sync_fn(job)
|
moved_files = finalize_library_files(job)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
watchlist_sync_error = exc
|
finalize_error = exc
|
||||||
|
no_files_downloaded = "No downloaded files were found in the staging folder" in str(exc)
|
||||||
|
if backend == "ani-cli" and no_files_downloaded and should_fallback:
|
||||||
|
self._append_log(
|
||||||
|
job,
|
||||||
|
"ani-cli exited without downloading any files. Retrying with anipy-cli fallback.",
|
||||||
|
)
|
||||||
|
self._cleanup_staging_dir(job)
|
||||||
|
staging_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
finalize_error = None
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
successful_backend = backend
|
||||||
|
if self.watchlist_sync_fn is not None:
|
||||||
|
try:
|
||||||
|
synced_watchlist_item = self.watchlist_sync_fn(job)
|
||||||
|
except Exception as exc:
|
||||||
|
watchlist_sync_error = exc
|
||||||
|
break
|
||||||
break
|
break
|
||||||
|
|
||||||
with self.lock:
|
with self.lock:
|
||||||
job["exit_code"] = last_exit_code
|
canceled = job.get("cancel_requested")
|
||||||
|
job["exit_code"] = 1 if finalize_error else exit_code
|
||||||
job["pid"] = None
|
job["pid"] = None
|
||||||
job["finished_at"] = now_iso()
|
job["finished_at"] = now_iso()
|
||||||
job["updated_at"] = job["finished_at"]
|
job["updated_at"] = job["finished_at"]
|
||||||
cleanup_staging = False
|
|
||||||
if canceled:
|
if canceled:
|
||||||
job["status"] = "canceled"
|
job["status"] = "canceled"
|
||||||
job.setdefault("log", []).append("Canceled.")
|
job.setdefault("log", []).append("Canceled.")
|
||||||
|
elif finalize_error:
|
||||||
|
job["status"] = "failed"
|
||||||
|
message = str(finalize_error).strip()
|
||||||
|
if "No downloaded files were found in the staging folder" in message:
|
||||||
|
job.setdefault("log", []).append(
|
||||||
|
f"{job.get('download_backend') or 'Downloader'} exited without downloading any files. The selected result or episodes may not be downloadable."
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
job.setdefault("log", []).append(f"Library rename failed: {finalize_error}")
|
||||||
cleanup_staging = True
|
cleanup_staging = True
|
||||||
elif download_succeeded:
|
elif exit_code == 0:
|
||||||
job["status"] = "done"
|
job["status"] = "done"
|
||||||
|
if successful_backend == "anipy-cli":
|
||||||
|
job.setdefault("log", []).append("Fallback download completed with anipy-cli.")
|
||||||
for path in moved_files:
|
for path in moved_files:
|
||||||
job.setdefault("log", []).append(f"Saved: {path}")
|
job.setdefault("log", []).append(f"Saved: {path}")
|
||||||
job.setdefault("log", []).append("Download completed.")
|
job.setdefault("log", []).append("Download completed.")
|
||||||
@@ -1546,10 +1574,11 @@ class DownloadQueue:
|
|||||||
job.setdefault("log", []).append("Watchlist download state synced.")
|
job.setdefault("log", []).append("Watchlist download state synced.")
|
||||||
else:
|
else:
|
||||||
job["status"] = "failed"
|
job["status"] = "failed"
|
||||||
if last_finalize_error and "No downloaded files were found in the staging folder" not in str(last_finalize_error):
|
job.setdefault("log", []).append(
|
||||||
job.setdefault("log", []).append(f"Download failed after all downloaders were tried: {last_finalize_error}")
|
f"{job.get('download_backend') or 'Download'} failed with exit code {exit_code}."
|
||||||
else:
|
)
|
||||||
job.setdefault("log", []).append("Download failed after all configured downloaders were tried.")
|
cleanup_staging = True
|
||||||
|
if canceled:
|
||||||
cleanup_staging = True
|
cleanup_staging = True
|
||||||
self.current_process = None
|
self.current_process = None
|
||||||
self.current_job_id = None
|
self.current_job_id = None
|
||||||
@@ -1557,7 +1586,7 @@ class DownloadQueue:
|
|||||||
self._save_job_locked(job)
|
self._save_job_locked(job)
|
||||||
if cleanup_staging:
|
if cleanup_staging:
|
||||||
self._cleanup_staging_dir(job)
|
self._cleanup_staging_dir(job)
|
||||||
elif download_succeeded:
|
elif exit_code == 0 and not finalize_error and not canceled:
|
||||||
download_title = (
|
download_title = (
|
||||||
str((synced_watchlist_item or {}).get("title") or "").strip()
|
str((synced_watchlist_item or {}).get("title") or "").strip()
|
||||||
or str(job.get("title") or "").strip()
|
or str(job.get("title") or "").strip()
|
||||||
@@ -1581,4 +1610,4 @@ class DownloadQueue:
|
|||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
debug_log("discord_webhook.download_completed_failed", title=download_title, error=exc)
|
debug_log("discord_webhook.download_completed_failed", title=download_title, error=exc)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
self._fail_job_runtime(job, exc)
|
self._fail_job_runtime(job, exc, process=process)
|
||||||
|
|||||||
+103
-59
@@ -589,6 +589,36 @@ class QueueApiTests(unittest.TestCase):
|
|||||||
self.assertTrue(Path(moved[0]).exists())
|
self.assertTrue(Path(moved[0]).exists())
|
||||||
self.assertTrue(Path(moved[1]).exists())
|
self.assertTrue(Path(moved[1]).exists())
|
||||||
|
|
||||||
|
def test_tv_finalizer_uses_requested_episode_numbers_for_anipy_fallback(self):
|
||||||
|
with tempfile.TemporaryDirectory() as temp_root:
|
||||||
|
job = APP.app_support.build_job(
|
||||||
|
{
|
||||||
|
"query": "Fallback Show",
|
||||||
|
"title": "Fallback Show",
|
||||||
|
"anime_name": "Fallback Show",
|
||||||
|
"media_type": "tv",
|
||||||
|
"mode": "sub",
|
||||||
|
"quality": "best",
|
||||||
|
"episodes": "11",
|
||||||
|
"download_dir": temp_root,
|
||||||
|
"season": "2",
|
||||||
|
},
|
||||||
|
{"mode": "sub", "quality": "best", "download_dir": temp_root},
|
||||||
|
)
|
||||||
|
job["download_backend"] = "anipy-cli"
|
||||||
|
staging_dir = APP.app_support.job_staging_dir(job)
|
||||||
|
staging_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
source = staging_dir / "Fallback Show - S02E01.mp4"
|
||||||
|
source.write_bytes(b"fallback")
|
||||||
|
|
||||||
|
moved = APP.app_support.finalize_library_files(job)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
moved,
|
||||||
|
[f"{temp_root}/tv/Fallback Show/Season 02/Fallback Show - S02E11.mp4"],
|
||||||
|
)
|
||||||
|
self.assertTrue(Path(moved[0]).exists())
|
||||||
|
|
||||||
def test_shutdown_wait_cancels_active_process_for_deterministic_teardown(self):
|
def test_shutdown_wait_cancels_active_process_for_deterministic_teardown(self):
|
||||||
queue = object.__new__(APP.DownloadQueue)
|
queue = object.__new__(APP.DownloadQueue)
|
||||||
queue.lock = threading.RLock()
|
queue.lock = threading.RLock()
|
||||||
@@ -624,7 +654,7 @@ class DownloadQueueWorkerFailureTests(unittest.TestCase):
|
|||||||
stored = queue._find(job["id"])
|
stored = queue._find(job["id"])
|
||||||
self.assertEqual(stored["status"], "failed")
|
self.assertEqual(stored["status"], "failed")
|
||||||
self.assertEqual(stored["exit_code"], 1)
|
self.assertEqual(stored["exit_code"], 1)
|
||||||
self.assertIn("Could not start ani-cli", "\n".join(stored["log"]))
|
self.assertIn("Could not start download", stored["log"][-1])
|
||||||
self.assertFalse(staging_dir.exists())
|
self.assertFalse(staging_dir.exists())
|
||||||
|
|
||||||
def test_failed_download_cleans_staging_dir(self):
|
def test_failed_download_cleans_staging_dir(self):
|
||||||
@@ -669,46 +699,6 @@ class DownloadQueueWorkerFailureTests(unittest.TestCase):
|
|||||||
self.assertIn("without downloading any files", "\n".join(stored["log"]))
|
self.assertIn("without downloading any files", "\n".join(stored["log"]))
|
||||||
self.assertFalse(staging_dir.exists())
|
self.assertFalse(staging_dir.exists())
|
||||||
|
|
||||||
def test_failed_ani_cli_retries_with_anikoto_backup(self):
|
|
||||||
queue = APP.DownloadQueue(
|
|
||||||
lambda: {
|
|
||||||
"mode": "sub",
|
|
||||||
"quality": "best",
|
|
||||||
"download_dir": "/tmp/example",
|
|
||||||
"download_backup_enabled": True,
|
|
||||||
},
|
|
||||||
start_worker=False,
|
|
||||||
)
|
|
||||||
job = queue.add({"query": "Queue Show", "title": "Queue Show", "season": "1", "episodes": "1"})
|
|
||||||
|
|
||||||
class FailedProc:
|
|
||||||
pid = 1111
|
|
||||||
stdout = []
|
|
||||||
|
|
||||||
def wait(self):
|
|
||||||
return 1
|
|
||||||
|
|
||||||
class SuccessProc:
|
|
||||||
pid = 2222
|
|
||||||
stdout = []
|
|
||||||
|
|
||||||
def wait(self):
|
|
||||||
return 0
|
|
||||||
|
|
||||||
with mock.patch.object(queue_jobs.subprocess, "Popen", side_effect=[FailedProc(), SuccessProc()]), mock.patch.object(
|
|
||||||
queue, "_command_available", return_value=True
|
|
||||||
), mock.patch.object(
|
|
||||||
queue_jobs, "finalize_library_files", return_value=["/tmp/example/tv/Queue Show/Season 01/Queue Show - S01E01.mp4"]
|
|
||||||
):
|
|
||||||
queue._run_job(job)
|
|
||||||
|
|
||||||
stored = queue._find(job["id"])
|
|
||||||
self.assertEqual(stored["status"], "done")
|
|
||||||
log_text = "\n".join(stored["log"])
|
|
||||||
self.assertIn("Retrying with backup downloader: anikoto-cli.", log_text)
|
|
||||||
self.assertIn("anikoto-cli does not support ani-cli quality flags", log_text)
|
|
||||||
self.assertIn("Download completed.", log_text)
|
|
||||||
|
|
||||||
def test_run_job_marks_post_start_exception_failed_without_killing_worker_state(self):
|
def test_run_job_marks_post_start_exception_failed_without_killing_worker_state(self):
|
||||||
queue = APP.DownloadQueue(lambda: {"mode": "sub", "quality": "best", "download_dir": "/tmp/example"}, start_worker=False)
|
queue = APP.DownloadQueue(lambda: {"mode": "sub", "quality": "best", "download_dir": "/tmp/example"}, start_worker=False)
|
||||||
job = queue.add({"query": "Queue Show", "title": "Queue Show", "season": "1", "episodes": "1"})
|
job = queue.add({"query": "Queue Show", "title": "Queue Show", "season": "1", "episodes": "1"})
|
||||||
@@ -811,6 +801,51 @@ class DownloadQueueWorkerFailureTests(unittest.TestCase):
|
|||||||
self.assertIn("Watchlist sync skipped for detached job.", stored["log"])
|
self.assertIn("Watchlist sync skipped for detached job.", stored["log"])
|
||||||
self.assertNotIn("Watchlist download state synced.", stored["log"])
|
self.assertNotIn("Watchlist download state synced.", stored["log"])
|
||||||
|
|
||||||
|
def test_failed_ani_cli_retries_with_anipy_when_enabled(self):
|
||||||
|
queue = APP.DownloadQueue(
|
||||||
|
lambda: {
|
||||||
|
"mode": "sub",
|
||||||
|
"quality": "best",
|
||||||
|
"download_dir": "/tmp/example",
|
||||||
|
"anipy_cli_fallback_enabled": True,
|
||||||
|
},
|
||||||
|
start_worker=False,
|
||||||
|
)
|
||||||
|
job = queue.add({"query": "Queue Show", "title": "Queue Show", "season": "1", "episodes": "1"})
|
||||||
|
commands = []
|
||||||
|
|
||||||
|
class FakeProc:
|
||||||
|
def __init__(self, pid, stdout, exit_code):
|
||||||
|
self.pid = pid
|
||||||
|
self.stdout = stdout
|
||||||
|
self._exit_code = exit_code
|
||||||
|
|
||||||
|
def wait(self):
|
||||||
|
return self._exit_code
|
||||||
|
|
||||||
|
processes = [
|
||||||
|
FakeProc(4321, ["ani-cli attempt\n"], 1),
|
||||||
|
FakeProc(5432, ["anipy-cli attempt\n"], 0),
|
||||||
|
]
|
||||||
|
|
||||||
|
def fake_popen(command, **kwargs):
|
||||||
|
commands.append(command)
|
||||||
|
return processes.pop(0)
|
||||||
|
|
||||||
|
with mock.patch.object(queue_jobs, "cli_executable_exists", return_value=True), mock.patch.object(
|
||||||
|
queue_jobs.subprocess, "Popen", side_effect=fake_popen
|
||||||
|
), mock.patch.object(
|
||||||
|
queue_jobs, "finalize_library_files", return_value=["/tmp/example/Queue Show - S01E01.mp4"]
|
||||||
|
):
|
||||||
|
queue._run_job(job)
|
||||||
|
|
||||||
|
stored = queue._find(job["id"])
|
||||||
|
self.assertEqual(stored["status"], "done")
|
||||||
|
self.assertTrue(stored["fallback_used"])
|
||||||
|
self.assertEqual(commands[0][0], APP.app_support.ANI_CLI)
|
||||||
|
self.assertEqual(commands[1][0], APP.app_support.ANIPY_CLI)
|
||||||
|
self.assertIn("Fallback download completed with anipy-cli.", stored["log"])
|
||||||
|
|
||||||
|
|
||||||
class WatchlistRefreshAllTests(unittest.TestCase):
|
class WatchlistRefreshAllTests(unittest.TestCase):
|
||||||
def test_refresh_all_iterates_only_watching_and_planned_show_ids(self):
|
def test_refresh_all_iterates_only_watching_and_planned_show_ids(self):
|
||||||
@@ -1637,21 +1672,22 @@ class WatchlistCompletionTests(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertNotIn("-S", command)
|
self.assertNotIn("-S", command)
|
||||||
|
|
||||||
def test_command_for_job_builds_anikoto_backup_command_without_quality_flag(self):
|
def test_command_for_job_builds_anipy_fallback_search_spec(self):
|
||||||
command = APP.app_support.command_for_job(
|
command = APP.app_support.command_for_job(
|
||||||
{
|
{
|
||||||
"query": "Queue Show",
|
"query": "Re:Zero",
|
||||||
"quality": "best",
|
"quality": "720",
|
||||||
"episodes": "1-10",
|
"episodes": "1-3",
|
||||||
"mode": "sub",
|
"mode": "dub",
|
||||||
},
|
},
|
||||||
downloader="anikoto-cli",
|
backend="anipy-cli",
|
||||||
|
download_path="/tmp/anipy-staging",
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(command[0], APP.app_support.ANIKOTO_CLI)
|
self.assertEqual(command[0], APP.app_support.ANIPY_CLI)
|
||||||
self.assertIn("-d", command)
|
self.assertEqual(command[1:5], ["-D", "-s", "Re Zero:1-3:dub", "-q"])
|
||||||
self.assertIn("--sub", command)
|
self.assertIn("-l", command)
|
||||||
self.assertNotIn("-q", command)
|
self.assertEqual(command[-1], "/tmp/anipy-staging")
|
||||||
|
|
||||||
def test_download_watchlist_item_queues_full_episode_range_for_selected_mode(self):
|
def test_download_watchlist_item_queues_full_episode_range_for_selected_mode(self):
|
||||||
item = {
|
item = {
|
||||||
@@ -2130,10 +2166,10 @@ class ConfigSnapshotTests(unittest.TestCase):
|
|||||||
|
|
||||||
def test_normalize_config_includes_watchlist_schedule_defaults(self):
|
def test_normalize_config_includes_watchlist_schedule_defaults(self):
|
||||||
config = APP.normalize_config({})
|
config = APP.normalize_config({})
|
||||||
self.assertFalse(config["download_backup_enabled"])
|
|
||||||
self.assertFalse(config["watchlist_auto_refresh_enabled"])
|
self.assertFalse(config["watchlist_auto_refresh_enabled"])
|
||||||
self.assertEqual(config["watchlist_auto_refresh_minutes"], 60)
|
self.assertEqual(config["watchlist_auto_refresh_minutes"], 60)
|
||||||
self.assertEqual(config["watchlist_refresh_delay_seconds"], 5)
|
self.assertEqual(config["watchlist_refresh_delay_seconds"], 5)
|
||||||
|
self.assertFalse(config["anipy_cli_fallback_enabled"])
|
||||||
self.assertFalse(config["auto_download_enabled"])
|
self.assertFalse(config["auto_download_enabled"])
|
||||||
self.assertEqual(config["auto_download_mode"], "dub")
|
self.assertEqual(config["auto_download_mode"], "dub")
|
||||||
self.assertEqual(config["auto_download_quality"], "best")
|
self.assertEqual(config["auto_download_quality"], "best")
|
||||||
@@ -2146,7 +2182,7 @@ class ConfigSnapshotTests(unittest.TestCase):
|
|||||||
def test_normalize_config_parses_watchlist_schedule_fields(self):
|
def test_normalize_config_parses_watchlist_schedule_fields(self):
|
||||||
config = APP.normalize_config(
|
config = APP.normalize_config(
|
||||||
{
|
{
|
||||||
"download_backup_enabled": "true",
|
"anipy_cli_fallback_enabled": "true",
|
||||||
"watchlist_auto_refresh_enabled": "true",
|
"watchlist_auto_refresh_enabled": "true",
|
||||||
"watchlist_auto_refresh_minutes": "15",
|
"watchlist_auto_refresh_minutes": "15",
|
||||||
"watchlist_refresh_delay_seconds": "7",
|
"watchlist_refresh_delay_seconds": "7",
|
||||||
@@ -2158,7 +2194,7 @@ class ConfigSnapshotTests(unittest.TestCase):
|
|||||||
"jellyfin_movie_dir": "~/jellyfin/movies",
|
"jellyfin_movie_dir": "~/jellyfin/movies",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.assertTrue(config["download_backup_enabled"])
|
self.assertTrue(config["anipy_cli_fallback_enabled"])
|
||||||
self.assertTrue(config["watchlist_auto_refresh_enabled"])
|
self.assertTrue(config["watchlist_auto_refresh_enabled"])
|
||||||
self.assertEqual(config["watchlist_auto_refresh_minutes"], 15)
|
self.assertEqual(config["watchlist_auto_refresh_minutes"], 15)
|
||||||
self.assertEqual(config["watchlist_refresh_delay_seconds"], 7)
|
self.assertEqual(config["watchlist_refresh_delay_seconds"], 7)
|
||||||
@@ -2751,10 +2787,11 @@ class HandlerRouteTests(unittest.TestCase):
|
|||||||
APP.initialize_runtime(start_workers=False)
|
APP.initialize_runtime(start_workers=False)
|
||||||
|
|
||||||
def test_config_post_accepts_watchlist_schedule_fields(self):
|
def test_config_post_accepts_watchlist_schedule_fields(self):
|
||||||
body = b'{"download_dir":"/tmp/example","mode":"sub","quality":"best","watchlist_auto_refresh_enabled":true,"watchlist_auto_refresh_minutes":"25","watchlist_refresh_delay_seconds":"9","auto_download_enabled":true,"auto_download_mode":"dub","auto_download_quality":"720","jellyfin_sync_enabled":true,"jellyfin_tv_dir":"/tmp/jellyfin-tv","jellyfin_movie_dir":"/tmp/jellyfin-movies"}'
|
body = b'{"download_dir":"/tmp/example","mode":"sub","quality":"best","anipy_cli_fallback_enabled":true,"watchlist_auto_refresh_enabled":true,"watchlist_auto_refresh_minutes":"25","watchlist_refresh_delay_seconds":"9","auto_download_enabled":true,"auto_download_mode":"dub","auto_download_quality":"720","jellyfin_sync_enabled":true,"jellyfin_tv_dir":"/tmp/jellyfin-tv","jellyfin_movie_dir":"/tmp/jellyfin-movies"}'
|
||||||
handler = DummyHandler("/api/config", body=body, content_length=len(body))
|
handler = DummyHandler("/api/config", body=body, content_length=len(body))
|
||||||
APP.Handler.do_POST(handler)
|
APP.Handler.do_POST(handler)
|
||||||
self.assertEqual(handler.json_status, HTTPStatus.OK)
|
self.assertEqual(handler.json_status, HTTPStatus.OK)
|
||||||
|
self.assertTrue(handler.json_payload["anipy_cli_fallback_enabled"])
|
||||||
self.assertTrue(handler.json_payload["watchlist_auto_refresh_enabled"])
|
self.assertTrue(handler.json_payload["watchlist_auto_refresh_enabled"])
|
||||||
self.assertEqual(handler.json_payload["watchlist_auto_refresh_minutes"], 25)
|
self.assertEqual(handler.json_payload["watchlist_auto_refresh_minutes"], 25)
|
||||||
self.assertEqual(handler.json_payload["watchlist_refresh_delay_seconds"], 9)
|
self.assertEqual(handler.json_payload["watchlist_refresh_delay_seconds"], 9)
|
||||||
@@ -2765,13 +2802,20 @@ class HandlerRouteTests(unittest.TestCase):
|
|||||||
self.assertEqual(handler.json_payload["jellyfin_tv_dir"], "/tmp/jellyfin-tv")
|
self.assertEqual(handler.json_payload["jellyfin_tv_dir"], "/tmp/jellyfin-tv")
|
||||||
self.assertEqual(handler.json_payload["jellyfin_movie_dir"], "/tmp/jellyfin-movies")
|
self.assertEqual(handler.json_payload["jellyfin_movie_dir"], "/tmp/jellyfin-movies")
|
||||||
|
|
||||||
def test_version_route_includes_ani_cli_version(self):
|
def test_version_route_includes_cli_versions(self):
|
||||||
handler = DummyHandler("/api/version")
|
handler = DummyHandler("/api/version")
|
||||||
APP.Handler.do_GET(handler)
|
APP.Handler.do_GET(handler)
|
||||||
self.assertEqual(handler.json_status, HTTPStatus.OK)
|
self.assertEqual(handler.json_status, HTTPStatus.OK)
|
||||||
self.assertEqual(handler.json_payload["name"], APP.APP_NAME)
|
self.assertEqual(handler.json_payload["name"], APP.APP_NAME)
|
||||||
self.assertEqual(handler.json_payload["version"], APP.VERSION)
|
self.assertEqual(handler.json_payload["version"], APP.VERSION)
|
||||||
self.assertIn("ani_cli_version", handler.json_payload)
|
self.assertIn("ani_cli_version", handler.json_payload)
|
||||||
|
self.assertIn("anipy_cli_version", handler.json_payload)
|
||||||
|
|
||||||
|
def test_dependencies_route_reports_anipy_cli_status(self):
|
||||||
|
handler = DummyHandler("/api/dependencies")
|
||||||
|
APP.Handler.do_GET(handler)
|
||||||
|
self.assertEqual(handler.json_status, HTTPStatus.OK)
|
||||||
|
self.assertIn("anipy-cli", handler.json_payload)
|
||||||
|
|
||||||
def test_changelog_route_returns_project_changelog_content(self):
|
def test_changelog_route_returns_project_changelog_content(self):
|
||||||
handler = DummyHandler("/api/changelog")
|
handler = DummyHandler("/api/changelog")
|
||||||
@@ -3303,10 +3347,10 @@ class TemplateHelperTests(unittest.TestCase):
|
|||||||
self.assertIn("@media (max-width: 1080px)", APP.CONFIG_HTML)
|
self.assertIn("@media (max-width: 1080px)", APP.CONFIG_HTML)
|
||||||
self.assertIn("justify-items: stretch;", APP.CONFIG_HTML)
|
self.assertIn("justify-items: stretch;", APP.CONFIG_HTML)
|
||||||
self.assertIn('id="aniCliVersionLine"', APP.CONFIG_HTML)
|
self.assertIn('id="aniCliVersionLine"', APP.CONFIG_HTML)
|
||||||
self.assertIn('id="anikotoCliVersionLine"', APP.CONFIG_HTML)
|
self.assertIn('id="anipyCliVersionLine"', APP.CONFIG_HTML)
|
||||||
self.assertIn('ani-cli ${data.ani_cli_version || "Unavailable"}', APP.CONFIG_HTML)
|
self.assertIn('ani-cli ${data.ani_cli_version || "Unavailable"}', APP.CONFIG_HTML)
|
||||||
self.assertIn('anikoto-cli ${data.anikoto_cli_version || "Unavailable"}', APP.CONFIG_HTML)
|
self.assertIn('anipy-cli ${data.anipy_cli_version || "Unavailable"}', APP.CONFIG_HTML)
|
||||||
self.assertIn('id="downloadBackupEnabled"', APP.CONFIG_HTML)
|
self.assertIn('id="anipyCliFallbackEnabled"', APP.CONFIG_HTML)
|
||||||
self.assertIn('id="openChangelogBtn"', APP.CONFIG_HTML)
|
self.assertIn('id="openChangelogBtn"', APP.CONFIG_HTML)
|
||||||
self.assertIn('id="changelogOverlay"', APP.CONFIG_HTML)
|
self.assertIn('id="changelogOverlay"', APP.CONFIG_HTML)
|
||||||
self.assertIn('const data = await api("/api/changelog");', APP.CONFIG_HTML)
|
self.assertIn('const data = await api("/api/changelog");', APP.CONFIG_HTML)
|
||||||
|
|||||||
Reference in New Issue
Block a user