Skip to content

Commit 248235e

Browse files
duck-vpsclaude
andcommitted
fix: update VERSION constant to 6.0, add plex-staggered-scan.sh
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 8d02b79 commit 248235e

3 files changed

Lines changed: 66 additions & 16 deletions

File tree

dksubs-proxy.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
########################################################################
77

88
"""
9-
DKSubs NFO-Hunter Proxy v5.6
9+
DKSubs NFO-Hunter Proxy v6.0
1010
==============================
1111
Universal Translator: Extended-attr enrichment for both NFO and enrich-only
12-
indexers, plus v5.6 API-spend reduction layers (request dedup with
12+
indexers, plus v6.0 API-spend reduction layers (request dedup with
1313
single-flight lock, movie-verdict cache, cross-indexer release-name dedup +
1414
NFO early-exit, per-indexer NFO budget scaled by rolling hit-rate).
1515
16-
All v5.6 layers are individually env-flag gated, with DKSUBS_PROXY_V56_FEATURES=0
16+
All v6.0 layers are individually env-flag gated, with DKSUBS_PROXY_V56_FEATURES=0
1717
as the global kill switch that reverts to v5.5 behavior.
1818
"""
1919

@@ -42,7 +42,7 @@
4242
load_dotenv() # /app/.env when running under `docker compose` w/ env_file
4343
load_dotenv("/config/.env", override=True) # /config/.env when installed via Cosmos Market (bind mount)
4444

45-
VERSION = "5.6"
45+
VERSION = "6.0"
4646

4747
PROWLARR_URL = os.getenv("PROWLARR_URL", "http://Prowlarr:9696").rstrip("/")
4848
PROWLARR_API_KEY = os.getenv("PROWLARR_API_KEY", "")
@@ -116,7 +116,7 @@ def probe_score(title: str, indexer_id: str,
116116
Components:
117117
+ 5.0 for subs_from_title (NORDiC etc. matched the title)
118118
+ 3.0 for a strong multi-audio scene-group signal in the title
119-
+ indexer_hit_rate × 2.0 (existing v5.6 per-indexer score)
119+
+ indexer_hit_rate × 2.0 (existing v6.0 per-indexer score)
120120
- per-indexer cost penalty (default 1.0)
121121
"""
122122
score = 0.0
@@ -131,7 +131,7 @@ def probe_score(title: str, indexer_id: str,
131131

132132
DEBUG_LOGGING = os.getenv("DEBUG_LOGGING", os.getenv("DEBUG", "0")) == "1"
133133

134-
# ── v5.6 feature flags ───────────────────────────────────────────────────────
134+
# ── v6.0 feature flags ───────────────────────────────────────────────────────
135135
# All flags can be disabled individually by setting to 0/false. The global
136136
# DKSUBS_PROXY_V56_FEATURES kill switch overrides them all when set to 0.
137137

@@ -186,7 +186,7 @@ def _max_nfo_candidates(indexer_id: str) -> int:
186186
"requests_total": 0, "hunt_total": 0, "dk_hits": 0, "nfo_fetches": 0,
187187
"nfo_direct_fetches": 0, "nfo_direct_hits": 0,
188188
"cache_hits": 0, "cache_misses": 0, "upstream_errors": 0, "hunt_errors": 0,
189-
# v5.6 metrics
189+
# v6.0 metrics
190190
"dedup_hits": 0, "dedup_inflight_waits": 0,
191191
"verdict_suppressions": 0, "verdict_writes": 0,
192192
"indexer_score_demotions": 0, "nfo_early_exits": 0,
@@ -276,7 +276,7 @@ def log(msg: str, level: str = "INFO") -> None:
276276

277277
ATTR_DK_RE = re.compile(r"\b(danish|dansk|nordic|dan|da)\b", re.I)
278278

279-
# ── v5.6 Layer 3: release-name normalization for cross-indexer dedup ─────────
279+
# ── v6.0 Layer 3: release-name normalization for cross-indexer dedup ─────────
280280
_PROXY_TAG_RE = re.compile(r'\.(DKOK|DKaudio)\b', re.I)
281281
_EXT_RE = re.compile(r'\.(mkv|mp4|avi|nfo|nzb)$', re.I)
282282
_WS_RE = re.compile(r'\s+')

plex-staggered-scan.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
# Scan Plex libraries one at a time with a pause between each.
3+
# Prevents the SQLite busy-loop that occurs when all 21 libraries scan simultaneously.
4+
#
5+
# Usage: plex-staggered-scan.sh [pause_seconds] (default: 90)
6+
7+
set -euo pipefail
8+
9+
PAUSE=${1:-90}
10+
PLEX_URL="http://172.18.0.9:32400"
11+
PLEX_TOKEN=$(grep -oP 'PlexOnlineToken="\K[^"]*' \
12+
"/srv/config/plex/Library/Application Support/Plex Media Server/Preferences.xml")
13+
14+
sections=$(curl -sf "$PLEX_URL/library/sections?X-Plex-Token=$PLEX_TOKEN" \
15+
| python3 -c "
16+
import sys, xml.etree.ElementTree as ET
17+
root = ET.fromstring(sys.stdin.read())
18+
for d in root.findall('Directory'):
19+
print(d.get('key') + '|' + d.get('title','?'))
20+
")
21+
22+
total=$(echo "$sections" | wc -l)
23+
i=0
24+
25+
while IFS='|' read -r key title; do
26+
i=$((i+1))
27+
echo "[$i/$total] Scanning: $title (section $key)"
28+
curl -sf -X POST "$PLEX_URL/library/sections/$key/refresh?X-Plex-Token=$PLEX_TOKEN" >/dev/null
29+
30+
# Wait for this section's scan to finish before starting the next
31+
while true; do
32+
refreshing=$(curl -sf "$PLEX_URL/library/sections/$key?X-Plex-Token=$PLEX_TOKEN" \
33+
| python3 -c "
34+
import sys, xml.etree.ElementTree as ET
35+
root = ET.fromstring(sys.stdin.read())
36+
d = root.find('Directory') or root
37+
print(d.get('refreshing','0') if d.tag == 'Directory' else root.get('refreshing','0'))
38+
" 2>/dev/null || echo "0")
39+
[ "$refreshing" = "0" ] && break
40+
sleep 5
41+
done
42+
echo " Done."
43+
44+
if [ "$i" -lt "$total" ]; then
45+
echo " Pausing ${PAUSE}s before next section..."
46+
sleep "$PAUSE"
47+
fi
48+
done <<< "$sections"
49+
50+
echo "All $total sections scanned."

src/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""
2-
DKSubs NFO-Hunter Proxy v5.6
2+
DKSubs NFO-Hunter Proxy v6.0
33
==============================
44
Universal Translator: Extended-attr enrichment for both NFO and enrich-only
5-
indexers, plus v5.6 API-spend reduction layers (request dedup with
5+
indexers, plus v6.0 API-spend reduction layers (request dedup with
66
single-flight lock, movie-verdict cache, cross-indexer release-name dedup +
77
NFO early-exit, per-indexer NFO budget scaled by rolling hit-rate).
88
9-
All v5.6 layers are individually env-flag gated, with DKSUBS_PROXY_V56_FEATURES=0
9+
All v6.0 layers are individually env-flag gated, with DKSUBS_PROXY_V56_FEATURES=0
1010
as the global kill switch that reverts to v5.5 behavior.
1111
"""
1212

@@ -35,7 +35,7 @@
3535
load_dotenv() # /app/.env when running under `docker compose` w/ env_file
3636
load_dotenv("/config/.env", override=True) # /config/.env when installed via Cosmos Market (bind mount)
3737

38-
VERSION = "5.6"
38+
VERSION = "6.0"
3939

4040
PROWLARR_URL = os.getenv("PROWLARR_URL", "http://Prowlarr:9696").rstrip("/")
4141
PROWLARR_API_KEY = os.getenv("PROWLARR_API_KEY", "")
@@ -109,7 +109,7 @@ def probe_score(title: str, indexer_id: str,
109109
Components:
110110
+ 5.0 for subs_from_title (NORDiC etc. matched the title)
111111
+ 3.0 for a strong multi-audio scene-group signal in the title
112-
+ indexer_hit_rate × 2.0 (existing v5.6 per-indexer score)
112+
+ indexer_hit_rate × 2.0 (existing v6.0 per-indexer score)
113113
- per-indexer cost penalty (default 1.0)
114114
"""
115115
score = 0.0
@@ -124,7 +124,7 @@ def probe_score(title: str, indexer_id: str,
124124

125125
DEBUG_LOGGING = os.getenv("DEBUG_LOGGING", os.getenv("DEBUG", "0")) == "1"
126126

127-
# ── v5.6 feature flags ───────────────────────────────────────────────────────
127+
# ── v6.0 feature flags ───────────────────────────────────────────────────────
128128
# All flags can be disabled individually by setting to 0/false. The global
129129
# DKSUBS_PROXY_V56_FEATURES kill switch overrides them all when set to 0.
130130

@@ -179,7 +179,7 @@ def _max_nfo_candidates(indexer_id: str) -> int:
179179
"requests_total": 0, "hunt_total": 0, "dk_hits": 0, "nfo_fetches": 0,
180180
"nfo_direct_fetches": 0, "nfo_direct_hits": 0,
181181
"cache_hits": 0, "cache_misses": 0, "upstream_errors": 0, "hunt_errors": 0,
182-
# v5.6 metrics
182+
# v6.0 metrics
183183
"dedup_hits": 0, "dedup_inflight_waits": 0,
184184
"verdict_suppressions": 0, "verdict_writes": 0,
185185
"indexer_score_demotions": 0, "nfo_early_exits": 0,
@@ -269,7 +269,7 @@ def log(msg: str, level: str = "INFO") -> None:
269269

270270
ATTR_DK_RE = re.compile(r"\b(danish|dansk|nordic|dan|da)\b", re.I)
271271

272-
# ── v5.6 Layer 3: release-name normalization for cross-indexer dedup ─────────
272+
# ── v6.0 Layer 3: release-name normalization for cross-indexer dedup ─────────
273273
_PROXY_TAG_RE = re.compile(r'\.(DKOK|DKaudio)\b', re.I)
274274
_EXT_RE = re.compile(r'\.(mkv|mp4|avi|nfo|nzb)$', re.I)
275275
_WS_RE = re.compile(r'\s+')

0 commit comments

Comments
 (0)