[addon] add lite addon configuration version
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
const { DebridOptions } = require('../moch/options');
|
||||
const { QualityFilter } = require('./filter');
|
||||
const { QualityFilter, Providers } = require('./filter');
|
||||
|
||||
const keysToSplit = ['providers', QualityFilter.key, DebridOptions.key];
|
||||
const LITE_CONFIG = liteConfig();
|
||||
const LITE_CONFIG_VALUE = liteConfigValue();
|
||||
|
||||
const keysToSplit = [Providers.key, QualityFilter.key, DebridOptions.key];
|
||||
|
||||
function parseConfiguration(configuration) {
|
||||
if (configuration === 'lite') {
|
||||
return LITE_CONFIG;
|
||||
}
|
||||
const configValues = configuration.split('|')
|
||||
.reduce((map, next) => {
|
||||
const parameterParts = next.split('=');
|
||||
@@ -18,4 +24,21 @@ function parseConfiguration(configuration) {
|
||||
return configValues;
|
||||
}
|
||||
|
||||
module.exports = parseConfiguration;
|
||||
function liteConfig() {
|
||||
const config = {};
|
||||
config[Providers.key] = Providers.options.filter(provider => !provider.foreign).map(provider => provider.key);
|
||||
config[QualityFilter.key] = ['scr', 'cam']
|
||||
config['limit'] = 1;
|
||||
config['lite'] = true;
|
||||
return config;
|
||||
}
|
||||
|
||||
function liteConfigValue() {
|
||||
return Object.entries(LITE_CONFIG)
|
||||
.filter(([key]) => key !== 'lite')
|
||||
.map(([key, value]) => `${key}=${Array.isArray(value) ? value.join(',') : value}`)
|
||||
.join('|');
|
||||
}
|
||||
|
||||
module.exports = parseConfiguration;
|
||||
module.exports.LiteConfigValue = LITE_CONFIG_VALUE;
|
||||
Reference in New Issue
Block a user