diff --git a/app/src/main/assets/scripts/source.js b/app/src/main/assets/scripts/source.js index b5e0f100..ebf42f59 100644 --- a/app/src/main/assets/scripts/source.js +++ b/app/src/main/assets/scripts/source.js @@ -43,18 +43,19 @@ let Type = { let Language = { UNKNOWN: "Unknown", - ARABIC: "Arabic", - SPANISH: "Spanish", - FRENCH: "French", - HINDI: "Hindi", - INDONESIAN: "Indonesian", - KOREAN: "Korean", - PORTBRAZIL: "Portuguese Brazilian", - RUSSIAN: "Russian", - THAI: "Thai", - TURKISH: "Turkish", - VIETNAMESE: "Vietnamese", - ENGLISH: "English" + ARABIC: "ar", + SPANISH: "es", + FRENCH: "fr", + HINDI: "hi", + INDONESIAN: "id", + KOREAN: "ko", + PORTUGUESE: "pt", + PORTBRAZIL: "pt", + RUSSIAN: "ru", + THAI: "th", + TURKISH: "tr", + VIETNAMESE: "vi", + ENGLISH: "en" } class ScriptException extends Error { diff --git a/app/src/main/java/com/futo/platformplayer/Settings.kt b/app/src/main/java/com/futo/platformplayer/Settings.kt index ec425e45..e0f6e96b 100644 --- a/app/src/main/java/com/futo/platformplayer/Settings.kt +++ b/app/src/main/java/com/futo/platformplayer/Settings.kt @@ -324,7 +324,28 @@ class Settings : FragmentedStorageFileJson() { @DropdownFieldOptionsId(R.array.audio_languages) var primaryLanguage: Int = 0; - fun getPrimaryLanguage(context: Context) = context.resources.getStringArray(R.array.audio_languages)[primaryLanguage]; + fun getPrimaryLanguage(context: Context): String? { + return when(primaryLanguage) { + 0 -> "en"; + 1 -> "es"; + 2 -> "de"; + 3 -> "fr"; + 4 -> "ja"; + 5 -> "ko"; + 6 -> "th"; + 7 -> "vi"; + 8 -> "id"; + 9 -> "hi"; + 10 -> "ar"; + 11 -> "tu"; + 12 -> "ru"; + 13 -> "pt"; + 14 -> "zh"; + else -> null + } + } + + //= context.resources.getStringArray(R.array.audio_languages)[primaryLanguage]; @FormField(R.string.default_playback_speed, FieldForm.DROPDOWN, -1, 1) @DropdownFieldOptionsId(R.array.playback_speeds) diff --git a/app/src/main/java/com/futo/platformplayer/activities/MainActivity.kt b/app/src/main/java/com/futo/platformplayer/activities/MainActivity.kt index b919c5c3..294e4fcf 100644 --- a/app/src/main/java/com/futo/platformplayer/activities/MainActivity.kt +++ b/app/src/main/java/com/futo/platformplayer/activities/MainActivity.kt @@ -1,5 +1,6 @@ package com.futo.platformplayer.activities +import android.annotation.SuppressLint import android.content.Context import android.content.Intent import android.content.Intent.FLAG_ACTIVITY_NEW_TASK @@ -852,6 +853,7 @@ class MainActivity : AppCompatActivity, IWithResultLauncher { * Navigate takes a MainFragment, and makes them the current main visible view * A parameter can be provided which becomes available in the onShow of said fragment */ + @SuppressLint("CommitTransaction") fun navigate(segment: MainFragment, parameter: Any? = null, withHistory: Boolean = true, isBack: Boolean = false) { Logger.i(TAG, "Navigate to $segment (parameter=$parameter, withHistory=$withHistory, isBack=$isBack)") @@ -897,11 +899,6 @@ class MainActivity : AppCompatActivity, IWithResultLauncher { } transaction.commitNow(); } else { - //Special cases - if(segment is VideoDetailFragment) { - _fragContainerVideoDetail.visibility = View.VISIBLE; - _fragVideoDetail.maximizeVideoDetail(); - } if(!segment.hasBottomBar) { supportFragmentManager.beginTransaction() diff --git a/app/src/main/java/com/futo/platformplayer/api/http/server/ManagedHttpServer.kt b/app/src/main/java/com/futo/platformplayer/api/http/server/ManagedHttpServer.kt index e4f1cb03..cf4460d7 100644 --- a/app/src/main/java/com/futo/platformplayer/api/http/server/ManagedHttpServer.kt +++ b/app/src/main/java/com/futo/platformplayer/api/http/server/ManagedHttpServer.kt @@ -191,7 +191,7 @@ class ManagedHttpServer(private val _requestedPort: Int = 0) { } } fun addBridgeHandlers(obj: Any, tag: String? = null) { - val tagToUse = tag ?: obj.javaClass.name; + //val tagToUse = tag ?: obj.javaClass.name; val getMethods = obj::class.java.declaredMethods .filter { it.getAnnotation(HttpGET::class.java) != null } .map { Pair(it, it.getAnnotation(HttpGET::class.java)!!) } diff --git a/app/src/main/java/com/futo/platformplayer/api/media/structures/SingleAsyncItemPager.kt b/app/src/main/java/com/futo/platformplayer/api/media/structures/SingleAsyncItemPager.kt index 592ce2e5..fb504ad9 100644 --- a/app/src/main/java/com/futo/platformplayer/api/media/structures/SingleAsyncItemPager.kt +++ b/app/src/main/java/com/futo/platformplayer/api/media/structures/SingleAsyncItemPager.kt @@ -41,7 +41,7 @@ class SingleAsyncItemPager { fun getCurrentItem(scope: CoroutineScope) : Deferred? { synchronized(_requestedPageItems) { if (_currentResultPos >= _requestedPageItems.size) { - val startPos = fillDeferredUntil(_currentResultPos); + fillDeferredUntil(_currentResultPos); if(!_pager.hasMorePages()) { Logger.i("SingleAsyncItemPager", "end of async page reached"); completeRemainder { it?.complete(null) }; @@ -49,7 +49,7 @@ class SingleAsyncItemPager { if(_isRequesting) return _requestedPageItems[_currentResultPos]; _isRequesting = true; - StateApp.instance.scopeOrNull?.launch(Dispatchers.IO) { + scope.launch(Dispatchers.IO) { try { Logger.i("SingleAsyncItemPager", "Started Pager"); val timeForPage = measureTimeMillis { _pager.nextPage() }; diff --git a/app/src/main/java/com/futo/platformplayer/engine/V8Plugin.kt b/app/src/main/java/com/futo/platformplayer/engine/V8Plugin.kt index 7517bddd..95ad1b3a 100644 --- a/app/src/main/java/com/futo/platformplayer/engine/V8Plugin.kt +++ b/app/src/main/java/com/futo/platformplayer/engine/V8Plugin.kt @@ -269,7 +269,7 @@ class V8Plugin { throwExceptionFromV8( config, result.getOrThrow(config, "plugin_type", "V8Plugin"), - result.getOrThrow(config, "message", "V8Plugin"), + context + ":" + result.getOrThrow(config, "message", "V8Plugin"), null, null, codeStripped @@ -280,7 +280,7 @@ class V8Plugin { return result; } catch(scriptEx: JavetCompilationException) { - throw ScriptCompilationException(config, "Compilation: ${scriptEx.message}\n(${scriptEx.scriptingError.lineNumber})[${scriptEx.scriptingError.startColumn}-${scriptEx.scriptingError.endColumn}]: ${scriptEx.scriptingError.sourceLine}", null, codeStripped); + throw ScriptCompilationException(config, "Compilation: [${context}]: ${scriptEx.message}\n(${scriptEx.scriptingError.lineNumber})[${scriptEx.scriptingError.startColumn}-${scriptEx.scriptingError.endColumn}]: ${scriptEx.scriptingError.sourceLine}", null, codeStripped); } catch(executeEx: JavetExecutionException) { if(executeEx.scriptingError?.context?.containsKey("plugin_type") == true) { diff --git a/app/src/main/java/com/futo/platformplayer/helpers/VideoHelper.kt b/app/src/main/java/com/futo/platformplayer/helpers/VideoHelper.kt index 44045431..1625b1e4 100644 --- a/app/src/main/java/com/futo/platformplayer/helpers/VideoHelper.kt +++ b/app/src/main/java/com/futo/platformplayer/helpers/VideoHelper.kt @@ -21,6 +21,7 @@ import com.futo.platformplayer.api.media.models.video.IPlatformVideoDetails import com.futo.platformplayer.api.media.platforms.js.models.sources.JSAudioUrlRangeSource import com.futo.platformplayer.api.media.platforms.js.models.sources.JSVideoUrlRangeSource import com.futo.platformplayer.logging.Logger +import com.futo.platformplayer.others.Language import kotlin.math.abs class VideoHelper { @@ -83,13 +84,14 @@ class VideoHelper { fun selectBestAudioSource(altSources : Iterable, prefContainers : Array, preferredLanguage: String? = null, targetBitrate: Long? = null) : IAudioSource? { val languageToFilter = if(preferredLanguage != null && altSources.any { it.language == preferredLanguage }) { preferredLanguage - } else if(preferredLanguage == null) { - null } else { - "Unknown" + if(altSources.any { it.language == Language.ENGLISH }) + Language.ENGLISH + else + Language.UNKNOWN; } - var usableSources = if(languageToFilter != null && altSources.any { it.language == languageToFilter }) { + var usableSources = if(altSources.any { it.language == languageToFilter }) { altSources.filter { it.language == languageToFilter }.sortedBy { it.bitrate }.toList(); } else { altSources.sortedBy { it.bitrate } diff --git a/app/src/main/java/com/futo/platformplayer/others/Language.kt b/app/src/main/java/com/futo/platformplayer/others/Language.kt index 04a0ba82..0147dd7f 100644 --- a/app/src/main/java/com/futo/platformplayer/others/Language.kt +++ b/app/src/main/java/com/futo/platformplayer/others/Language.kt @@ -1,20 +1,19 @@ package com.futo.platformplayer.others class Language { - //TODO: Do this differently, somehow map them to ids for multilanguage? companion object { val UNKNOWN = "Unknown"; - val ARABIC = "Arabic"; - val SPANISH = "Spanish"; - val FRENCH = "French"; - val HINDI = "Hindi"; - val INDONESIAN = "Indonesian"; - val KOREAN = "Korean"; - val PORTBRAZIL = "Portuguese Brazilian"; - val RUSSIAN = "Russian"; - val THAI = "Thai"; - val TURKISH = "Turkish"; - val VIETNAMESE = "Vietnamese"; - val ENGLISH = "English"; + val ARABIC = "ar"; + val SPANISH = "es"; + val FRENCH = "fr"; + val HINDI = "hi"; + val INDONESIAN = "id"; + val KOREAN = "ko"; + val PORTBRAZIL = "pt"; + val RUSSIAN = "ru"; + val THAI = "th"; + val TURKISH = "tr"; + val VIETNAMESE = "vi"; + val ENGLISH = "en"; } } \ No newline at end of file diff --git a/app/src/main/java/com/futo/platformplayer/states/StateApp.kt b/app/src/main/java/com/futo/platformplayer/states/StateApp.kt index 771c98b0..45e8e069 100644 --- a/app/src/main/java/com/futo/platformplayer/states/StateApp.kt +++ b/app/src/main/java/com/futo/platformplayer/states/StateApp.kt @@ -731,7 +731,6 @@ class StateApp { StatePlatform.instance.reloadClient(context, client.config.id); } catch (e: Throwable) { Logger.e(SourceDetailFragment.TAG, "Failed to reload client.", e) - return@launch; } } } diff --git a/app/src/main/java/com/futo/platformplayer/states/StatePlatform.kt b/app/src/main/java/com/futo/platformplayer/states/StatePlatform.kt index d82d6eff..a9aae85d 100644 --- a/app/src/main/java/com/futo/platformplayer/states/StatePlatform.kt +++ b/app/src/main/java/com/futo/platformplayer/states/StatePlatform.kt @@ -676,7 +676,7 @@ class StatePlatform { } } - fun getChannelContent(baseClient: IPlatformClient, channelUrl: String, isSubscriptionOptimized: Boolean = false, usePooledClients: Int = 0, ignorePlugins: List? = null): IPager { + fun getChannelContent(baseClient: IPlatformClient, channelUrl: String, isSubscriptionOptimized: Boolean = false, usePooledClients: Int = 0): IPager { val clientCapabilities = baseClient.getChannelCapabilities(); val client = if(usePooledClients > 1) _channelClientPool.getClientPooled(baseClient, usePooledClients); @@ -796,7 +796,7 @@ class StatePlatform { fun getChannelContent(channelUrl: String, isSubscriptionOptimized: Boolean = false, usePooledClients: Int = 0, ignorePlugins: List? = null): IPager { Logger.i(TAG, "Platform - getChannelVideos"); val baseClient = getChannelClient(channelUrl, ignorePlugins); - return getChannelContent(baseClient, channelUrl, isSubscriptionOptimized, usePooledClients, ignorePlugins); + return getChannelContent(baseClient, channelUrl, isSubscriptionOptimized, usePooledClients); } fun getChannelContent(channelUrl: String, type: String?, ordering: String = ResultCapabilities.ORDER_CHONOLOGICAL): IPager { val client = getChannelClient(channelUrl); @@ -899,18 +899,13 @@ class StatePlatform { devId = newClient.devID; try { StateDeveloper.instance.initializeDev(devId!!); - var didEnable = false; if (isPrimary) { _primaryClientObj = newClient; _enabledClients.add(0, newClient); newClient.initialize(); - didEnable = true; } else if (isEnabled) { _enabledClients.add(newClient); - if(!didEnable) { - newClient.initialize(); - didEnable = true; - } + newClient.initialize(); } _availableClients.add(newClient); } catch (ex: Exception) { diff --git a/app/src/main/java/com/futo/platformplayer/subscription/SimpleSubscriptionAlgorithm.kt b/app/src/main/java/com/futo/platformplayer/subscription/SimpleSubscriptionAlgorithm.kt index f4a9818e..496dd572 100644 --- a/app/src/main/java/com/futo/platformplayer/subscription/SimpleSubscriptionAlgorithm.kt +++ b/app/src/main/java/com/futo/platformplayer/subscription/SimpleSubscriptionAlgorithm.kt @@ -153,7 +153,7 @@ class SimpleSubscriptionAlgorithm( try { val platformClient = StatePlatform.instance.getChannelClientOrNull(url, toIgnore) ?: continue; val time = measureTimeMillis { - pager = StatePlatform.instance.getChannelContent(platformClient, url, true, threadPool.poolSize, toIgnore); + pager = StatePlatform.instance.getChannelContent(platformClient, url, true, threadPool.poolSize); pager = StateCache.cachePagerResults(scope, pager!!) { onNewCacheHit.emit(sub, it); }; diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 585cdf89..698bc62f 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -701,20 +701,6 @@ استئناف بعد 10 ثوان استئناف دائم - - الإنجليزية - الإسبانية - الفرنسية - الفرنسية - الكورية - التايلاندية - الفيتنامية - الإندونيسية - الهندية - العربية - التركية - الروسية - لا شيء خطأ diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 72d223fb..d8b534ee 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -701,20 +701,6 @@ Nach 10 Sekunden fortsetzen Immer fortsetzen - - Englisch - Spanisch - Französisch - Französisch - Koreanisch - Thailändisch - Vietnamesisch - Indonesisch - Hindi - Arabisch - Türkisch - Russisch - Keine Fehler diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index b73d92bf..e9122c58 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -717,20 +717,6 @@ Reanudar Después de 10s Siempre Reanudar - - Inglés - Español - Francés - Francés - Coreano - Tailandés - Vietnamita - Indonesio - Hindi - Árabe - Turco - Ruso - Ninguno Error diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 2691d5d0..03ab5700 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -701,20 +701,6 @@ Reprendre après 10s Toujours reprendre - - Anglais - Espagnol - Français - Français - Coréen - Thaï - Vietnamien - Indonésien - Hindi - Arabe - Turc - Russe - Aucun Erreur diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index c58233ce..914a95cb 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -701,20 +701,6 @@ 10秒後から再開 常に再開 - - 英語 - スペイン語 - フランス語 - フランス語 - 韓国語 - タイ語 - ベトナム語 - インドネシア語 - ヒンディー語 - アラビア語 - トルコ語 - ロシア語 - なし エラー diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 2124a56c..2b8958d2 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -701,20 +701,6 @@ 10초 후에 이어서 항상 이어서 - - 영어 - 스페인어 - 프랑스어 - 프랑스어 - 한국어 - 태국어 - 베트남어 - 인도네시아어 - 힌디어 - 아랍어 - 터키어 - 러시아어 - 없음 오류 diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 793ff525..5dc7b601 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -701,20 +701,6 @@ Continuar Após 10s Sempre Continuar - - Inglês - Espanhol - Francês - Francês - Coreano - Tailandês - Vietnamita - Indonésio - Hindi - Árabe - Turco - Russo - Nenhum Erro diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index ebc3654b..4c9819fa 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -701,20 +701,6 @@ Продолжить после 10 секунд Всегда продолжать - - Английский - Испанский - Французский - Французский - Корейский - Тайский - Вьетнамский - Индонезийский - Хинди - Арабский - Турецкий - Русский - Нет Ошибка diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 7a0d2f77..9056144d 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -701,20 +701,6 @@ 预览后10秒继续 始终继续 - - 英语 - 西班牙语 - 法语 - 法语 - 韩语 - 泰语 - 越南语 - 印度尼西亚语 - 印地语 - 阿拉伯语 - 土耳其语 - 俄语 - 错误 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index beca95c4..022b423e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -854,8 +854,9 @@ English Spanish + German French - French + Japanese Korean Thai Vietnamese @@ -864,6 +865,8 @@ Arabic Turkish Russian + Portuguese + Chinese FCast diff --git a/app/src/stable/assets/sources/youtube b/app/src/stable/assets/sources/youtube index fc5d17e1..d41cc8e8 160000 --- a/app/src/stable/assets/sources/youtube +++ b/app/src/stable/assets/sources/youtube @@ -1 +1 @@ -Subproject commit fc5d17e19067efc0d28192b43de31f9bc499d288 +Subproject commit d41cc8e848891ef8e949e6d49384b754e7c305c7 diff --git a/app/src/unstable/assets/sources/youtube b/app/src/unstable/assets/sources/youtube index fc5d17e1..d41cc8e8 160000 --- a/app/src/unstable/assets/sources/youtube +++ b/app/src/unstable/assets/sources/youtube @@ -1 +1 @@ -Subproject commit fc5d17e19067efc0d28192b43de31f9bc499d288 +Subproject commit d41cc8e848891ef8e949e6d49384b754e7c305c7