|
10 | 10 | if spec is None or spec.loader is None: |
11 | 11 | raise RuntimeError('cannot load strict content fix v3') |
12 | 12 | mod = importlib.util.module_from_spec(spec) |
| 13 | +# v3 applies the complete v2 patch and its episode-marker refinement at import. |
13 | 14 | spec.loader.exec_module(mod) |
14 | | -mod.mod.main() |
15 | 15 |
|
16 | | -# v3's own post-processing runs only in its __main__ block, so reproduce the |
17 | | -# episode-marker exemption here before refining precedence. |
18 | 16 | path = ROOT / 'scripts' / 'nuvio_client_lab.cjs' |
19 | 17 | 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) |
35 | 18 | needle = """ const strongIdentityLabels = [stream?.title, stream?.filename, mediaFilename] |
36 | 19 | .map((value) => String(value || '').trim()) |
37 | 20 | .filter(Boolean); |
|
44 | 27 | for (const strongLabel of strongIdentityLabels) { |
45 | 28 | """ |
46 | 29 | 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') |
48 | 31 | text = text.replace(needle, replacement, 1) |
49 | 32 | 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" |
50 | 33 | if late not in text: |
|
0 commit comments