diff --git a/.env.example b/.env.example index 71bdae1..1a0cd20 100644 --- a/.env.example +++ b/.env.example @@ -31,8 +31,8 @@ VPN_PORT_FORWARDING=${VPN_PORT_FORWARDING} # configure.sh API host API_HOST=${API_HOST} -# seerr-gateway: 1 = DELETE /request also purges media (assemblrr default). -# Set to 0 when Seerr natively purges on request delete — see docs/seerr-delete-request.md +# seerr-gateway: 1 = DELETE /request cancels in-flight *arr/qB grabs (not library files). +# Set to 0 for stock Seerr (request row only). See docs/seerr-delete-request.md SEERR_DELETE_REQUEST_PURGE=1 # media-purge-watch: 1 = inotify on library deletes (Jellyfin/*arr file remove → qB). diff --git a/README.md b/README.md index f381f65..bea6753 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Official support is the **express / default** install only: - **Managers:** Sonarr, Radarr - **Subtitles:** Bazarr (auto-wired to Sonarr/Radarr; optional OpenSubtitles.com) - **Indexing:** Prowlarr -- **Request Management:** Seerr (delete request removes that request’s media via `seerr-gateway`; TV is season-scoped — see [docs/seerr-delete-request.md](docs/seerr-delete-request.md)) +- **Request Management:** Seerr (`seerr-gateway`: delete request cancels in-flight downloads, not library files — see [docs/seerr-delete-request.md](docs/seerr-delete-request.md)) - **Quality Profiles:** Recyclarr - **VPN (optional):** Gluetun + watchdog - **Management:** Built-in `assemblrr` CLI (`status`, `logs`, `start`/`stop`, …) @@ -117,7 +117,7 @@ Configuration lives in your installation directory (default: `~/assemblrr`). ## Documentation - **[TRaSH Guides & Quality Profiles](docs/trash-guides.md):** Details on how assemblrr handles quality profiles and what to do when community guide IDs change. -- **[Seerr delete request → purge](docs/seerr-delete-request.md):** How `seerr-gateway` makes “delete request” remove media/torrents (TV is season-scoped), and how to retire it if Seerr gains this natively. +- **[Seerr delete request](docs/seerr-delete-request.md):** How `seerr-gateway` cancels in-flight downloads on “delete request” (library files stay), and how to retire it if Seerr gains this natively. - **[Uninstall Guide](docs/uninstall.md):** Complete removal guide, including a full inventory of what an installation creates. - **[API Reference](docs/api-reference.md):** Official API documentation links for all services in the stack. diff --git a/bin/cli.sh b/bin/cli.sh index 7a0d091..d9f0fd6 100644 --- a/bin/cli.sh +++ b/bin/cli.sh @@ -769,7 +769,11 @@ show_config() { echo " VPN type: ${VPN_TYPE:-openvpn}" echo " Timezone: ${TZ:-UTC}" if type quality_tier >/dev/null 2>&1; then - echo " Quality: $(quality_tier)" + if [ "$(quality_tier)" = "any" ]; then + echo " Quality: any" + else + echo " Quality: $(quality_tier) / $(quality_source)" + fi fi if [ "${VPN_ENABLED:-n}" = "y" ]; then echo " VPN secrets: $INSTALL_DIR/secrets/" diff --git a/bin/setup.sh b/bin/setup.sh index d39c672..0559161 100644 --- a/bin/setup.sh +++ b/bin/setup.sh @@ -557,6 +557,7 @@ VPN_ENABLED="${setup_vpn,,}" VPN_TYPE="${vpn_type:-openvpn}" TZ="$tz" QUALITY_TIER="$(quality_tier)" +QUALITY_SOURCE="$(quality_source)" SEERR_IS_4K="$(quality_seerr_is_4k)" SUBTITLE_LANGUAGE="${subtitle_language:-}" SETUP_MODE="${SETUP_MODE:-manual}" @@ -656,7 +657,11 @@ else echo " VPN: DISABLED" fi echo " Media service: $media_service (port $media_service_port)" -echo " Quality profile: $QUALITY_TIER (4K=$seerr_is_4k)" +if [ "$QUALITY_TIER" = "any" ]; then + echo " Quality profile: any" +else + echo " Quality profile: $QUALITY_TIER / ${QUALITY_SOURCE:-bluray} (4K=$seerr_is_4k)" +fi echo " Subtitle language: ${subtitle_language:-en (Bazarr default)}" if [ "${opensubtitles_enabled:-n}" = "y" ]; then echo " OpenSubtitles.com: yes (username=${opensubtitles_username})" diff --git a/compose/base.yaml b/compose/base.yaml index 1f36fc5..82f8c58 100644 --- a/compose/base.yaml +++ b/compose/base.yaml @@ -177,7 +177,7 @@ services: # Seerr — media request management (successor to Jellyseerr/Overseerr) # Host port 5055 is published by seerr-gateway (not seerr) so DELETE /request - # can cascade into media file purge. Seerr stays on the Docker network only. + # can cancel in-flight *arr/qB grabs. Seerr stays on the Docker network only. # Retirement: see docs/seerr-delete-request.md seerr: image: ghcr.io/seerr-team/seerr:v3.4.1 @@ -201,7 +201,7 @@ services: assemblrr_network: ipv4_address: 172.60.0.17 - # Thin reverse proxy in front of Seerr: pass-through + delete-request purge. + # Thin reverse proxy in front of Seerr: pass-through + delete-request queue drain. # TV: season-scoped via Sonarr when the request is a subset of remaining seasons. # SEERR_DELETE_REQUEST_PURGE=0 disables intercept (stock Seerr semantics). seerr-gateway: diff --git a/docs/trash-guides.md b/docs/trash-guides.md index 8d6d3dc..d0ef012 100644 --- a/docs/trash-guides.md +++ b/docs/trash-guides.md @@ -4,13 +4,24 @@ assemblrr uses [Recyclarr](https://recyclarr.dev/) to sync [TRaSH Guides](https: **Subtitles:** Bazarr is wired separately (not via Recyclarr). On first install and every `assemblrr upgrade`, assemblrr applies [TRaSH Bazarr suggested scoring](https://trash-guides.info/Bazarr/Bazarr-suggested-scoring/) (series min score 90, movies 80, auto-sync thresholds 96/86). Subtitle providers are chosen interactively from the running Bazarr image (fzf multi-select; nothing enabled unless you pick it). OpenSubtitles.com is enabled only when you saved credentials during setup. -**Both resolutions are always installed** as assemblrr-named profiles (movies: **assemblrr HD Bluray + WEB** + **assemblrr UHD Bluray + WEB**; TV: **assemblrr WEB-1080p** + **assemblrr WEB-2160p**). Setup and `config edit` ask once. That choice is the default for **Radarr, Sonarr, and Seerr**: +**Both resolutions and both movie sources are always installed** as assemblrr-named profiles: -- **Ultra-HD (4K):** movies → UHD Bluray + WEB, TV → WEB-2160p -- **1080p:** movies → HD Bluray + WEB, TV → WEB-1080p -- **Any:** stock *arr Any +- Movies: **assemblrr HD Bluray + WEB**, **assemblrr UHD Bluray + WEB**, **assemblrr WEB-1080p**, **assemblrr WEB-2160p** +- TV: **assemblrr WEB-1080p**, **assemblrr WEB-2160p** -The chosen profile is written over *arr’s stock **Any** slot (id 1) so Add Movie / Add Series opens on it. The other assemblrr profile stays in the dropdown. Titles already in the library keep whatever profile they have. Stock *arr profiles (HD-1080p, …) still appear; that is normal. +TRaSH has no first-class WEB-only Radarr profile. Movie WEB packs reuse the HD/UHD Bluray + WEB trash IDs as Recyclarr variants, with qualities overridden so Blu-ray is disabled and cutoff is WEB. All four stay in the Radarr/Seerr dropdown; setup only picks the default. + +Setup and `config edit` ask once for resolution, then (unless you chose Any) for movie source. That pair is the default for **Radarr, Sonarr, and Seerr**: + +- **Ultra-HD (4K) + Bluray + WEB:** movies → UHD Bluray + WEB, TV → WEB-2160p +- **Ultra-HD (4K) + WEB:** movies → WEB-2160p, TV → WEB-2160p +- **1080p + Bluray + WEB:** movies → HD Bluray + WEB, TV → WEB-1080p +- **1080p + WEB:** movies → WEB-1080p, TV → WEB-1080p +- **Any:** stock *arr Any (movie source is ignored) + +Missing `QUALITY_SOURCE` on an older install means **bluray** (the previous default). TV is always WEB; TRaSH’s English Sonarr defaults are WEB-only. + +The chosen profile is written over *arr’s stock **Any** slot (id 1) so Add Movie / Add Series opens on it. The other assemblrr profiles stay in the dropdown. Titles already in the library keep whatever profile they have. Stock *arr profiles (HD-1080p, …) still appear; that is normal. assemblrr deliberately **does not** apply TRaSH quality min-size limits (they can reject smaller legitimate releases), and softens hard-block custom formats (LQ / x265 / 3D scores set to 0). Tier preferences from the guides still apply when better releases exist. diff --git a/lib/arr.sh b/lib/arr.sh index 523157d..a85de34 100644 --- a/lib/arr.sh +++ b/lib/arr.sh @@ -689,6 +689,15 @@ arr_promote_quality_profile() { return 0 fi + # Recyclarr variants share a trash_id. Overwriting id 1 with a sibling + # makes Recyclarr treat that as a rename and the other profile vanishes. + local id1_name + id1_name=$(api_get "$port" "/api/v3/qualityprofile/1" "$apikey" | jq -r '.name // empty') + if [ -n "$id1_name" ] && [ "$id1_name" != "Any" ] && [ "$id1_name" != "$src_name" ]; then + log_step "${service_name}: Add New slot stays ${id1_name}; default is ${src_name} (id ${src_id})" + return 1 + fi + local src dest tmp_name tmp_payload code src=$(api_get "$port" "/api/v3/qualityprofile/${src_id}" "$apikey") if [ -z "$src" ] || ! echo "$src" | jq -e '.id' >/dev/null 2>&1; then diff --git a/lib/config_edit.sh b/lib/config_edit.sh index 5702529..d959489 100644 --- a/lib/config_edit.sh +++ b/lib/config_edit.sh @@ -308,8 +308,10 @@ _config_edit_profile() { configure_quality_profile quality_sync_exports config_set_kv "$(_config_edit_runtime_file)" "QUALITY_TIER" "$QUALITY_TIER" + config_set_kv "$(_config_edit_runtime_file)" "QUALITY_SOURCE" "$QUALITY_SOURCE" config_set_kv "$(_config_edit_runtime_file)" "SEERR_IS_4K" "$SEERR_IS_4K" config_unset_kv "$(_config_edit_runtime_file)" "SEERR_DEFAULT_PROFILE" + configure_recyclarr || true if [ -n "${RADARR_API_KEY:-}" ]; then set_default_quality_profile "Radarr" "7878" "$RADARR_API_KEY" "lookup_radarr_profile" || true fi diff --git a/lib/managed_files.sh b/lib/managed_files.sh index f377a0f..51cf9bb 100644 --- a/lib/managed_files.sh +++ b/lib/managed_files.sh @@ -38,6 +38,8 @@ compose/sidecars/media-purge-watch.Dockerfile|compose/sidecars/media-purge-watch templates/recyclarr/recyclarr.yml|templates/recyclarr/recyclarr.yml templates/recyclarr/includes/radarr-hd.yml|templates/recyclarr/includes/radarr-hd.yml templates/recyclarr/includes/radarr-uhd.yml|templates/recyclarr/includes/radarr-uhd.yml +templates/recyclarr/includes/radarr-web-1080.yml|templates/recyclarr/includes/radarr-web-1080.yml +templates/recyclarr/includes/radarr-web-2160.yml|templates/recyclarr/includes/radarr-web-2160.yml templates/recyclarr/includes/radarr-soft-cfs.yml|templates/recyclarr/includes/radarr-soft-cfs.yml templates/recyclarr/includes/sonarr-web-1080.yml|templates/recyclarr/includes/sonarr-web-1080.yml templates/recyclarr/includes/sonarr-web-2160.yml|templates/recyclarr/includes/sonarr-web-2160.yml diff --git a/lib/prompts.sh b/lib/prompts.sh index 9ad9844..8a18fb0 100644 --- a/lib/prompts.sh +++ b/lib/prompts.sh @@ -63,8 +63,8 @@ configure_quality_profile() { ui_intro \ "What default quality should movies and TV use (Radarr, Sonarr, and Seerr)?" \ "Change the default quality on Radarr, Sonarr, and Seerr." - echo " 1) Ultra-HD (4K — movies: assemblrr UHD Bluray + WEB, TV: assemblrr WEB-2160p)" - echo " 2) 1080p (movies: assemblrr HD Bluray + WEB, TV: assemblrr WEB-1080p)" + echo " 1) Ultra-HD (4K — TV: assemblrr WEB-2160p)" + echo " 2) 1080p (TV: assemblrr WEB-1080p)" echo " 3) Any (stock *arr profile — no quality preference)" while true; do @@ -79,13 +79,45 @@ configure_quality_profile() { esac done + QUALITY_SOURCE="bluray" + if [ "$QUALITY_TIER" != "any" ]; then + echo + echo " Movies: WEB only, or allow Blu-ray upgrades?" + echo " (TV stays WEB. TRaSH has no English Blu-ray TV default.)" + echo " 1) WEB only (smaller files; no Blu-ray upgrades)" + echo " 2) Bluray + WEB (upgrades WEB to a Blu-ray encode when one exists)" + while true; do + read -p "Choose movie source [2]: " source_choice + source_choice=${source_choice:-2} + case "$source_choice" in + 1) QUALITY_SOURCE="web"; break ;; + 2) QUALITY_SOURCE="bluray"; break ;; + *) log_warning "Invalid choice. Please choose 1 or 2." ;; + esac + done + fi + seerr_is_4k="false" [ "$QUALITY_TIER" = "uhd" ] && seerr_is_4k="true" - export QUALITY_TIER seerr_is_4k + export QUALITY_TIER QUALITY_SOURCE seerr_is_4k case "$QUALITY_TIER" in - uhd) log_success "Quality: Ultra-HD (4K) for movies and TV" ;; - hd) log_success "Quality: 1080p for movies and TV" ;; - *) log_success "Quality: Any" ;; + uhd) + if [ "$QUALITY_SOURCE" = "web" ]; then + log_success "Quality: Ultra-HD (4K) WEB for movies and TV" + else + log_success "Quality: Ultra-HD (4K) (movies: Bluray + WEB, TV: WEB)" + fi + ;; + hd) + if [ "$QUALITY_SOURCE" = "web" ]; then + log_success "Quality: 1080p WEB for movies and TV" + else + log_success "Quality: 1080p (movies: Bluray + WEB, TV: WEB)" + fi + ;; + *) + log_success "Quality: Any" + ;; esac } diff --git a/lib/quality.sh b/lib/quality.sh index 103f4ee..ca285f4 100644 --- a/lib/quality.sh +++ b/lib/quality.sh @@ -1,7 +1,9 @@ #!/bin/bash # One quality choice for Radarr, Sonarr, and Seerr. # Canonical: QUALITY_TIER=uhd|hd|any +# QUALITY_SOURCE=web|bluray (movies only; TV is always WEB) # Older installs only have SEERR_IS_4K / SEERR_DEFAULT_PROFILE (stock *arr ids). +# Missing QUALITY_SOURCE means bluray (legacy HD/UHD Bluray + WEB defaults). if [ -n "${_ASSEMBLRR_QUALITY_SOURCED:-}" ]; then return 0 @@ -26,6 +28,17 @@ quality_tier() { fi } +# Movies: web = WEB-only (no Blu-ray upgrades). bluray = TRaSH Bluray + WEB. +quality_source() { + case "${QUALITY_SOURCE:-}" in + web|bluray) + echo "$QUALITY_SOURCE" + return 0 + ;; + esac + echo bluray +} + quality_seerr_is_4k() { if [ "$(quality_tier)" = "uhd" ]; then echo true @@ -46,6 +59,8 @@ quality_profile_names() { uhd) if [ "$kind" = "sonarr" ]; then printf '%s\n' "assemblrr WEB-2160p|Ultra-HD" + elif [ "$(quality_source)" = "web" ]; then + printf '%s\n' "assemblrr WEB-2160p|Ultra-HD" else printf '%s\n' "assemblrr UHD Bluray + WEB|Ultra-HD" fi @@ -53,6 +68,8 @@ quality_profile_names() { hd) if [ "$kind" = "sonarr" ]; then printf '%s\n' "assemblrr WEB-1080p|HD-1080p" + elif [ "$(quality_source)" = "web" ]; then + printf '%s\n' "assemblrr WEB-1080p|HD-1080p" else printf '%s\n' "assemblrr HD Bluray + WEB|HD-1080p" fi @@ -65,8 +82,9 @@ quality_profile_names() { quality_sync_exports() { QUALITY_TIER="$(quality_tier)" + QUALITY_SOURCE="$(quality_source)" SEERR_IS_4K="$(quality_seerr_is_4k)" - export QUALITY_TIER SEERR_IS_4K + export QUALITY_TIER QUALITY_SOURCE SEERR_IS_4K } # stdin: JSON array of {id,name} diff --git a/scripts/media-purge.sh b/scripts/media-purge.sh index 8cb7a5b..d541c81 100755 --- a/scripts/media-purge.sh +++ b/scripts/media-purge.sh @@ -505,26 +505,36 @@ arr_queue_hashes() { local endpoint raw if [ "$kind" = "movie" ]; then endpoint="/api/v3/queue?pageSize=250&movieId=${id}" + raw=$(arr_get "$base" "$key" "$endpoint") + echo "$raw" | jq -r --argjson id "$id" ' + if type == "array" then .[] + elif type == "object" then .records[]? + else empty end + | select((.movieId // empty) == ($id|tonumber)) + | .downloadId // .data.torrentInfoHash // empty + ' 2>/dev/null | tr 'A-F' 'a-f' | sort -u else endpoint="/api/v3/queue?pageSize=250&seriesId=${id}" + raw=$(arr_get "$base" "$key" "$endpoint") + echo "$raw" | jq -r --argjson id "$id" ' + if type == "array" then .[] + elif type == "object" then .records[]? + else empty end + | select((.seriesId // empty) == ($id|tonumber)) + | .downloadId // .data.torrentInfoHash // empty + ' 2>/dev/null | tr 'A-F' 'a-f' | sort -u fi - raw=$(arr_get "$base" "$key" "$endpoint") - echo "$raw" | jq -r ' - if type == "array" then .[] - elif type == "object" then .records[]? - else empty end - | .downloadId // .data.torrentInfoHash // empty - ' 2>/dev/null | tr 'A-F' 'a-f' | sort -u } arr_queue_hashes_seasons() { local base="$1" key="$2" id="$3" seasons_json="$4" local raw raw=$(arr_get "$base" "$key" "/api/v3/queue?pageSize=250&seriesId=${id}") - echo "$raw" | jq -r --argjson seasons "$seasons_json" ' + echo "$raw" | jq -r --argjson id "$id" --argjson seasons "$seasons_json" ' if type == "array" then .[] elif type == "object" then .records[]? else empty end + | select((.seriesId // empty) == ($id|tonumber)) | . as $r | ( $r.episode.seasonNumber @@ -676,6 +686,9 @@ arr_id_for_path() { local base="$1" key="$2" kind="$3" path="$4" local b json b=$(basename_of "$path") + case "$b" in + movies|tv|media|torrents|incomplete|data|""|.) return 0 ;; + esac if [ "$kind" = "movie" ]; then json=$(arr_get "$base" "$key" "/api/v3/movie") echo "$json" | jq -r --arg p "$path" --arg b "$b" ' diff --git a/scripts/seerr-gateway.py b/scripts/seerr-gateway.py index 2b2c74e..47d3efc 100755 --- a/scripts/seerr-gateway.py +++ b/scripts/seerr-gateway.py @@ -6,7 +6,7 @@ Stock Seerr DELETE /api/v1/request/:id only removes the request row. assemblrr intercepts that call (when enabled): * Movies (and TV requests that cover every remaining season): drain the - *arr download queue (removeFromClient) first, then DELETE + *arr download queue (removeFromClient) for this title first, then DELETE /api/v1/media/:id/file → Radarr/Sonarr deleteFiles + purge hooks. * TV requests for a subset of seasons: drain only those seasons' queue items, then delete those seasons' episode files via Sonarr and unmonitor @@ -440,10 +440,26 @@ def drain_arr_queue( considered = 0 req = _radarr_request if kind == "movie" else _sonarr_request for row in rows: - if wanted is not None: - sn = queue_record_season(row) - if sn is None or sn not in wanted: - continue + if kind == "movie": + mid = row.get("movieId") + if mid is not None: + try: + if int(mid) != int(arr_id): + continue + except (TypeError, ValueError): + continue + elif kind == "series": + sid = row.get("seriesId") + if sid is not None: + try: + if int(sid) != int(arr_id): + continue + except (TypeError, ValueError): + continue + if wanted is not None: + sn = queue_record_season(row) + if sn is None or sn not in wanted: + continue qid = row.get("id") if qid is None: continue @@ -700,7 +716,6 @@ def purge_then_delete_request( payload = parse_request_payload(get_body) media_id, is4k = media_ids_from_request(payload) elif get_status in (401, 403): - # Auth failed — surface upstream response; do not delete. return get_status, [("Content-Type", "application/json")], get_body, "auth_failed" else: log.warning("GET /api/v1/request/%s → HTTP %s (continuing with request delete)", request_id, get_status) @@ -719,7 +734,6 @@ def purge_then_delete_request( try: series_id = sonarr_lookup_series_id(payload, api_key) if series_id is None: - # Not in Sonarr — drop the request only (under-delete). log.info("request %s: series not in Sonarr; request-delete only", request_id) purge_note = "sonarr_series_missing" else: @@ -750,15 +764,15 @@ def purge_then_delete_request( qnote = _drain_queue_note( "series", series_id, api_key, None, request_id ) - purge_note, _ = _delete_media_file(media_id, is4k, headers) - purge_note = f"{qnote};{purge_note}" + pnote, _ = _delete_media_file(media_id, is4k, headers) + purge_note = f"{qnote};{pnote}" except Exception as exc: log.error("request %s: season purge failed: %s", request_id, exc) return _season_purge_fail(str(exc), "season_purge_failed") else: qnote = _drain_movie_queue_note(payload, request_id) - purge_note, _ = _delete_media_file(media_id, is4k, headers) - purge_note = f"{qnote};{purge_note}" if qnote else purge_note + pnote, _ = _delete_media_file(media_id, is4k, headers) + purge_note = f"{qnote};{pnote}" if qnote else pnote else: log.info("request %s: no linked media id; deleting request only", request_id) @@ -1134,11 +1148,17 @@ def _reset_mock_sonarr() -> None: "downloadId": "bbb", "episode": {"seasonNumber": 2}, }, + { + "id": 203, + "seriesId": 11, + "downloadId": "ccc", + "episode": {"seasonNumber": 1}, + }, ] class _MockRadarr(BaseHTTPRequestHandler): - """Radarr stand-in: movie 1 with one queue item unless deleted.""" + """Radarr stand-in: movie 1 with queue item 99 and movie 2 with queue item 100.""" protocol_version = "HTTP/1.1" calls: List[str] = [] @@ -1183,9 +1203,11 @@ def _reset_mock_radarr() -> None: _MockRadarr.calls = [] _MockRadarr.movies = [ {"id": 1, "tmdbId": 10378, "title": "Big Buck Bunny"}, + {"id": 2, "tmdbId": 1726, "title": "Iron Man"}, ] _MockRadarr.queue = [ {"id": 99, "movieId": 1, "downloadId": "abc123"}, + {"id": 100, "movieId": 2, "downloadId": "iron456"}, ] @@ -1305,11 +1327,14 @@ def self_test() -> int: any(c.startswith("DELETE /api/v3/queue/99") for c in radarr_calls), "movie queue item removed from download client", ) + check( + not any(c.startswith("DELETE /api/v3/queue/100") for c in radarr_calls), + "other movie queue item left alone", + ) check( "queue_movie:1:1" in (hdrs.get("X-Assemblrr-Purge-Detail") or ""), f"purge detail notes queue drain ({hdrs.get('X-Assemblrr-Purge-Detail')})", ) - # Order: GET, media file, request delete try: i_get = next(i for i, c in enumerate(calls) if c.startswith("GET /api/v1/request/42")) i_file = next(i for i, c in enumerate(calls) if "DELETE /api/v1/media/7/file" in c) @@ -1443,6 +1468,10 @@ def self_test() -> int: not any(c == "DELETE /api/v3/queue/202" for c in _MockSonarr.calls), "TV S01 leaves S02 queue item", ) + check( + not any(c == "DELETE /api/v3/queue/203" for c in _MockSonarr.calls), + "TV S01 leaves other series queue item", + ) check( "seasons_deleted" in (hdrs.get("X-Assemblrr-Purge-Detail") or ""), f"purge detail is season-scoped ({hdrs.get('X-Assemblrr-Purge-Detail')})", @@ -1584,6 +1613,10 @@ def self_test() -> int: and any(c == "DELETE /api/v3/queue/202" for c in _MockSonarr.calls), "TV all-seasons drains every series queue item", ) + check( + not any(c == "DELETE /api/v3/queue/203" for c in _MockSonarr.calls), + "TV all-seasons leaves other series queue item", + ) tv_s01 = { "id": 8, diff --git a/templates/recyclarr/includes/radarr-web-1080.yml b/templates/recyclarr/includes/radarr-web-1080.yml new file mode 100644 index 0000000..c51d3d0 --- /dev/null +++ b/templates/recyclarr/includes/radarr-web-1080.yml @@ -0,0 +1,32 @@ +# Include: Radarr 1080p WEB-only (HD Bluray + WEB trash_id, WEB cutoff) + +quality_profiles: + - trash_id: d1d67249d3890e49bc12e275d989a7e9 # HD Bluray + WEB + name: assemblrr WEB-1080p + reset_unmatched_scores: + enabled: true + min_format_score: -1000 + upgrade: + allowed: true + until_quality: WEB 1080p + until_score: 10000 + qualities: + - name: WEB 1080p + qualities: + - WEBRip-1080p + - WEBDL-1080p + - name: Bluray-1080p + enabled: false + - name: Bluray-720p + enabled: false + +custom_formats: + - trash_ids: + - 90a6f9a284dff5103f6346090e6280c8 # LQ + - e204b80c87be9497a8a6eaff48f72905 # LQ (Release Title) + - dc98083864ea246d05a42df0d05f81cc # x265 (HD) + - 839bea857ed2c0a8e084f3cbdbd65ecb # x265 (no HDR/DV) + - b8cd450cbfa689c0259a01d9e29ba3d6 # 3D + assign_scores_to: + - name: assemblrr WEB-1080p + score: 0 diff --git a/templates/recyclarr/includes/radarr-web-2160.yml b/templates/recyclarr/includes/radarr-web-2160.yml new file mode 100644 index 0000000..1289ba0 --- /dev/null +++ b/templates/recyclarr/includes/radarr-web-2160.yml @@ -0,0 +1,30 @@ +# Include: Radarr 4K WEB-only (UHD Bluray + WEB trash_id, WEB cutoff) + +quality_profiles: + - trash_id: 64fb5f9858489bdac2af690e27c8f42f # UHD Bluray + WEB + name: assemblrr WEB-2160p + reset_unmatched_scores: + enabled: true + min_format_score: -1000 + upgrade: + allowed: true + until_quality: WEB 2160p + until_score: 10000 + qualities: + - name: WEB 2160p + qualities: + - WEBRip-2160p + - WEBDL-2160p + - name: Bluray-2160p + enabled: false + +custom_formats: + - trash_ids: + - 90a6f9a284dff5103f6346090e6280c8 # LQ + - e204b80c87be9497a8a6eaff48f72905 # LQ (Release Title) + - dc98083864ea246d05a42df0d05f81cc # x265 (HD) + - 839bea857ed2c0a8e084f3cbdbd65ecb # x265 (no HDR/DV) + - b8cd450cbfa689c0259a01d9e29ba3d6 # 3D + assign_scores_to: + - name: assemblrr WEB-2160p + score: 0 diff --git a/templates/recyclarr/recyclarr.yml b/templates/recyclarr/recyclarr.yml index 1c5253d..ab7cc01 100644 --- a/templates/recyclarr/recyclarr.yml +++ b/templates/recyclarr/recyclarr.yml @@ -1,7 +1,8 @@ # yaml-language-server: $schema=https://schemas.recyclarr.dev/v8/config-schema.json # Root: instance URLs/keys + include list. Profile packs are under includes/. # All packs listed here are synced; the default (movies + TV) is chosen at setup. -# See README "Quality Profiles & TRaSH Guides". +# Movie WEB packs are Recyclarr variants of the HD/UHD Bluray + WEB trash IDs. +# See docs/trash-guides.md. radarr: radarr-instance: @@ -11,6 +12,8 @@ radarr: include: - config: radarr-hd.yml - config: radarr-uhd.yml + - config: radarr-web-1080.yml + - config: radarr-web-2160.yml - config: radarr-soft-cfs.yml sonarr: diff --git a/tests/unit/test_arr_quality.sh b/tests/unit/test_arr_quality.sh index 325f26e..dd019af 100644 --- a/tests/unit/test_arr_quality.sh +++ b/tests/unit/test_arr_quality.sh @@ -42,6 +42,8 @@ assert_true "sets root-folder default" "grep -q defaultQualityProfileId \"$src\" assert_true "updates import lists" "grep -q '/api/v3/importlist/' \"$src\"" assert_true "promotes assemblrr profile to id 1" "grep -q 'arr_promote_quality_profile' \"$src\"" assert_true "writes qualityprofile/1" "grep -q '/api/v3/qualityprofile/1' \"$src\"" +assert_contains "$(sed -n '/^arr_promote_quality_profile()/,/^}/p' "$src")" \ + 'id1_name' "promote does not overwrite a sibling assemblrr profile" assert_not_contains "$apply" '"all"' "does not remap the whole library" assert_not_contains "$apply" "any-only" "does not remap titles still on Any" assert_contains "$apply" "quality_wants_named_profile" "named-profile check uses the tier" diff --git a/tests/unit/test_config_edit.sh b/tests/unit/test_config_edit.sh index 3c3a6be..065a719 100644 --- a/tests/unit/test_config_edit.sh +++ b/tests/unit/test_config_edit.sh @@ -76,6 +76,11 @@ assert_contains "$profile_line" "Radarr" "profile catalog mentions Radarr" assert_contains "$profile_line" "Sonarr" "profile catalog mentions Sonarr" assert_contains "$profile_line" "Seerr" "profile catalog mentions Seerr" +test_suite "profile edit persists QUALITY_SOURCE and resyncs Recyclarr" +profile_fn=$(sed -n '/^_config_edit_profile()/,/^}/p' "$REPO_ROOT/lib/config_edit.sh") +assert_contains "$profile_fn" 'QUALITY_SOURCE' "writes QUALITY_SOURCE" +assert_contains "$profile_fn" "configure_recyclarr" "resyncs Recyclarr so WEB packs exist" + test_suite "vpn edit chmods only vpn secret files" vpn_fn=$(sed -n '/^_config_edit_vpn()/,/^}/p' "$REPO_ROOT/lib/config_edit.sh") assert_not_contains "$vpn_fn" 'chmod 600 "$secrets_dir"/*.txt' "vpn edit does not chmod every secret" diff --git a/tests/unit/test_quality.sh b/tests/unit/test_quality.sh index 34cfdb0..661effc 100644 --- a/tests/unit/test_quality.sh +++ b/tests/unit/test_quality.sh @@ -39,17 +39,39 @@ assert_eq "any" "$(quality_tier)" "stock id 1 → any" unset SEERR_IS_4K SEERR_DEFAULT_PROFILE assert_eq "any" "$(quality_tier)" "empty config → any" +test_suite "quality_source defaults to bluray" +unset QUALITY_SOURCE +assert_eq "bluray" "$(quality_source)" "missing QUALITY_SOURCE → bluray" +QUALITY_SOURCE=web +assert_eq "web" "$(quality_source)" "QUALITY_SOURCE=web" +QUALITY_SOURCE=bluray +assert_eq "bluray" "$(quality_source)" "QUALITY_SOURCE=bluray" +QUALITY_SOURCE=nope +assert_eq "bluray" "$(quality_source)" "invalid QUALITY_SOURCE → bluray" +unset QUALITY_SOURCE + test_suite "quality_profile_names follow the same tier" QUALITY_TIER=uhd -assert_eq "assemblrr UHD Bluray + WEB|Ultra-HD" "$(quality_profile_names radarr)" "uhd movies" +assert_eq "assemblrr UHD Bluray + WEB|Ultra-HD" "$(quality_profile_names radarr)" "uhd movies (legacy/bluray)" assert_eq "assemblrr WEB-2160p|Ultra-HD" "$(quality_profile_names sonarr)" "uhd tv" QUALITY_TIER=hd -assert_eq "assemblrr HD Bluray + WEB|HD-1080p" "$(quality_profile_names radarr)" "hd movies" +assert_eq "assemblrr HD Bluray + WEB|HD-1080p" "$(quality_profile_names radarr)" "hd movies (legacy/bluray)" assert_eq "assemblrr WEB-1080p|HD-1080p" "$(quality_profile_names sonarr)" "hd tv" QUALITY_TIER=any assert_eq "Any|" "$(quality_profile_names radarr)" "any movies" assert_eq "Any|" "$(quality_profile_names sonarr)" "any tv" +test_suite "quality_profile_names WEB movie source" +QUALITY_TIER=uhd QUALITY_SOURCE=web +assert_eq "assemblrr WEB-2160p|Ultra-HD" "$(quality_profile_names radarr)" "uhd web movies" +assert_eq "assemblrr WEB-2160p|Ultra-HD" "$(quality_profile_names sonarr)" "uhd web tv still WEB" +QUALITY_TIER=hd QUALITY_SOURCE=web +assert_eq "assemblrr WEB-1080p|HD-1080p" "$(quality_profile_names radarr)" "hd web movies" +assert_eq "assemblrr WEB-1080p|HD-1080p" "$(quality_profile_names sonarr)" "hd web tv still WEB" +QUALITY_TIER=any QUALITY_SOURCE=web +assert_eq "Any|" "$(quality_profile_names radarr)" "any ignores movie source" +unset QUALITY_SOURCE + test_suite "quality_seerr_is_4k / quality_wants_named_profile" QUALITY_TIER=uhd assert_eq "true" "$(quality_seerr_is_4k)" "uhd is 4K" @@ -81,8 +103,37 @@ assert_not_contains "$prompt" "SETUP_MODE" "express does not skip the question" assert_contains "$prompt" "Radarr, Sonarr, and Seerr" "question names all three" assert_contains "$prompt" "WEB-2160p" "lists the 4K TV profile" assert_contains "$prompt" "WEB-1080p" "lists the 1080p TV profile" +assert_contains "$prompt" "QUALITY_SOURCE" "asks movie source" +assert_contains "$prompt" "WEB only" "offers WEB-only movies" +assert_contains "$prompt" "Bluray + WEB" "offers Bluray + WEB movies" +assert_contains "$prompt" "source_choice:-2" "Bluray + WEB is the default" assert_not_contains "$prompt" 'seerr_default_profile="5"' "does not store stock profile ids" +test_suite "recyclarr movie WEB packs are variants of Bluray + WEB" +root="$REPO_ROOT/templates/recyclarr" +assert_contains "$(cat "$root/recyclarr.yml")" "radarr-web-1080.yml" "root includes WEB-1080p pack" +assert_contains "$(cat "$root/recyclarr.yml")" "radarr-web-2160.yml" "root includes WEB-2160p pack" +hd_web=$(cat "$root/includes/radarr-web-1080.yml") +uhd_web=$(cat "$root/includes/radarr-web-2160.yml") +assert_contains "$hd_web" "d1d67249d3890e49bc12e275d989a7e9" "1080p WEB reuses HD Bluray + WEB trash_id" +assert_contains "$hd_web" "name: assemblrr WEB-1080p" "1080p WEB profile name" +assert_contains "$hd_web" "until_quality: WEB 1080p" "1080p cutoff is WEB" +assert_contains "$hd_web" "enabled: false" "1080p disables Blu-ray" +assert_contains "$uhd_web" "64fb5f9858489bdac2af690e27c8f42f" "2160p WEB reuses UHD Bluray + WEB trash_id" +assert_contains "$uhd_web" "name: assemblrr WEB-2160p" "2160p WEB profile name" +assert_contains "$uhd_web" "until_quality: WEB 2160p" "2160p cutoff is WEB" +soft=$(cat "$root/includes/radarr-soft-cfs.yml") +assert_contains "$soft" "assemblrr HD Bluray + WEB" "soft CFs score HD Bluray + WEB" +assert_not_contains "$soft" "assemblrr WEB-1080p" "bluray soft CFs do not name WEB-1080p" +assert_contains "$hd_web" "assemblrr WEB-1080p" "WEB-1080p pack scores itself" +assert_contains "$uhd_web" "assemblrr WEB-2160p" "WEB-2160p pack scores itself" + +test_suite "configure_recyclarr syncs every movie pack" +recyc=$(sed -n '/^configure_recyclarr()/,/^}/p' "$REPO_ROOT/lib/seerr.sh") +assert_not_contains "$recyc" "grep -vE" "does not drop HD or WEB movie packs" +assert_contains "$(cat "$REPO_ROOT/templates/recyclarr/recyclarr.yml")" "radarr-hd.yml" "root still includes HD Bluray + WEB" +assert_contains "$(cat "$REPO_ROOT/templates/recyclarr/recyclarr.yml")" "radarr-web-1080.yml" "root still includes WEB-1080p" + test_suite "sonarr and seerr follow the same flag" assert_contains "$(sed -n '/^lookup_sonarr_profile()/,/^}/p' "$REPO_ROOT/lib/arr.sh")" \ "lookup_arr_quality_profile" "sonarr uses shared lookup" diff --git a/tests/unit/test_upgrade.sh b/tests/unit/test_upgrade.sh index 8fcc925..d4157c2 100644 --- a/tests/unit/test_upgrade.sh +++ b/tests/unit/test_upgrade.sh @@ -21,6 +21,8 @@ assert_true "has lib/upgrade.sh" "echo \"\$list\" | grep -q 'lib/upgrade.sh|lib/ assert_true "has lib/services.sh" "echo \"\$list\" | grep -q 'lib/services.sh|lib/services.sh'" assert_true "has lib/config_edit.sh" "echo \"\$list\" | grep -q 'lib/config_edit.sh|lib/config_edit.sh'" assert_true "has lib/quality.sh" "echo \"\$list\" | grep -q 'lib/quality.sh|lib/quality.sh'" +assert_true "has radarr WEB-1080p pack" "echo \"\$list\" | grep -q 'radarr-web-1080.yml'" +assert_true "has radarr WEB-2160p pack" "echo \"\$list\" | grep -q 'radarr-web-2160.yml'" assert_true "has lib/ui.sh" "echo \"\$list\" | grep -q 'lib/ui.sh|lib/ui.sh'" assert_true "has compose/base.yaml" "echo \"\$list\" | grep -q 'compose/base.yaml|compose/base.yaml'" assert_true "has vpn-watchdog Dockerfile" "echo \"\$list\" | grep -q 'compose/sidecars/vpn-watchdog.Dockerfile'" @@ -34,8 +36,9 @@ assert_eq "el" "$(_bazarr_lang_code2 gre)" "gre → el" assert_eq "en" "$(_bazarr_lang_code2 '')" "empty → en" test_suite "migration 001 skip when custom.yaml has bazarr" +tmp="" tmp2="" tmp=$(mktemp -d) -trap 'rm -rf "$tmp" "$tmp2"' EXIT +trap 'rm -rf "${tmp:-}" "${tmp2:-}"' EXIT mkdir -p "$tmp/compose" cat >"$tmp/compose/custom.yaml" <<'EOF' services: