fixed lang and AllMoviesForYouProvider.kt

This commit is contained in:
LagradOst 2021-09-24 19:13:13 +02:00
parent c04b1a0d51
commit c4328ccd3c
2 changed files with 46 additions and 4 deletions

View file

@ -7,6 +7,7 @@ import com.lagradost.cloudstream3.utils.Qualities
import com.lagradost.cloudstream3.utils.loadExtractor import com.lagradost.cloudstream3.utils.loadExtractor
import org.jsoup.Jsoup import org.jsoup.Jsoup
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
import java.lang.Thread.sleep
import java.net.URLDecoder import java.net.URLDecoder
class AllMoviesForYouProvider : MainAPI() { class AllMoviesForYouProvider : MainAPI() {
@ -173,7 +174,41 @@ class AllMoviesForYouProvider : MainAPI() {
} else if (data.startsWith(mainUrl) && data != mainUrl) { } else if (data.startsWith(mainUrl) && data != mainUrl) {
val realDataUrl = URLDecoder.decode(data, "application/x-www-form-urlencoded") val realDataUrl = URLDecoder.decode(data, "application/x-www-form-urlencoded")
if (data.contains("trdownload")) { if (data.contains("trdownload")) {
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)) callback(ExtractorLink(this.name, this.name, realDataUrl, mainUrl, Qualities.Unknown.value))
}
return true return true
} }
val response = khttp.get(realDataUrl) val response = khttp.get(realDataUrl)

View file

@ -110,16 +110,23 @@ class SettingsFragment : PreferenceFragmentCompat() {
currentList.add(allLangs.indexOf(i)) 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( context?.showMultiDialog(
names, names.map { it.second },
currentList, currentList,
getString(R.string.provider_lang_settings), getString(R.string.provider_lang_settings),
{}) { selectedList -> {}) { selectedList ->
settingsManager.edit().putStringSet( settingsManager.edit().putStringSet(
this.getString(R.string.provider_lang_key), this.getString(R.string.provider_lang_key),
selectedList.map { names[it] }.toMutableSet() selectedList.map { names[it].first }.toMutableSet()
).apply() ).apply()
} }
} }