From 7a68d6304fa3284cc5701626dfefbcca01816016 Mon Sep 17 00:00:00 2001 From: reduplicated <110570621+reduplicated@users.noreply.github.com> Date: Wed, 31 Aug 2022 20:08:45 +0200 Subject: [PATCH] fixed subs bug + fixed generator bug + bump 3.1.4 + updated drive link --- app/build.gradle | 2 +- .../lagradost/cloudstream3/AcraApplication.kt | 4 +-- .../cloudstream3/ui/player/GeneratorPlayer.kt | 36 ++++++++++++++----- .../cloudstream3/ui/player/IGenerator.kt | 2 +- .../ui/result/ResultViewModel2.kt | 2 +- 5 files changed, 32 insertions(+), 14 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index c14f0657..b1cb3a6b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -36,7 +36,7 @@ android { targetSdkVersion 30 versionCode 50 - versionName "3.1.3" + versionName "3.1.4" resValue "string", "app_version", "${defaultConfig.versionName}${versionNameSuffix ?: ""}" diff --git a/app/src/main/java/com/lagradost/cloudstream3/AcraApplication.kt b/app/src/main/java/com/lagradost/cloudstream3/AcraApplication.kt index 93469451..49044e06 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/AcraApplication.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/AcraApplication.kt @@ -32,9 +32,9 @@ class CustomReportSender : ReportSender { override fun send(context: Context, errorContent: CrashReportData) { println("Sending report") val url = - "https://docs.google.com/forms/u/0/d/e/1FAIpQLSeFmyBChi6HF3IkhTVWPiDXJtxt8W0Hf4Agljm_0-0_QuEYFg/formResponse" + "https://docs.google.com/forms/u/0/d/e/1FAIpQLSe9Vff8oHGMRXcjgCXZwkjvx3eBdNpn4DzjO0FkcWEU1gEQpA/formResponse" val data = mapOf( - "entry.134906550" to errorContent.toJSON() + "entry.1586460852" to errorContent.toJSON() ) thread { // to not run it on main thread diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt index 8f908465..04d630aa 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt @@ -101,6 +101,7 @@ class GeneratorPlayer : FullScreenPlayer() { private fun setSubtitles(sub: SubtitleData?): Boolean { currentSelectedSubtitles = sub + //Log.i(TAG, "setSubtitles = $sub") return player.setPreferredSubtitles(sub) } @@ -849,17 +850,33 @@ class GeneratorPlayer : FullScreenPlayer() { private fun autoSelectFromSettings(): Boolean { // auto select subtitle based of settings val langCode = preferredAutoSelectSubtitles - if (!langCode.isNullOrEmpty() && player.getCurrentPreferredSubtitle() == null) { - getAutoSelectSubtitle(currentSubs, settings = true, downloads = false)?.let { sub -> - context?.let { ctx -> - if (setSubtitles(sub)) { - player.saveData() - player.reloadPlayer(ctx) - player.handleEvent(CSPlayerEvent.Play) - return true + val current = player.getCurrentPreferredSubtitle() + Log.i(TAG, "autoSelectFromSettings = $current") + context?.let { ctx -> + if (current != null) { + if (setSubtitles(current)) { + player.saveData() + player.reloadPlayer(ctx) + player.handleEvent(CSPlayerEvent.Play) + return true + } + } else + if (!langCode.isNullOrEmpty()) { + getAutoSelectSubtitle( + currentSubs, + settings = true, + downloads = false + )?.let { sub -> + + if (setSubtitles(sub)) { + player.saveData() + player.reloadPlayer(ctx) + player.handleEvent(CSPlayerEvent.Play) + return true + } + } } - } } return false } @@ -881,6 +898,7 @@ class GeneratorPlayer : FullScreenPlayer() { } private fun autoSelectSubtitles() { + //Log.i(TAG, "autoSelectSubtitles") normalSafeApiCall { if (!autoSelectFromSettings()) { autoSelectFromDownloads() diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/IGenerator.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/IGenerator.kt index 219f5502..a1287e6a 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/IGenerator.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/IGenerator.kt @@ -14,7 +14,7 @@ interface IGenerator { fun getCurrentId(): Int? // this is used to save data or read data about this id fun getCurrent(offset : Int = 0): Any? // this is used to get metadata about the current playing, can return null - fun getAll() : List? // thus us used to get the metadata about all entries, not needed + fun getAll() : List? // this us used to get the metadata about all entries, not needed /* not safe, must use try catch */ suspend fun generateLinks( diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt index e26265ec..b7e36f21 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt @@ -1226,7 +1226,7 @@ class ResultViewModel2 : ViewModel() { it.getAll() // I know kinda shit to itterate all, but it is 100% sure to work ?.indexOfFirst { value -> value is ResultEpisode && value.id == click.data.id } ?.let { index -> - if (index > 0) + if (index >= 0) it.goto(index) }