From c4328ccd3c98ce6d15c034edcb6c21ea8824d0c8 Mon Sep 17 00:00:00 2001 From: LagradOst Date: Fri, 24 Sep 2021 19:13:13 +0200 Subject: [PATCH] fixed lang and AllMoviesForYouProvider.kt --- .../movieproviders/AllMoviesForYouProvider.kt | 37 ++++++++++++++++++- .../ui/settings/SettingsFragment.kt | 13 +++++-- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AllMoviesForYouProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AllMoviesForYouProvider.kt index d2e6ca42..5187859e 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AllMoviesForYouProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/AllMoviesForYouProvider.kt @@ -7,6 +7,7 @@ import com.lagradost.cloudstream3.utils.Qualities import com.lagradost.cloudstream3.utils.loadExtractor import org.jsoup.Jsoup import org.jsoup.nodes.Document +import java.lang.Thread.sleep import java.net.URLDecoder class AllMoviesForYouProvider : MainAPI() { @@ -173,7 +174,41 @@ class AllMoviesForYouProvider : MainAPI() { } else if (data.startsWith(mainUrl) && data != mainUrl) { val realDataUrl = URLDecoder.decode(data, "application/x-www-form-urlencoded") if (data.contains("trdownload")) { - callback(ExtractorLink(this.name, this.name, realDataUrl, mainUrl, Qualities.Unknown.value)) + val request = khttp.get(data, stream = true) + if (request.url.startsWith("https://streamhub.to/d/")) { + val document = Jsoup.parse(request.text) + val inputs = document.select("Form > input") + if (inputs.size < 4) return false + var op: String? = null + var id: String? = null + var mode: String? = null + var hash: String? = null + + for (input in inputs) { + val value = input.attr("value") ?: continue + when (input.attr("name")) { + "op" -> op = value + "id" -> id = value + "mode" -> mode = value + "hash" -> hash = value + else -> { + } + } + } + if(op == null || id == null || mode == null || hash == null) { + return false + } + sleep(5000) // ye this is needed, wont work with 0 delay + + val postResponse = khttp.post(request.url, headers = mapOf("content-type" to "application/x-www-form-urlencoded", "referer" to request.url, "user-agent" to USER_AGENT, "accept" to "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"), data = mapOf("op" to op, "id" to id, "mode" to mode, "hash" to hash)) + val postDocument = Jsoup.parse(postResponse.text) + + val url = postDocument.selectFirst("a.downloadbtn").attr("href") + if(url.isNullOrEmpty()) return false + callback(ExtractorLink(this.name, this.name, url, mainUrl, Qualities.Unknown.value)) + } else { + callback(ExtractorLink(this.name, this.name, realDataUrl, mainUrl, Qualities.Unknown.value)) + } return true } val response = khttp.get(realDataUrl) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsFragment.kt index 828ea4e6..223de62b 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsFragment.kt @@ -110,16 +110,23 @@ class SettingsFragment : PreferenceFragmentCompat() { currentList.add(allLangs.indexOf(i)) } - val names = allLangs.mapNotNull { SubtitleHelper.fromTwoLettersToLanguage(it) } + val names = allLangs.mapNotNull { + val fullName = SubtitleHelper.fromTwoLettersToLanguage(it) + if (fullName.isNullOrEmpty()) { + return@mapNotNull null + } + + Pair(it, fullName) + } context?.showMultiDialog( - names, + names.map { it.second }, currentList, getString(R.string.provider_lang_settings), {}) { selectedList -> settingsManager.edit().putStringSet( this.getString(R.string.provider_lang_key), - selectedList.map { names[it] }.toMutableSet() + selectedList.map { names[it].first }.toMutableSet() ).apply() } }