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 c7e7fef
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 34 deletions.
29 changes: 15 additions & 14 deletions index.json
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,6 @@
"newEpisodeNotifications": true
}
},
"transportName": "http",
"transportUrl": "https://v3-cinemeta.strem.io/manifest.json",
"flags": {
"official": true,
Expand Down Expand Up @@ -813,10 +812,10 @@
}
]
},
"transportName": "http",
"transportUrl": "https://v3-channels.strem.io/manifest.json",
"flags": {
"official": true
"official": true,
"protected": false
}
},
{
Expand All @@ -838,10 +837,10 @@
"tt"
]
},
"transportName": "http",
"transportUrl": "https://watchhub.strem.io/manifest.json",
"flags": {
"official": true
"official": true,
"protected": false
}
},
{
Expand Down Expand Up @@ -876,10 +875,10 @@
"tt"
]
},
"transportName": "http",
"transportUrl": "https://caching.stremio.net/publicdomainmovies.now.sh/manifest.json",
"flags": {
"official": true
"official": true,
"protected": false
}
},
{
Expand All @@ -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
}
},
{
Expand All @@ -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
}
},
{
Expand Down Expand Up @@ -965,11 +967,10 @@
],
"catalogs": []
},
"transportName": "http",
"transportUrl": "http://127.0.0.1:11470/local-addon/manifest.json",
"flags": {
"official": true,
"protected": true
}
}
]
]
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: 28 additions & 19 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 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",
Expand All @@ -14,23 +21,25 @@ 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 { response: Promise.resolve(localAddonManifest), transportUrl };
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))
})

0 comments on commit c7e7fef

Please sign in to comment.