[addon] add lite addon configuration version

This commit is contained in:
TheBeastLT
2021-03-07 21:31:22 +01:00
parent 1c9ef4097b
commit 6b6a53e7f8
6 changed files with 148 additions and 69 deletions

View File

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

View File

@@ -1,85 +1,126 @@
const Providers = [
'YTS',
'EZTV',
'RARBG',
'1337x',
'ThePirateBay',
'KickassTorrents',
'TorrentGalaxy',
'Rutor',
'HorribleSubs',
'NyaaSi',
'NyaaPantsu'
];
const Providers = {
key: 'providers',
options: [
{
key: 'yts',
label: 'YTS'
},
{
key: 'eztv',
label: 'EZTV'
},
{
key: 'rarbg',
label: 'RARBG'
},
{
key: '1337x',
label: '1337x'
},
{
key: 'thepiratebay',
label: 'ThePirateBay'
},
{
key: 'kickasstorrents',
label: 'KickassTorrents'
},
{
key: 'torrentgalaxy',
label: 'TorrentGalaxy'
},
{
key: 'rutor',
label: 'Rutor',
foreign: true
},
{
key: 'horriblesubs',
label: 'HorribleSubs',
anime: true
},
{
key: 'nyaasi',
label: 'NyaaSi',
anime: true
},
{
key: 'nyaapantsu',
label: 'NyaaPantsu',
anime: true
}
]
};
const QualityFilter = {
key: 'qualityfilter',
options: [
{
key: "4k",
label: "4k",
items: ["4k"],
key: '4k',
label: '4k',
items: ['4k'],
test(quality) {
return this.items.includes(quality);
}
},
{
key: "1080p",
label: "1080p",
items: ["1080p"],
key: '1080p',
label: '1080p',
items: ['1080p'],
test(quality) {
return this.items.includes(quality)
}
},
{
key: "720p",
label: "720p",
items: ["720p"],
key: '720p',
label: '720p',
items: ['720p'],
test(quality) {
return this.items.includes(quality)
}
},
{
key: "480p",
label: "480p",
items: ["480p"],
key: '480p',
label: '480p',
items: ['480p'],
test(quality) {
return this.items.includes(quality)
}
},
{
key: "sd",
label: "SD",
items: ["DVDRip", "HDRip", "BDRip", "BRRip", "BluRay", "WED-DL", "WEBRip", "HDTV", "DivX", "XviD"],
key: 'other',
label: 'Other (DVDRip/HDRip/BDRip...)',
// could be ['DVDRip', 'HDRip', 'BDRip', 'BRRip', 'BluRay', 'WEB-DL', 'WEBRip', 'HDTV', 'DivX', 'XviD']
items: ['4k', '1080p', '720p', '480p', 'SCR', 'CAM', 'TeleSync', 'TeleCine'],
test(quality) {
return quality && !this.items.includes(quality);
}
},
{
key: 'scr',
label: 'Screener',
items: ['SCR'],
test(quality) {
return this.items.includes(quality)
}
},
{
key: "scr",
label: "Screener",
items: ["SCR"],
key: 'cam',
label: 'Cam',
items: ['CAM', 'TeleSync', 'TeleCine'],
test(quality) {
return this.items.includes(quality)
}
},
{
key: "cam",
label: "Cam",
items: ["CAM", "TeleSync", "TeleCine"],
test(quality) {
return this.items.includes(quality)
}
},
{
key: "unknown",
label: "Unknown",
key: 'unknown',
label: 'Unknown',
test(quality) {
return !quality
}
}
]
};
const defaultProviderKeys = Providers.map(provider => provider.toLowerCase());
const defaultProviderKeys = Providers.options.map(provider => provider.key);
function applyFilters(streams, config) {
return filterByQuality(filterByProvider(streams, config), config);

View File

@@ -185,6 +185,7 @@ const { SortOptions } = require('./sort');
const { QualityFilter } = require('./filter');
const { DebridOptions } = require('../moch/options');
const { MochOptions } = require('../moch/moch');
const { LiteConfigValue } = require('../lib/configuration');
function landingTemplate(manifest, config = {}) {
const providers = config.providers || [];
@@ -208,8 +209,8 @@ function landingTemplate(manifest, config = {}) {
<p>Contact ${manifest.name} creator:</p>
<a href="mailto:${manifest.contactEmail}">${manifest.contactEmail}</a>
</div>` : '';
const providersHTML = Providers
.map(provider => `<option value="${provider.toLowerCase()}">${provider}</option>`)
const providersHTML = Providers.options
.map(provider => `<option value="${provider.key}">${provider.label}</option>`)
.join('\n');
const sortOptionsHTML = Object.values(SortOptions.options)
.map((option, i) => `<option value="${option.key}" ${i === 0 ? 'selected' : ''}>${option.description}</option>`)
@@ -393,17 +394,18 @@ function landingTemplate(manifest, config = {}) {
const allDebrid = allDebridValue.length && allDebridValue.trim();
const putio = putioClientIdValue.length && putioTokenValue.length && putioClientIdValue.trim() + '@' + putioTokenValue.trim();
const configurationValue = [
['providers', providers],
let configurationValue = [
['${Providers.key}', providers],
['${SortOptions.key}', sort],
['limit', limit],
['${QualityFilter.key}', qualityFilters],
['limit', limit],
['${DebridOptions.key}', debridOptions],
['${MochOptions.realdebrid.key}', realDebrid],
['${MochOptions.premiumize.key}', premiumize],
['${MochOptions.alldebrid.key}', allDebrid],
['${MochOptions.putio.key}', putio]
].filter(([_, value]) => value.length).map(([key, value]) => key + '=' + value).join('|');
configurationValue = '${LiteConfigValue}' === configurationValue ? 'lite' : configurationValue;
const configuration = configurationValue && configurationValue.length ? '/' + configurationValue : '';
installLink.href = 'stremio://' + window.location.host + configuration + '/manifest.json';
}

View File

@@ -3,27 +3,15 @@ const { Providers } = require('./filter');
const { showDebridCatalog } = require('../moch/options');
const { Type } = require('./types');
const DefaultProviders = Providers
const DefaultProviders = Providers.options.map(provider => provider.key);
const CatalogMochs = Object.values(MochOptions).filter(moch => moch.catalog);
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 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',
id: `com.stremio.torrentio${config.lite ? '.lite' : ''}.addon`,
version: '0.0.10',
name: 'Torrentio',
description: 'Provides torrent streams from scraped torrent providers.'
+ ` Currently supports ${enabledProvidersDesc}${mochsDesc}.`
+ ` To configure providers, ${possibleMochs} support and other settings visit https://torrentio.strem.fun`,
name: `Torrentio${config.lite ? ' Lite' : ''}`,
description: getDescription(config),
catalogs: getCatalogs(config),
resources: getResources(config),
types: [Type.MOVIE, Type.SERIES, Type.OTHER],
@@ -43,8 +31,24 @@ function dummyManifest() {
return manifestDefault;
}
function getProvider(configProvider) {
return Providers.find(provider => provider.toLowerCase() === configProvider);
function getDescription(config) {
if (config.lite) {
return 'Preconfigured Lite version of Torrentio addon.'
+ ' To configure advanced options visit https://torrentio.strem.fun';
}
const providersList = config.providers || DefaultProviders;
const enabledProvidersDesc = Providers.options
.map(provider => `${provider.label}${providersList.includes(provider.key) ? '(+)' : '(-)'}`)
.join(', ')
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 'Provides torrent streams from scraped torrent providers.'
+ ` Currently supports ${enabledProvidersDesc}${mochsDesc}.`
+ ` To configure providers, ${possibleMochs} support and other settings visit https://torrentio.strem.fun`
}
function getCatalogs(config) {

View File

@@ -1,3 +1,7 @@
const { QualityFilter } = require('./filter');
const OTHER_QUALITIES = QualityFilter.options.find(option => option.key === 'other');
const CAM_QUALITIES = QualityFilter.options.find(option => option.key === 'cam');
const HEALTHY_SEEDERS = 5;
const SEEDED_SEEDERS = 1;
const MIN_HEALTHY_COUNT = 10;
@@ -97,6 +101,10 @@ function extractQuality(title) {
return '4320p'
} else if (/4k|uhd/i.test(qualityDesc)) {
return '2060p'
} else if (CAM_QUALITIES.test(qualityDesc)) {
return CAM_QUALITIES.label;
} else if (OTHER_QUALITIES.test(qualityDesc)) {
return OTHER_QUALITIES.label;
}
return qualityDesc;
}

View File

@@ -69,8 +69,9 @@ function getQuality(record, torrentInfo, fileInfo) {
function getLanguages(record, torrentInfo, fileInfo) {
const providerLanguages = record.torrent.languages && titleParser.parse(record.torrent.languages).languages || [];
const torrentLanguages = torrentInfo.languages || [];
const fileLanguages = fileInfo.languages || [];
const dubbed = torrentInfo.dubbed || fileInfo.dubbed;
let languages = [].concat(torrentLanguages).concat(providerLanguages);
let languages = Array.from(new Set([].concat(torrentLanguages).concat(fileLanguages).concat(providerLanguages)));
if (record.kitsuId || record.torrent.type === Type.ANIME) {
// no need to display japanese for anime or english if anime is dubbed
languages = languages.concat(dubbed ? ['dubbed'] : [])