From 25aafc755592db8e34226ecbf310c7e1e6e1d179 Mon Sep 17 00:00:00 2001 From: TheBeastLT Date: Thu, 19 Mar 2020 20:01:59 +0100 Subject: [PATCH] [addon] populate existing config values in template --- addon/lib/landingTemplate.js | 8 +++++++- addon/lib/manifest.js | 2 +- addon/serverless.js | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/addon/lib/landingTemplate.js b/addon/lib/landingTemplate.js index 3f12742..fe38f99 100644 --- a/addon/lib/landingTemplate.js +++ b/addon/lib/landingTemplate.js @@ -185,7 +185,11 @@ button:active { const { Providers } = require('./manifest'); const { SortType } = require('./sort'); -function landingTemplate(manifest, providers = [], realDebridApiKey = '') { +function landingTemplate(manifest, config = {}) { + const providers = config.providers || []; + const realDebridApiKey = config.realdebrid || ''; + const sort = config.sort === SortType.SEEDERS ? SortType.SEEDERS : SortType.QUALITY; + const limit = config.limit || ''; const background = manifest.background || 'https://dl.strem.io/addon-background.jpg'; const logo = manifest.logo || 'https://dl.strem.io/addon-logo.png'; const contactHTML = manifest.contactEmail ? @@ -266,6 +270,8 @@ function landingTemplate(manifest, providers = [], realDebridApiKey = '') { }); $('#iProviders').multiselect('select', [${providers.map(provider => '"' + provider + '"')}]); $('#iRealDebrid').val("${realDebridApiKey}"); + $('#iSort').val("${sort}"); + $('#iLimit').val("${limit}"); generateInstallLink(); }); diff --git a/addon/lib/manifest.js b/addon/lib/manifest.js index 9efa971..74e37ee 100644 --- a/addon/lib/manifest.js +++ b/addon/lib/manifest.js @@ -16,7 +16,7 @@ function manifest({ providers, realdebrid } = {}) { name: 'Torrentio', description: '[BETA] Provides torrent streams from scraped torrent providers.' + ` ${providersDesc} ${providersList.join(', ')}${realDebridDesc}.` - + ' To configure providers,RealDebrid support and other settings visit www.torrentio.now.sh', + + ' To configure providers, RealDebrid support and other settings visit www.torrentio.now.sh', catalogs: [], resources: ['stream'], types: ['movie', 'series'], diff --git a/addon/serverless.js b/addon/serverless.js index 31fc885..e1b4c3f 100644 --- a/addon/serverless.js +++ b/addon/serverless.js @@ -22,7 +22,7 @@ router.get('/', (_, res) => { router.get('/:configuration', (req, res) => { const configValues = parseConfiguration(req.params.configuration); - const landingHTML = landingTemplate(manifest(configValues), configValues.providers, configValues.realdebrid); + const landingHTML = landingTemplate(manifest(configValues), configValues); res.setHeader('content-type', 'text/html'); res.end(landingHTML); });