diff --git a/addon/lib/landingTemplate.js b/addon/lib/landingTemplate.js index 8740f2f..8ead5c1 100644 --- a/addon/lib/landingTemplate.js +++ b/addon/lib/landingTemplate.js @@ -15,12 +15,12 @@ html { background-size: auto 100%; background-size: cover; background-position: center center; - background-repeat: no-repeat + background-repeat: repeat-y; } body { display: flex; - background: rgba(0, 0, 0, 0.60); + background-color: transparent; font-family: 'Open Sans', Arial, sans-serif; color: white; } @@ -62,7 +62,7 @@ ul { } a { - color: white + color: green } a.install-link { @@ -95,8 +95,11 @@ button:active { } #addon { - width: 40vh; + width: 90vh; margin: auto; + padding-left: 10%; + padding-right: 10%; + background: rgba(0, 0, 0, 0.60); } .logo { @@ -173,6 +176,7 @@ button:active { height: 3.5vh; width: 100%; margin: auto; + margin-bottom: 10px; padding: 6px 12px; border: 0; border-radius: 0; @@ -184,12 +188,21 @@ button:active { `; const { Providers } = require('./manifest'); const { SortOptions } = require('./sort'); +const { DebridOptions } = require('../moch/options'); +const { MochOptions } = require('../moch/moch'); function landingTemplate(manifest, config = {}) { const providers = config.providers || []; - const realDebridApiKey = config.realdebrid || ''; const sort = config.sort || SortOptions.options.qualitySeeders.key; const limit = config.limit || ''; + + const debridOptions = config[DebridOptions.key] || []; + const realDebridApiKey = config[MochOptions.realdebrid.key] || ''; + const allDebridApiKey = config[MochOptions.alldebrid.key] || ''; + const putioKey = config[MochOptions.putio.key] || ''; + const putioClientId = putioKey.replace(/@.*/, ''); + const putioToken = putioKey.replace(/.*@/, ''); + 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 ? @@ -203,6 +216,9 @@ function landingTemplate(manifest, config = {}) { const sortOptionsHTML = Object.values(SortOptions.options) .map((option, i) => ``) .join('\n'); + const debridOptionsHTML = Object.values(DebridOptions.options) + .map((option) => ``) + .join('\n'); const stylizedTypes = manifest.types .map(t => t[0].toUpperCase() + t.slice(1) + (t !== 'series' ? 's' : '')); @@ -254,9 +270,21 @@ function landingTemplate(manifest, config = {}) { - + + + + + + + + + + +
@@ -271,14 +299,22 @@ function landingTemplate(manifest, config = {}) { onChange: () => generateInstallLink() }); $('#iProviders').multiselect('select', [${providers.map(provider => '"' + provider + '"')}]); + $('#iDebridOptions').multiselect({ + nonSelectedText: 'None', + onChange: () => generateInstallLink() + }); + $('#iDebridOptions').multiselect('select', [${debridOptions.map(option => '"' + option + '"')}]); $('#iRealDebrid').val("${realDebridApiKey}"); + $('#iAllDebrid').val("${allDebridApiKey}"); + $('#iPutioClientId').val("${putioClientId}"); + $('#iPutioToken').val("${putioToken}"); $('#iSort').val("${sort}"); $('#iLimit').val("${limit}"); generateInstallLink(); }); function sortModeChange() { - if (['${SortOptions.options.qualitySeeders.key}', '${SortOptions.options.qualitySize.key}'].includes($('#iSort').val())) { + if (['${SortOptions.options.seeders.key}', '${SortOptions.options.size.key}'].includes($('#iSort').val())) { $("#iLimitLabel").text("Max results:"); } else { $("#iLimitLabel").text("Max results per quality:"); @@ -287,17 +323,35 @@ function landingTemplate(manifest, config = {}) { } function generateInstallLink() { - const providersValue = $('#iProviders').val().join(','); - const realDebridValue = $('#iRealDebrid').val(); - const sortValue = $('#iSort').val(); - const limitValue = $('#iLimit').val(); + const providersValue = $('#iProviders').val().join(',') || ''; + const sortValue = $('#iSort').val() || ''; + const limitValue = $('#iLimit').val() || ''; - const providers = providersValue && providersValue.length ? 'providers=' + providersValue : ''; - const realDebrid = realDebridValue && realDebridValue.length ? 'realdebrid=' + realDebridValue : ''; - const sort = sortValue !== '${SortOptions.options.qualitySeeders.key}' ? 'sort=' + sortValue : ''; - const limit = /^[1-9][0-9]*$/.test(limitValue) ? 'limit=' + limitValue : ''; + const debridOptionsValue = $('#iDebridOptions').val().join(',') || ''; + const realDebridValue = $('#iRealDebrid').val() || ''; + const allDebridValue = $('#iAllDebrid').val() || ''; + const putioClientIdValue = $('#iPutioClientId').val() || ''; + const putioTokenValue = $('#iPutioToken').val() || ''; - const configurationValue = [providers, sort, limit, realDebrid].filter(value => value.length).join('|'); + + const providers = providersValue.length && providersValue; + const sort = sortValue !== '${SortOptions.options.qualitySeeders.key}' && sortValue; + const limit = /^[1-9][0-9]*$/.test(limitValue) && limitValue; + + const debridOptions = debridOptionsValue.length && debridOptionsValue.trim(); + const realDebrid = realDebridValue.length && realDebridValue.trim(); + const allDebrid = allDebridValue.length && allDebridValue.trim(); + const putio = putioClientIdValue.length && putioTokenValue.length && putioClientIdValue.trim() + '@' + putioTokenValue.trim(); + + const configurationValue = [ + ['providers', providers], + ['${SortOptions.key}', sort], + ['limit', limit], + ['${DebridOptions.key}', debridOptions], + ['${MochOptions.realdebrid.key}', realDebrid], + ['${MochOptions.alldebrid.key}', allDebrid], + ['${MochOptions.putio.key}', putio] + ].filter(([_, value]) => value.length).map(([key, value]) => key + '=' + value).join('|'); const configuration = configurationValue && configurationValue.length ? '/' + configurationValue : ''; installLink.href = 'stremio://' + window.location.host + configuration + '/manifest.json'; } diff --git a/addon/lib/manifest.js b/addon/lib/manifest.js index e0f8071..b87c203 100644 --- a/addon/lib/manifest.js +++ b/addon/lib/manifest.js @@ -1,3 +1,5 @@ +const { MochOptions } = require('../moch/moch'); + const Providers = [ 'YTS', 'EZTV', @@ -9,19 +11,24 @@ const Providers = [ ]; const DefaultProviders = Providers -function manifest({ providers, realdebrid } = {}) { - const providersList = providers && providers.map(provider => getProvider(provider)) || DefaultProviders; +function manifest(config = {}) { + const providersList = config.providers && config.providers.map(provider => getProvider(provider)) || DefaultProviders; const enabledProvidersDesc = Providers .map(provider => `${provider}${providersList.includes(provider) ? '(+)' : '(-)'}`) .join(', ') - const realDebridDesc = realdebrid ? ' and RealDebrid enabled' : ''; + const enabledMochs = Object.values(MochOptions) + .filter(moch => config[moch.key]) + .map(moch => moch.name) + .join(' & '); + const possibleMochs = Object.values(MochOptions).map(moch => moch.name).join('/') + const mochsDesc = enabledMochs ? ` and ${enabledMochs} enabled ` : ''; return { id: 'com.stremio.torrentio.addon', version: '0.0.4', name: 'Torrentio', description: 'Provides torrent streams from scraped torrent providers.' - + ` Currently supports ${enabledProvidersDesc}${realDebridDesc}.` - + ' To configure providers, RealDebrid support and other settings visit https://torrentio.strem.fun', + + ` Currently supports ${enabledProvidersDesc}${mochsDesc}.` + + ` To configure providers, ${possibleMochs} support and other settings visit https://torrentio.strem.fun`, catalogs: [], resources: ['stream'], types: ['movie', 'series'],