add priority language setting
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const { DebridOptions } = require('../moch/options');
|
||||
const { QualityFilter, Providers } = require('./filter');
|
||||
const { LanguageOptions } = require('./sort');
|
||||
|
||||
const PRE_CONFIGURATIONS = {
|
||||
lite: {
|
||||
@@ -54,7 +55,8 @@ function liteConfig() {
|
||||
|
||||
function brazucaConfig() {
|
||||
const config = {};
|
||||
config[Providers.key] = ['nyaasi', 'comando', 'comoeubaixo', 'lapumia', 'ondebaixa'];
|
||||
config[Providers.key] = Providers.options.map(provider => provider.key).filter(key => key !== 'rutor');
|
||||
config[LanguageOptions.key] = 'portuguese';
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ button:active {
|
||||
}
|
||||
|
||||
.input, .btn {
|
||||
height: 3.5vh;
|
||||
height: 3.8vh;
|
||||
width: 100%;
|
||||
margin: auto;
|
||||
margin-bottom: 10px;
|
||||
@@ -182,6 +182,7 @@ button:active {
|
||||
`;
|
||||
const { Providers } = require('./filter');
|
||||
const { SortOptions } = require('./sort');
|
||||
const { LanguageOptions } = require('./sort');
|
||||
const { QualityFilter } = require('./filter');
|
||||
const { DebridOptions } = require('../moch/options');
|
||||
const { MochOptions } = require('../moch/moch');
|
||||
@@ -190,6 +191,7 @@ const { PreConfigurations } = require('../lib/configuration');
|
||||
function landingTemplate(manifest, config = {}) {
|
||||
const providers = config.providers || [];
|
||||
const sort = config[SortOptions.key] || SortOptions.options.qualitySeeders.key;
|
||||
const language = config[LanguageOptions.key];
|
||||
const qualityFilters = config[QualityFilter.key] || [];
|
||||
const limit = config.limit || '';
|
||||
|
||||
@@ -216,6 +218,9 @@ function landingTemplate(manifest, config = {}) {
|
||||
const sortOptionsHTML = Object.values(SortOptions.options)
|
||||
.map((option, i) => `<option value="${option.key}" ${i === 0 ? 'selected' : ''}>${option.description}</option>`)
|
||||
.join('\n');
|
||||
const languageOptionsHTML = LanguageOptions.options
|
||||
.map((option, i) => `<option value="${option.key}">${option.label}</option>`)
|
||||
.join('\n');
|
||||
const qualityFiltersHTML = Object.values(QualityFilter.options)
|
||||
.map(option => `<option value="${option.key}">${option.label}</option>`)
|
||||
.join('\n');
|
||||
@@ -277,6 +282,12 @@ function landingTemplate(manifest, config = {}) {
|
||||
${sortOptionsHTML}
|
||||
</select>
|
||||
|
||||
<label class="label" for="iLanguage">Priority language:</label>
|
||||
<select id="iLanguage" class="input" onchange="generateInstallLink()" title="Streams with the selected dubs/subs language will be shown on the top">
|
||||
<option value="none" selected>None</option>
|
||||
${languageOptionsHTML}
|
||||
</select>
|
||||
|
||||
<label class="label" for="iQualityFilter">Exclude qualities/resolutions:</label>
|
||||
<select id="iQualityFilter" class="input" name="qualityFilters[]" multiple="multiple">
|
||||
${qualityFiltersHTML}
|
||||
@@ -356,6 +367,7 @@ function landingTemplate(manifest, config = {}) {
|
||||
$('#iPutioClientId').val("${putioClientId}");
|
||||
$('#iPutioToken').val("${putioToken}");
|
||||
$('#iSort').val("${sort}");
|
||||
$('#iLanguage').val("${language || 'none'}");
|
||||
$('#iLimit').val("${limit}");
|
||||
generateInstallLink();
|
||||
debridProvidersChange();
|
||||
@@ -384,6 +396,7 @@ function landingTemplate(manifest, config = {}) {
|
||||
const providersValue = $('#iProviders').val().join(',') || '';
|
||||
const qualityFilterValue = $('#iQualityFilter').val().join(',') || '';
|
||||
const sortValue = $('#iSort').val() || '';
|
||||
const languageValue = $('#iLanguage').val() || '';
|
||||
const limitValue = $('#iLimit').val() || '';
|
||||
|
||||
const debridOptionsValue = $('#iDebridOptions').val().join(',') || '';
|
||||
@@ -398,6 +411,7 @@ function landingTemplate(manifest, config = {}) {
|
||||
const providers = providersValue.length && providersValue;
|
||||
const qualityFilters = qualityFilterValue.length && qualityFilterValue;
|
||||
const sort = sortValue !== '${SortOptions.options.qualitySeeders.key}' && sortValue;
|
||||
const language = languageValue.length && languageValue !== 'none' && languageValue;
|
||||
const limit = /^[1-9][0-9]*$/.test(limitValue) && limitValue;
|
||||
|
||||
const debridOptions = debridOptionsValue.length && debridOptionsValue.trim();
|
||||
@@ -413,6 +427,7 @@ function landingTemplate(manifest, config = {}) {
|
||||
let configurationValue = [
|
||||
['${Providers.key}', providers],
|
||||
['${SortOptions.key}', sort],
|
||||
['${LanguageOptions.key}', language],
|
||||
['${QualityFilter.key}', qualityFilters],
|
||||
['limit', limit],
|
||||
['${DebridOptions.key}', debridOptions],
|
||||
|
||||
@@ -6,14 +6,14 @@ const languageMapping = {
|
||||
'english': '🇬🇧',
|
||||
'japanese': '🇯🇵',
|
||||
'russian': '🇷🇺',
|
||||
'portuguese': '🇵🇹',
|
||||
'spanish': '🇪🇸',
|
||||
'italian': '🇮🇹',
|
||||
'korean': '🇰🇷',
|
||||
'chinese': '🇨🇳',
|
||||
'french': '🇫🇷',
|
||||
'german': '🇩🇪',
|
||||
'dutch': '🇳🇱',
|
||||
'portuguese': '🇵🇹',
|
||||
'spanish': '🇪🇸',
|
||||
'italian': '🇮🇹',
|
||||
'hindi': '🇮🇳',
|
||||
'telugu': '🇮🇳',
|
||||
'tamil': '🇮🇳',
|
||||
@@ -32,11 +32,13 @@ const languageMapping = {
|
||||
'norwegian': '🇳🇴',
|
||||
'turkish': '🇹🇷',
|
||||
'arabic': '🇸🇦',
|
||||
'persian': '🇮🇷',
|
||||
'hebrew': '🇮🇱',
|
||||
'vietnamese': '🇻🇳',
|
||||
'indonesian': '🇮🇩',
|
||||
'thai': '🇹🇭'
|
||||
}
|
||||
const languages = Object.keys(languageMapping).slice(4);
|
||||
|
||||
function mapLanguages(languages) {
|
||||
const mapped = languages
|
||||
@@ -49,4 +51,8 @@ function mapLanguages(languages) {
|
||||
return [...new Set([].concat(mapped).concat(unmapped))];
|
||||
}
|
||||
|
||||
module.exports = { mapLanguages }
|
||||
function containsLanguage(stream, language) {
|
||||
return stream.title.includes(languageMapping[language]);
|
||||
}
|
||||
|
||||
module.exports = { mapLanguages, containsLanguage, languages }
|
||||
@@ -1,4 +1,5 @@
|
||||
const { QualityFilter } = require('./filter');
|
||||
const { languages, containsLanguage } = require('./languages');
|
||||
|
||||
const OTHER_QUALITIES = QualityFilter.options.find(option => option.key === 'other');
|
||||
const CAM_QUALITIES = QualityFilter.options.find(option => option.key === 'cam');
|
||||
@@ -28,8 +29,25 @@ const SortOptions = {
|
||||
},
|
||||
}
|
||||
}
|
||||
const LanguageOptions = {
|
||||
key: 'language',
|
||||
options: languages.map(lang => ({
|
||||
key: lang,
|
||||
label: lang.charAt(0).toUpperCase() + lang.substr(1)
|
||||
}))
|
||||
}
|
||||
|
||||
function sortStreams(streams, config) {
|
||||
const language = config[LanguageOptions.key];
|
||||
if (language) {
|
||||
const streamsWithLanguage = streams.filter(stream => containsLanguage(stream, language));
|
||||
const streamsNoLanguage = streams.filter(stream => !streamsWithLanguage.includes(stream));
|
||||
return _sortStreams(streamsWithLanguage, config).concat(_sortStreams(streamsNoLanguage, config));
|
||||
}
|
||||
return _sortStreams(streams, config);
|
||||
}
|
||||
|
||||
function _sortStreams(streams, config) {
|
||||
const sort = config.sort && config.sort.toLowerCase() || undefined;
|
||||
const limit = /^[1-9][0-9]*$/.test(config.limit) && parseInt(config.limit) || undefined;
|
||||
if (sort === SortOptions.options.seeders.key) {
|
||||
@@ -137,4 +155,5 @@ function parseSize(sizeText) {
|
||||
}
|
||||
|
||||
module.exports = sortStreams;
|
||||
module.exports.SortOptions = SortOptions;
|
||||
module.exports.SortOptions = SortOptions;
|
||||
module.exports.LanguageOptions = LanguageOptions;
|
||||
Reference in New Issue
Block a user