[addon] populate existing config values in template

This commit is contained in:
TheBeastLT
2020-03-19 20:01:59 +01:00
parent e8390ad2a5
commit 25aafc7555
3 changed files with 9 additions and 3 deletions

View File

@@ -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();
});

View File

@@ -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'],

View File

@@ -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);
});