mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
[addon] display enabled providers
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
const { addonBuilder } = require('stremio-addon-sdk');
|
const { addonBuilder } = require('stremio-addon-sdk');
|
||||||
const { Type } = require('./lib/types');
|
const { Type } = require('./lib/types');
|
||||||
const { manifest, Providers } = require('./lib/manifest');
|
const { manifest, DefaultProviders } = require('./lib/manifest');
|
||||||
const { cacheWrapStream } = require('./lib/cache');
|
const { cacheWrapStream } = require('./lib/cache');
|
||||||
const { toStreamInfo } = require('./lib/streamInfo');
|
const { toStreamInfo } = require('./lib/streamInfo');
|
||||||
const repository = require('./lib/repository');
|
const repository = require('./lib/repository');
|
||||||
@@ -12,7 +12,7 @@ const CACHE_MAX_AGE_EMPTY = 30 * 60; // 30 minutes
|
|||||||
const STALE_REVALIDATE_AGE = 4 * 60 * 60; // 4 hours
|
const STALE_REVALIDATE_AGE = 4 * 60 * 60; // 4 hours
|
||||||
const STALE_ERROR_AGE = 7 * 24 * 60 * 60; // 7 days
|
const STALE_ERROR_AGE = 7 * 24 * 60 * 60; // 7 days
|
||||||
|
|
||||||
const defaultProviders = Providers.map(provider => provider.toLowerCase());
|
const defaultProviders = DefaultProviders.map(provider => provider.toLowerCase());
|
||||||
const builder = new addonBuilder(manifest());
|
const builder = new addonBuilder(manifest());
|
||||||
|
|
||||||
builder.defineStreamHandler((args) => {
|
builder.defineStreamHandler((args) => {
|
||||||
|
|||||||
@@ -5,17 +5,20 @@ const Providers = [
|
|||||||
'KickassTorrents',
|
'KickassTorrents',
|
||||||
'HorribleSubs'
|
'HorribleSubs'
|
||||||
];
|
];
|
||||||
|
const DefaultProviders = Providers
|
||||||
|
|
||||||
function manifest({ providers, realdebrid } = {}) {
|
function manifest({ providers, realdebrid } = {}) {
|
||||||
const providersList = Array.isArray(providers) && providers.map(provider => getProvider(provider)) || Providers;
|
const providersList = providers && providers.map(provider => getProvider(provider)) || DefaultProviders;
|
||||||
const providersDesc = providers && providers.length ? 'Enabled providers -' : 'Currently supports';
|
const enabledProvidersDesc = Providers
|
||||||
|
.map(provider => `${provider}${providersList.includes(provider) ? '(+)' : '(-)'}`)
|
||||||
|
.join(', ')
|
||||||
const realDebridDesc = realdebrid ? ' and RealDebrid enabled' : '';
|
const realDebridDesc = realdebrid ? ' and RealDebrid enabled' : '';
|
||||||
return {
|
return {
|
||||||
id: 'com.stremio.torrentio.addon',
|
id: 'com.stremio.torrentio.addon',
|
||||||
version: '0.0.2',
|
version: '0.0.2',
|
||||||
name: 'Torrentio',
|
name: 'Torrentio',
|
||||||
description: 'Provides torrent streams from scraped torrent providers.'
|
description: 'Provides torrent streams from scraped torrent providers.'
|
||||||
+ ` ${providersDesc} ${providersList.join(', ')}${realDebridDesc}.`
|
+ ` Currently supports ${enabledProvidersDesc}${realDebridDesc}.`
|
||||||
+ ' To configure providers, RealDebrid support and other settings visit https://torrentio.strem.fun',
|
+ ' To configure providers, RealDebrid support and other settings visit https://torrentio.strem.fun',
|
||||||
catalogs: [],
|
catalogs: [],
|
||||||
resources: ['stream'],
|
resources: ['stream'],
|
||||||
@@ -30,4 +33,4 @@ function getProvider(configProvider) {
|
|||||||
return Providers.find(provider => provider.toLowerCase() === configProvider);
|
return Providers.find(provider => provider.toLowerCase() === configProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { manifest, Providers };
|
module.exports = { manifest, Providers, DefaultProviders };
|
||||||
Reference in New Issue
Block a user