Skip to content

Commit 17dc9c3

Browse files
committed
ci: execute v3 before precedence refinement
1 parent cabc34f commit 17dc9c3

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

scripts/tmp_apply_strict_content_fix_v4.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,27 @@
1111
raise RuntimeError('cannot load strict content fix v3')
1212
mod = importlib.util.module_from_spec(spec)
1313
spec.loader.exec_module(mod)
14+
mod.mod.main()
1415

15-
# Importing v3 executes its top-level patch sequence before this refinement.
16+
# v3's own post-processing runs only in its __main__ block, so reproduce the
17+
# episode-marker exemption here before refining precedence.
1618
path = ROOT / 'scripts' / 'nuvio_client_lab.cjs'
1719
text = path.read_text(encoding='utf-8')
20+
old_loop = """ for (const strongLabel of strongIdentityLabels) {
21+
const strongTokens = contentTokens(strongLabel);
22+
if (strongTokens.length >= 2 && expectedTokens.size && !strongTokens.some((token) => expectedTokens.has(token))) {
23+
"""
24+
new_loop = """ for (const strongLabel of strongIdentityLabels) {
25+
const carriesEpisodeIdentity = /(?:^|\\D)s(?:eason|aison)?\\s*0*\\d{1,3}\\s*[-_. ]*e(?:p(?:isode)?)?\\s*0*\\d{1,4}(?:\\D|$)/i.test(strongLabel)
26+
|| /(?:season|saison)\\s*0*\\d{1,3}/i.test(strongLabel)
27+
|| /(?:^|\\D)(?:episode|ep)\\s*0*\\d{1,4}(?:\\D|$)/i.test(strongLabel);
28+
if (carriesEpisodeIdentity) continue;
29+
const strongTokens = contentTokens(strongLabel);
30+
if (strongTokens.length >= 2 && expectedTokens.size && !strongTokens.some((token) => expectedTokens.has(token))) {
31+
"""
32+
if old_loop not in text:
33+
raise RuntimeError('strong identity loop missing after base patch')
34+
text = text.replace(old_loop, new_loop, 1)
1835
needle = """ const strongIdentityLabels = [stream?.title, stream?.filename, mediaFilename]
1936
.map((value) => String(value || '').trim())
2037
.filter(Boolean);
@@ -27,7 +44,7 @@
2744
for (const strongLabel of strongIdentityLabels) {
2845
"""
2946
if needle not in text:
30-
raise RuntimeError('strong identity block missing after v3 patch')
47+
raise RuntimeError('strong identity block missing after episode refinement')
3148
text = text.replace(needle, replacement, 1)
3249
late = " if (normalized && forbiddenAliases.some((alias) => normalized.includes(alias))) return { status: 'contradiction', reason: 'forbidden_title_alias' };\n if (normalized && expected.some((alias) => normalized.includes(alias))) return { status: 'match', reason: 'expected_title_alias' };\n"
3350
if late not in text:

0 commit comments

Comments
 (0)