[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 { 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) { function parseConfiguration(configuration) {
if (configuration === 'lite') {
return LITE_CONFIG;
}
const configValues = configuration.split('|') const configValues = configuration.split('|')
.reduce((map, next) => { .reduce((map, next) => {
const parameterParts = next.split('='); const parameterParts = next.split('=');
@@ -18,4 +24,21 @@ function parseConfiguration(configuration) {
return configValues; 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 = [ const Providers = {
'YTS', key: 'providers',
'EZTV', options: [
'RARBG', {
'1337x', key: 'yts',
'ThePirateBay', label: 'YTS'
'KickassTorrents', },
'TorrentGalaxy', {
'Rutor', key: 'eztv',
'HorribleSubs', label: 'EZTV'
'NyaaSi', },
'NyaaPantsu' {
]; 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 = { const QualityFilter = {
key: 'qualityfilter', key: 'qualityfilter',
options: [ options: [
{ {
key: "4k", key: '4k',
label: "4k", label: '4k',
items: ["4k"], items: ['4k'],
test(quality) { test(quality) {
return this.items.includes(quality); return this.items.includes(quality);
} }
}, },
{ {
key: "1080p", key: '1080p',
label: "1080p", label: '1080p',
items: ["1080p"], items: ['1080p'],
test(quality) { test(quality) {
return this.items.includes(quality) return this.items.includes(quality)
} }
}, },
{ {
key: "720p", key: '720p',
label: "720p", label: '720p',
items: ["720p"], items: ['720p'],
test(quality) { test(quality) {
return this.items.includes(quality) return this.items.includes(quality)
} }
}, },
{ {
key: "480p", key: '480p',
label: "480p", label: '480p',
items: ["480p"], items: ['480p'],
test(quality) { test(quality) {
return this.items.includes(quality) return this.items.includes(quality)
} }
}, },
{ {
key: "sd", key: 'other',
label: "SD", label: 'Other (DVDRip/HDRip/BDRip...)',
items: ["DVDRip", "HDRip", "BDRip", "BRRip", "BluRay", "WED-DL", "WEBRip", "HDTV", "DivX", "XviD"], // 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) { test(quality) {
return this.items.includes(quality) return this.items.includes(quality)
} }
}, },
{ {
key: "scr", key: 'cam',
label: "Screener", label: 'Cam',
items: ["SCR"], items: ['CAM', 'TeleSync', 'TeleCine'],
test(quality) { test(quality) {
return this.items.includes(quality) return this.items.includes(quality)
} }
}, },
{ {
key: "cam", key: 'unknown',
label: "Cam", label: 'Unknown',
items: ["CAM", "TeleSync", "TeleCine"],
test(quality) {
return this.items.includes(quality)
}
},
{
key: "unknown",
label: "Unknown",
test(quality) { test(quality) {
return !quality return !quality
} }
} }
] ]
}; };
const defaultProviderKeys = Providers.map(provider => provider.toLowerCase()); const defaultProviderKeys = Providers.options.map(provider => provider.key);
function applyFilters(streams, config) { function applyFilters(streams, config) {
return filterByQuality(filterByProvider(streams, config), config); return filterByQuality(filterByProvider(streams, config), config);

View File

@@ -185,6 +185,7 @@ const { SortOptions } = require('./sort');
const { QualityFilter } = require('./filter'); const { QualityFilter } = require('./filter');
const { DebridOptions } = require('../moch/options'); const { DebridOptions } = require('../moch/options');
const { MochOptions } = require('../moch/moch'); const { MochOptions } = require('../moch/moch');
const { LiteConfigValue } = require('../lib/configuration');
function landingTemplate(manifest, config = {}) { function landingTemplate(manifest, config = {}) {
const providers = config.providers || []; const providers = config.providers || [];
@@ -208,8 +209,8 @@ function landingTemplate(manifest, config = {}) {
<p>Contact ${manifest.name} creator:</p> <p>Contact ${manifest.name} creator:</p>
<a href="mailto:${manifest.contactEmail}">${manifest.contactEmail}</a> <a href="mailto:${manifest.contactEmail}">${manifest.contactEmail}</a>
</div>` : ''; </div>` : '';
const providersHTML = Providers const providersHTML = Providers.options
.map(provider => `<option value="${provider.toLowerCase()}">${provider}</option>`) .map(provider => `<option value="${provider.key}">${provider.label}</option>`)
.join('\n'); .join('\n');
const sortOptionsHTML = Object.values(SortOptions.options) const sortOptionsHTML = Object.values(SortOptions.options)
.map((option, i) => `<option value="${option.key}" ${i === 0 ? 'selected' : ''}>${option.description}</option>`) .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 allDebrid = allDebridValue.length && allDebridValue.trim();
const putio = putioClientIdValue.length && putioTokenValue.length && putioClientIdValue.trim() + '@' + putioTokenValue.trim(); const putio = putioClientIdValue.length && putioTokenValue.length && putioClientIdValue.trim() + '@' + putioTokenValue.trim();
const configurationValue = [ let configurationValue = [
['providers', providers], ['${Providers.key}', providers],
['${SortOptions.key}', sort], ['${SortOptions.key}', sort],
['limit', limit],
['${QualityFilter.key}', qualityFilters], ['${QualityFilter.key}', qualityFilters],
['limit', limit],
['${DebridOptions.key}', debridOptions], ['${DebridOptions.key}', debridOptions],
['${MochOptions.realdebrid.key}', realDebrid], ['${MochOptions.realdebrid.key}', realDebrid],
['${MochOptions.premiumize.key}', premiumize], ['${MochOptions.premiumize.key}', premiumize],
['${MochOptions.alldebrid.key}', allDebrid], ['${MochOptions.alldebrid.key}', allDebrid],
['${MochOptions.putio.key}', putio] ['${MochOptions.putio.key}', putio]
].filter(([_, value]) => value.length).map(([key, value]) => key + '=' + value).join('|'); ].filter(([_, value]) => value.length).map(([key, value]) => key + '=' + value).join('|');
configurationValue = '${LiteConfigValue}' === configurationValue ? 'lite' : configurationValue;
const configuration = configurationValue && configurationValue.length ? '/' + configurationValue : ''; const configuration = configurationValue && configurationValue.length ? '/' + configurationValue : '';
installLink.href = 'stremio://' + window.location.host + configuration + '/manifest.json'; 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 { showDebridCatalog } = require('../moch/options');
const { Type } = require('./types'); const { Type } = require('./types');
const DefaultProviders = Providers const DefaultProviders = Providers.options.map(provider => provider.key);
const CatalogMochs = Object.values(MochOptions).filter(moch => moch.catalog); const CatalogMochs = Object.values(MochOptions).filter(moch => moch.catalog);
function manifest(config = {}) { 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 { return {
id: 'com.stremio.torrentio.addon', id: `com.stremio.torrentio${config.lite ? '.lite' : ''}.addon`,
version: '0.0.10', version: '0.0.10',
name: 'Torrentio', name: `Torrentio${config.lite ? ' Lite' : ''}`,
description: 'Provides torrent streams from scraped torrent providers.' description: getDescription(config),
+ ` Currently supports ${enabledProvidersDesc}${mochsDesc}.`
+ ` To configure providers, ${possibleMochs} support and other settings visit https://torrentio.strem.fun`,
catalogs: getCatalogs(config), catalogs: getCatalogs(config),
resources: getResources(config), resources: getResources(config),
types: [Type.MOVIE, Type.SERIES, Type.OTHER], types: [Type.MOVIE, Type.SERIES, Type.OTHER],
@@ -43,8 +31,24 @@ function dummyManifest() {
return manifestDefault; return manifestDefault;
} }
function getProvider(configProvider) { function getDescription(config) {
return Providers.find(provider => provider.toLowerCase() === configProvider); 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) { 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 HEALTHY_SEEDERS = 5;
const SEEDED_SEEDERS = 1; const SEEDED_SEEDERS = 1;
const MIN_HEALTHY_COUNT = 10; const MIN_HEALTHY_COUNT = 10;
@@ -97,6 +101,10 @@ function extractQuality(title) {
return '4320p' return '4320p'
} else if (/4k|uhd/i.test(qualityDesc)) { } else if (/4k|uhd/i.test(qualityDesc)) {
return '2060p' return '2060p'
} else if (CAM_QUALITIES.test(qualityDesc)) {
return CAM_QUALITIES.label;
} else if (OTHER_QUALITIES.test(qualityDesc)) {
return OTHER_QUALITIES.label;
} }
return qualityDesc; return qualityDesc;
} }

View File

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