|
11 | 11 | raise RuntimeError('cannot load strict content fix v3') |
12 | 12 | mod = importlib.util.module_from_spec(spec) |
13 | 13 | spec.loader.exec_module(mod) |
| 14 | +mod.mod.main() |
14 | 15 |
|
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. |
16 | 18 | path = ROOT / 'scripts' / 'nuvio_client_lab.cjs' |
17 | 19 | 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) |
18 | 35 | needle = """ const strongIdentityLabels = [stream?.title, stream?.filename, mediaFilename] |
19 | 36 | .map((value) => String(value || '').trim()) |
20 | 37 | .filter(Boolean); |
|
27 | 44 | for (const strongLabel of strongIdentityLabels) { |
28 | 45 | """ |
29 | 46 | 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') |
31 | 48 | text = text.replace(needle, replacement, 1) |
32 | 49 | 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" |
33 | 50 | if late not in text: |
|
0 commit comments