[addon] updates multi/dual languages handling

This commit is contained in:
TheBeastLT
2020-04-25 11:25:21 +02:00
parent 10615e4aed
commit 5e72683ce4
4 changed files with 12 additions and 6 deletions

View File

@@ -1,6 +1,8 @@
const languageMapping = {
'dubbed': 'Dubbed',
'multi': 'Multi',
'multi audio': 'Multi Audio',
'multi subs': 'Multi Subs',
'dual audio': 'Dual Audio',
'english': '🇬🇧',
'japanese': '🇯🇵',
'korean': '🇰🇷',

View File

@@ -53,9 +53,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 dubbed = torrentInfo.dubbed || fileInfo.dubbed;
let languages = [].concat(torrentLanguages).concat(providerLanguages);
if (record.kitsuId || record.torrent.type === Type.ANIME) {
const dubbed = torrentInfo.dubbed || fileInfo.dubbed || languages.includes('multi');
// no need to display japanese for anime or english if anime is dubbed
languages = languages.concat(dubbed ? ['dubbed'] : [])
.filter(lang => lang !== 'japanese')
@@ -65,6 +65,10 @@ function getLanguages(record, torrentInfo, fileInfo) {
// no need to display languages if only english is present
languages = [];
}
if (languages.length === 0 && dubbed) {
// display dubbed only if there are no other languages defined for non anime
languages = ['dubbed'];
}
return mapLanguages(languages);
}