From 7122e4b6365062752745545ce863945378f05791 Mon Sep 17 00:00:00 2001 From: Lachezar Lechev Date: Thu, 11 Jan 2024 12:37:07 +0200 Subject: [PATCH 1/2] feat: use local-addon instead of running server Signed-off-by: Lachezar Lechev --- index.json | 29 +++++++++++++++-------------- package.json | 3 ++- scripts/gen.js | 46 +++++++++++++++++++++++++++------------------- 3 files changed, 44 insertions(+), 34 deletions(-) diff --git a/index.json b/index.json index a403a8a..d40589c 100644 --- a/index.json +++ b/index.json @@ -744,7 +744,6 @@ "newEpisodeNotifications": true } }, - "transportName": "http", "transportUrl": "https://v3-cinemeta.strem.io/manifest.json", "flags": { "official": true, @@ -813,10 +812,10 @@ } ] }, - "transportName": "http", "transportUrl": "https://v3-channels.strem.io/manifest.json", "flags": { - "official": true + "official": true, + "protected": false } }, { @@ -838,10 +837,10 @@ "tt" ] }, - "transportName": "http", "transportUrl": "https://watchhub.strem.io/manifest.json", "flags": { - "official": true + "official": true, + "protected": false } }, { @@ -876,10 +875,10 @@ "tt" ] }, - "transportName": "http", "transportUrl": "https://caching.stremio.net/publicdomainmovies.now.sh/manifest.json", "flags": { - "official": true + "official": true, + "protected": false } }, { @@ -901,10 +900,10 @@ ], "logo": "http://www.strem.io/images/addons/opensubtitles-logo.png" }, - "transportName": "http", "transportUrl": "https://opensubtitles-v3.strem.io/manifest.json", "flags": { - "official": true + "official": true, + "protected": false } }, { @@ -922,12 +921,15 @@ "movie", "other" ], - "catalogs": [] + "catalogs": [], + "behaviorHints": { + "adult": false + } }, - "transportName": "legacy", "transportUrl": "https://opensubtitles.strem.io/stremio/v1", "flags": { - "official": true + "official": true, + "protected": false } }, { @@ -965,11 +967,10 @@ ], "catalogs": [] }, - "transportName": "http", "transportUrl": "http://127.0.0.1:11470/local-addon/manifest.json", "flags": { "official": true, "protected": true } } -] \ No newline at end of file +] diff --git a/package.json b/package.json index c1941b3..864d6cd 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,8 @@ }, "homepage": "https://github.com/Stremio/stremio-official-addons#readme", "devDependencies": { - "stremio-addon-client": "^1.5.2" + "stremio-addon-client": "^1.5.2", + "stremio-local-addon": "https://git@github.com/Stremio/stremio-local-addon#79cd88c32aa26270af8b662fa7bd92b657f6e14f" }, "workspaces": [ ".", diff --git a/scripts/gen.js b/scripts/gen.js index e01049d..8a14077 100755 --- a/scripts/gen.js +++ b/scripts/gen.js @@ -1,7 +1,14 @@ #!/usr/bin/env node -const client = require('stremio-addon-client') +const client = require('stremio-addon-client'); +const AddonClient = require('stremio-addon-client/lib/AddonClient'); +const transports = require('stremio-addon-client/lib/transports'); +const localAddonManifest = require('stremio-local-addon/lib/manifestNoCatalogs'); +const PROTECTED_URLS = [ + 'https://v3-cinemeta.strem.io/manifest.json', + 'http://127.0.0.1:11470/local-addon/manifest.json', +]; const ENDPOINTS = [ "https://v3-cinemeta.strem.io/manifest.json", "https://v3-channels.strem.io/manifest.json", @@ -14,23 +21,24 @@ const ENDPOINTS = [ const col = new client.AddonCollection() -Promise.all(ENDPOINTS.map(url => client.detectFromURL(url))) -.then(function(responses) { - responses.forEach(function(x, i) { - if (!x.addon) return - if (JSON.stringify(x.addon.manifest).length > 8192) throw 'manifest bigger than 8kb - aborting!' - x.addon.flags = isProtected(x, i) ? { official: true, protected: true } : { official: true } - col.add(x.addon) - }) -}) -.then(function() { - console.log(JSON.stringify(col.save(), null, 4)) -}) +Promise.all(ENDPOINTS.map((transportUrl) => { + if (transportUrl === 'http://127.0.0.1:11470/local-addon/manifest.json') { + return Promise.resolve({ addon: new AddonClient(localAddonManifest, new transports.http(transportUrl), { official: true, protected: true }), transportUrl }); + } + + return client.detectFromURL(transportUrl); +})) + .then(function (responses) { + responses.forEach(function (response) { + if (!response.addon) return + let descriptor = response.addon.toDescriptor(); -function isProtected(x, i) { - // cinemeta - if (i === 0) return true + if (JSON.stringify(descriptor.manifest).length > 8192) throw 'manifest bigger than 8kb - aborting!' + let isProtected = PROTECTED_URLS.includes(descriptor.transportUrl); - // local - if (x.addon.manifest.id.match('local')) return true -} + col.add(new AddonClient(descriptor.manifest, new transports.http(descriptor.transportUrl), { official: true, protected: isProtected })) + }) + }) + .then(function () { + console.log(JSON.stringify(col.save(), null, 4)) + }) From 0b2aa16fbf5bea73b76067612e3310242579fe96 Mon Sep 17 00:00:00 2001 From: Lachezar Lechev Date: Thu, 11 Jan 2024 12:43:50 +0200 Subject: [PATCH 2/2] chore: update README Signed-off-by: Lachezar Lechev --- README.md | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 5a802e0..9559b15 100644 --- a/README.md +++ b/README.md @@ -8,31 +8,27 @@ All the stremio official add-ons, in `AddonCollection.load()` format The `index.js` file is meant to be generated from the output of `AddonCollection.save()` -## Update - -To re-generate `index.json` you can do `scripts/gen.js > index.json` ( you also need a locally running Stremio Server using either the [Stremio Desktop](https://www.stremio.com/downloads) app or [Stremio service](https://www.stremio.com/download-service)) - - ## Changing the official add-ons -To change what's contained in this module, you have to change `scripts/gen.js` +To change what's contained in this module, you have to change [`scripts/gen.js`](./scripts/gen.js) for **version 1** and [`official-addons-v2/scripts/build.js`](./official-addons-v2/scripts/build.js) for **version 2**. Besides changing this module, you have to update all it's dependant packages, most notably: -* stremio-api-workers: this is the **most important one**, since it will affect `addonsofficialcollection.json` and therefore the addonCollection API, and therefore all running apps should respect it +* stremio-api-workers: this is the **most important one**, since it will affect `addonsofficialcollection.json` and therefore the addonCollection API, and therefore all running apps should respect it ([`stremio-official-addons@1`][v1-npm-link] package) -* stremio: the desktop/web app ([`stremio-official-addons@1`](https://www.npmjs.com/package/stremio-official-addons) package) +* stremio: the desktop/web app ([`stremio-official-addons@1` package][v1-npm-link]) -* stremio-rn: the react native app +* stremio-rn: the react native app ([`stremio-official-addons@1` package][v1-npm-link]) -* stremio-web: the new desktop/web app ([`@stremio/stremio-official-addons@2`](https://www.npmjs.com/package/@stremio/stremio-official-addons) package) +* stremio-web: the new desktop/web app ([`@stremio/stremio-official-addons@2` package][v2-npm-link]) -* stremio-api-legacy-shim: this one does not *depend on* this module, and does not include it, but it contains a separate list of official add-ons in `addons/official.js` that is respected by all apps using the legacy endpoints +* stremio-core: the core for most applications including web, android tv, android, etc. ([`stremio-official-addons@2` crate][v2-crates-io-link]) + +* stremio-api-legacy-shim: this one does not *depend on* this module, and does not include it, but it contains a separate list of official add-ons in `addons/official.js` that is respected by all apps using the legacy endpoints **ARCHIVED** [v1-npm-link]: https://www.npmjs.com/package/stremio-official-addons [stremio-official-addons downloads badge]: https://img.shields.io/npm/dm/stremio-official-addons?label=stremio-official-addons%20downloads&link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2Fstremio-official-addons - [stremio-official-addons version badge]: https://img.shields.io/npm/v/stremio-official-addons?label=stremio-official-addons&link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2Fstremio-official-addons [v2-npm-link]: https://www.npmjs.com/package/@stremio/stremio-official-addons