|
| 1 | +import assert from "node:assert/strict"; |
| 2 | +import { |
| 3 | + catalogIdentity, |
| 4 | + compareManifest, |
| 5 | + interestFor, |
| 6 | + providerKey, |
| 7 | +} from "../scripts/watch-upstream-providers.mjs"; |
| 8 | + |
| 9 | +assert.equal(providerKey("🐍 Anime-Sama"), "animesama"); |
| 10 | +assert.equal(providerKey("ANIME_SAMA"), "animesama"); |
| 11 | + |
| 12 | +const catalog = { |
| 13 | + providers: [ |
| 14 | + { |
| 15 | + canonicalId: "cineby", |
| 16 | + scraper: { id: "CINEBY", name: "Cineby", filename: "providers/cineby--nuvio--abc.js" }, |
| 17 | + }, |
| 18 | + { |
| 19 | + canonicalId: "anime-sama", |
| 20 | + scraper: { id: "ANIME-SAMA", name: "🐍 Anime-Sama", filename: "providers/anime-sama--nuvio--def.js" }, |
| 21 | + }, |
| 22 | + ], |
| 23 | +}; |
| 24 | +const identity = catalogIdentity(catalog); |
| 25 | +assert(identity.ids.has("cineby")); |
| 26 | +assert(identity.ids.has("animesama")); |
| 27 | + |
| 28 | +const upstream = { id: "gowaru", repository: "Gowaru/gowaru-nuvio-providers" }; |
| 29 | +const manifest = { |
| 30 | + scrapers: [ |
| 31 | + { id: "cineby", name: "Cineby", supportedTypes: ["movie", "tv"], formats: ["m3u8"] }, |
| 32 | + { |
| 33 | + id: "new-vf-provider", |
| 34 | + name: "New VF Provider 4K", |
| 35 | + description: "Films et séries français 4K", |
| 36 | + supportedTypes: ["movie", "tv"], |
| 37 | + contentLanguage: ["fr"], |
| 38 | + formats: ["m3u8", "mp4"], |
| 39 | + enabled: true, |
| 40 | + }, |
| 41 | + { |
| 42 | + id: "new-limited", |
| 43 | + name: "New Limited", |
| 44 | + supportedTypes: ["movie"], |
| 45 | + contentLanguage: ["en"], |
| 46 | + limited: true, |
| 47 | + enabled: false, |
| 48 | + }, |
| 49 | + ], |
| 50 | +}; |
| 51 | + |
| 52 | +const compared = compareManifest({ upstream, manifest, catalog }); |
| 53 | +assert.equal(compared.existingCount, 1); |
| 54 | +assert.equal(compared.unseen.length, 2); |
| 55 | +assert.equal(compared.unseen[0].id, "new-vf-provider"); |
| 56 | +assert.equal(compared.unseen[0].interesting, true); |
| 57 | +assert(compared.unseen[0].reasons.includes("French/VF metadata")); |
| 58 | +assert(compared.unseen[0].reasons.some((reason) => reason.startsWith("direct formats:"))); |
| 59 | +assert.equal(compared.unseen.at(-1).id, "new-limited"); |
| 60 | +assert.equal(compared.unseen.at(-1).interesting, false); |
| 61 | + |
| 62 | +const noAutoMagic = interestFor({ |
| 63 | + id: "plain", |
| 64 | + name: "Plain", |
| 65 | + supportedTypes: ["movie"], |
| 66 | + formats: [], |
| 67 | + contentLanguage: ["en"], |
| 68 | + enabled: false, |
| 69 | +}); |
| 70 | +assert.equal(noAutoMagic.interesting, false); |
| 71 | +assert(noAutoMagic.score < 4); |
| 72 | + |
| 73 | +console.log("engine v2 upstream provider watch tests passed"); |
0 commit comments