feat(media): embed recyclarr config with codec scoring, enable qbittorrent auto-tmm

This commit is contained in:
2026-02-18 22:01:49 -05:00
parent b8b8dd58e1
commit ae6915c204
2 changed files with 135 additions and 4 deletions

View File

@@ -86,6 +86,11 @@
# how many connections per sec # how many connections per sec
ConnectionSpeed = 300; ConnectionSpeed = 300;
# Automatic Torrent Management: use category save paths for new torrents
DisableAutoTMMByDefault = false;
DisableAutoTMMTriggers.CategorySavePathChanged = false;
DisableAutoTMMTriggers.DefaultSavePathChanged = false;
ChokingAlgorithm = "RateBased"; ChokingAlgorithm = "RateBased";
PieceExtentAffinity = true; PieceExtentAffinity = true;
SuggestMode = true; SuggestMode = true;

View File

@@ -5,16 +5,141 @@
lib, lib,
... ...
}: }:
let
radarrPort = builtins.toString service_configs.ports.radarr;
sonarrPort = builtins.toString service_configs.ports.sonarr;
configTemplate = pkgs.writeText "recyclarr.yml" ''
radarr:
movies:
base_url: http://localhost:${radarrPort}
api_key: RADARR_API_KEY_PLACEHOLDER
include:
- template: radarr-quality-definition-movie
- template: radarr-quality-profile-remux-web-2160p
- template: radarr-custom-formats-remux-web-2160p
# Override template to also allow 1080p (2160p still prioritized via cutoff)
quality_profiles:
- name: Remux + WEB 2160p
upgrade:
allowed: true
until_quality: Remux-2160p
qualities:
- name: Remux-2160p
- name: WEB 2160p
qualities:
- WEBDL-2160p
- WEBRip-2160p
- name: Remux-1080p
- name: Bluray-1080p
- name: WEB 1080p
qualities:
- WEBDL-1080p
- WEBRip-1080p
- name: HDTV-1080p
custom_formats:
- trash_ids:
- bfd8eb01832d646a0a89c4deb46f8564 # Upscaled
assign_scores_to:
- name: Remux + WEB 2160p
score: -10000
# Codec preferences: allow x265/HEVC (override template -10000 penalties)
- trash_ids:
- dc98083864ea246d05a42df0d05f81cc # x265 (HD)
assign_scores_to:
- name: Remux + WEB 2160p
score: 0
- trash_ids:
- 839bea857ed2c0a8e084f3cbdbd65ecb # x265 (no HDR/DV)
assign_scores_to:
- name: Remux + WEB 2160p
score: 0
- trash_ids:
- cae4ca30163749b891686f95532519bd # AV1
assign_scores_to:
- name: Remux + WEB 2160p
score: 0
sonarr:
series:
base_url: http://localhost:${sonarrPort}
api_key: SONARR_API_KEY_PLACEHOLDER
include:
- template: sonarr-quality-definition-series
- template: sonarr-v4-quality-profile-web-2160p
- template: sonarr-v4-custom-formats-web-2160p
# Override template to also allow 1080p (2160p still prioritized via cutoff)
quality_profiles:
- name: WEB-2160p
upgrade:
allowed: true
until_quality: WEB 2160p
qualities:
- name: WEB 2160p
qualities:
- WEBDL-2160p
- WEBRip-2160p
- name: Bluray-1080p Remux
- name: Bluray-1080p
- name: WEB 1080p
qualities:
- WEBDL-1080p
- WEBRip-1080p
- name: HDTV-1080p
custom_formats:
- trash_ids:
- 23297a736ca77c0fc8e70f8edd7ee56c # Upscaled
assign_scores_to:
- name: WEB-2160p
score: -10000
# Codec preferences: allow x265/HEVC (override template -10000 penalties)
- trash_ids:
- 47435ece6b99a0b477caf360e79ba0bb # x265 (HD)
assign_scores_to:
- name: WEB-2160p
score: 0
- trash_ids:
- 9b64dff695c2115facf1b6ea59c9bd07 # x265 (no HDR/DV)
assign_scores_to:
- name: WEB-2160p
score: 0
- trash_ids:
- 15a05bc7c1a36e2b57fd628f8977e2fc # AV1
assign_scores_to:
- name: WEB-2160p
score: 0
'';
dataDir = service_configs.recyclarr.dataDir;
radarrConfig = "${service_configs.radarr.dataDir}/config.xml";
sonarrConfig = "${service_configs.sonarr.dataDir}/config.xml";
# Script to inject API keys from sonarr/radarr config.xml at runtime
generateConfig = pkgs.writeShellScript "recyclarr-generate-config" ''
RADARR_KEY=$(${pkgs.gnugrep}/bin/grep -oP '(?<=<ApiKey>)[^<]+' ${radarrConfig})
SONARR_KEY=$(${pkgs.gnugrep}/bin/grep -oP '(?<=<ApiKey>)[^<]+' ${sonarrConfig})
${pkgs.gnused}/bin/sed \
-e "s/RADARR_API_KEY_PLACEHOLDER/$RADARR_KEY/" \
-e "s/SONARR_API_KEY_PLACEHOLDER/$SONARR_KEY/" \
${configTemplate} > ${dataDir}/recyclarr.yml
'';
in
{ {
imports = [ imports = [
(lib.serviceMountWithZpool "recyclarr" service_configs.zpool_ssds [ (lib.serviceMountWithZpool "recyclarr" service_configs.zpool_ssds [
service_configs.recyclarr.dataDir dataDir
]) ])
]; ];
systemd.tmpfiles.rules = [ systemd.tmpfiles.rules = [
"d ${service_configs.recyclarr.dataDir} 0755 root root -" "d ${dataDir} 0755 root root -"
"d ${service_configs.recyclarr.dataDir}/data 0755 root root -" "d ${dataDir}/data 0755 root root -"
]; ];
systemd.services.recyclarr = { systemd.services.recyclarr = {
@@ -23,7 +148,8 @@
wants = [ "network-online.target" ]; wants = [ "network-online.target" ];
serviceConfig = { serviceConfig = {
Type = "oneshot"; Type = "oneshot";
ExecStart = "${pkgs.recyclarr}/bin/recyclarr sync --config ${service_configs.recyclarr.dataDir}/recyclarr.yml --app-data ${service_configs.recyclarr.dataDir}/data"; ExecStartPre = "${generateConfig}";
ExecStart = "${pkgs.recyclarr}/bin/recyclarr sync --config ${dataDir}/recyclarr.yml --app-data ${dataDir}/data";
}; };
}; };