Skip to content

Commit

Permalink
feat: use local-addon instead of running server
Browse files Browse the repository at this point in the history
Signed-off-by: Lachezar Lechev <[email protected]>
  • Loading branch information
elpiel committed Jan 11, 2024
1 parent 03b64bb commit b829a23
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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://[email protected]/Stremio/stremio-local-addon#79cd88c32aa26270af8b662fa7bd92b657f6e14f"
},
"workspaces": [
".",
Expand Down
47 changes: 27 additions & 20 deletions scripts/gen.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#!/usr/bin/env node

const client = require('stremio-addon-client')


const client = require('stremio-addon-client');
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",
Expand All @@ -14,23 +21,23 @@ 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))
})

function isProtected(x, i) {
// cinemeta
if (i === 0) return true
Promise.all(ENDPOINTS.map((transportUrl) => {
if (transportUrl === 'http://127.0.0.1:11470/local-addon/manifest.json') {
// return { response: Promise.resolve(localAddonManifest), transportUrl };
return Promise.resolve({ addon: new client.AddonClient(localAddonManifest, transportUrl, { official: true, protected: true }), transportUrl });
}

// local
if (x.addon.manifest.id.match('local')) return true
}
return client.detectFromURL(transportUrl);
}))
.then(function (responses) {
responses.forEach(function (response) {
if (!response.addon) return
if (JSON.stringify(response.addon.manifest).length > 8192) throw 'manifest bigger than 8kb - aborting!'
let isProtected = PROTECTED_URLS.includes(response.transportUrl);
response.addon.flags = isProtected ? { official: true, protected: true } : { official: true }
col.add(response.addon)
})
})
.then(function () {
console.log(JSON.stringify(col.save(), null, 4))
})

0 comments on commit b829a23

Please sign in to comment.