Skip to content

Commit b8688bb

Browse files
committed
ci: fix v4 patch chaining
1 parent 17dc9c3 commit b8688bb

1 file changed

Lines changed: 2 additions & 19 deletions

File tree

scripts/tmp_apply_strict_content_fix_v4.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,11 @@
1010
if spec is None or spec.loader is None:
1111
raise RuntimeError('cannot load strict content fix v3')
1212
mod = importlib.util.module_from_spec(spec)
13+
# v3 applies the complete v2 patch and its episode-marker refinement at import.
1314
spec.loader.exec_module(mod)
14-
mod.mod.main()
1515

16-
# v3's own post-processing runs only in its __main__ block, so reproduce the
17-
# episode-marker exemption here before refining precedence.
1816
path = ROOT / 'scripts' / 'nuvio_client_lab.cjs'
1917
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)
3518
needle = """ const strongIdentityLabels = [stream?.title, stream?.filename, mediaFilename]
3619
.map((value) => String(value || '').trim())
3720
.filter(Boolean);
@@ -44,7 +27,7 @@
4427
for (const strongLabel of strongIdentityLabels) {
4528
"""
4629
if needle not in text:
47-
raise RuntimeError('strong identity block missing after episode refinement')
30+
raise RuntimeError('strong identity block missing after v3 patch')
4831
text = text.replace(needle, replacement, 1)
4932
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"
5033
if late not in text:

0 commit comments

Comments
 (0)