Add OpenSubtitles support for Brazilian Portuguese

This commit is contained in:
Blatzar 2022-08-20 18:08:39 +02:00
parent 4bb15a61c2
commit 1b129920f3
3 changed files with 13 additions and 6 deletions

View file

@ -143,8 +143,9 @@ class OpenSubtitlesApi(index: Int) : InAppAuthAPIManager(index), AbstractSubApi
/**
* Some languages do not use the normal country codes on OpenSubtitles
* */
private val languageExceptions = mapOf(
"pt" to "pt-PT"
private val languageExceptions = mapOf<String, String>(
// "pt" to "pt-PT",
// "pt" to "pt-BR"
)
private fun fixLanguage(language: String?) : String? {
return languageExceptions[language] ?: language

View file

@ -734,7 +734,7 @@ class GeneratorPlayer : FullScreenPlayer() {
if ((currentMeta as? ResultEpisode)?.tvType?.isLiveStream() == true) return
val (position, duration) = posDur
if(duration == 0L) return // idk how you achieved this, but div by zero crash
if (duration == 0L) return // idk how you achieved this, but div by zero crash
viewModel.getId()?.let {
DataStoreHelper.setViewPos(it, position, duration)
@ -1015,7 +1015,8 @@ class GeneratorPlayer : FullScreenPlayer() {
limitTitle = settingsManager.getInt(ctx.getString(R.string.prefer_limit_title_key), 0)
updateForcedEncoding(ctx)
filterSubByLang = settingsManager.getBoolean(getString(R.string.filter_sub_lang_key), false)
filterSubByLang =
settingsManager.getBoolean(getString(R.string.filter_sub_lang_key), false)
if (filterSubByLang) {
val langFromPrefMedia = settingsManager.getStringSet(
this.getString(R.string.provider_lang_key),

View file

@ -71,7 +71,8 @@ object SubtitleHelper {
/** ISO_639_1 -> lang*/
fun fromTwoLettersToLanguage(input: String): String? {
if (input.length != 2) return null
// pr-BR
if (input.substringBefore("-").length != 2) return null
if (ISO_639_1Map.isEmpty()) {
initISO6391Map()
}
@ -269,6 +270,8 @@ object SubtitleHelper {
"pl" to "PL",
"ps" to "AF",
"pt" to "PT",
"pt-pt" to "PT",
"pt-br" to "BR",
"rm" to "CH",
"rn" to "BI",
"ro" to "RO",
@ -452,7 +455,9 @@ object SubtitleHelper {
Language639("Persian", "فارسی", "fa", "fas", "", "fas", ""),
Language639("Polish", "język polski, polszczyzna", "pl", "pol", "pol", "pol", "pols"),
Language639("Pashto", "پښتو", "ps", "pus", "pus", "pus", ""),
Language639("Portuguese", "português", "pt", "por", "por", "por", ""),
Language639("Portuguese", "português", "pt-pt", "por", "por", "por", ""),
// Addition to support Brazilian Portuguese properly, might break other things
Language639("Portuguese (Brazilian)", "português", "pt-br", "por", "por", "por", ""),
Language639("Quechua", "Runa Simi, Kichwa", "qu", "que", "que", "que", ""),
Language639("Romansh", "rumantsch grischun", "rm", "roh", "roh", "roh", ""),
Language639("Kirundi", "Ikirundi", "rn", "run", "run", "run", ""),