api fix + VPN status + 1 frame issue resolved

This commit is contained in:
LagradOst 2021-08-29 15:10:36 +02:00
parent f02793f62a
commit 08d557a82e
9 changed files with 98 additions and 19 deletions

View file

@ -13,7 +13,7 @@ import java.util.*
const val USER_AGENT =
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
val baseHeader = mapOf("User-Agent" to USER_AGENT)
//val baseHeader = mapOf("User-Agent" to USER_AGENT)
val mapper = JsonMapper.builder().addModule(KotlinModule())
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).build()!!
@ -119,6 +119,8 @@ abstract class MainAPI {
TvType.ONA
)
open val vpnStatus = VPNStatus.None
open fun getMainPage(): HomePageResponse? {
throw NotImplementedError()
}
@ -197,6 +199,12 @@ fun imdbUrlToIdNullable(url: String?): String? {
return imdbUrlToId(url)
}
enum class VPNStatus {
None,
MightBeNeeded,
Torrent,
}
enum class ShowStatus {
Completed,
Ongoing,

View file

@ -10,6 +10,11 @@ class DoodToExtractor : DoodLaExtractor() {
get() = "https://dood.to"
}
class DoodSoExtractor : DoodLaExtractor() {
override val mainUrl: String
get() = "https://dood.so"
}
open class DoodLaExtractor : ExtractorApi() {
override val name: String
get() = "DoodStream"
@ -33,7 +38,16 @@ open class DoodLaExtractor : ExtractorApi() {
val downloadResponse = khttp.get(downloadLink)
Regex("onclick=\"window\\.open\\((['\"])(.*?)(['\"])").find(downloadResponse.text)?.groupValues?.get(2)
?.let { trueLink ->
return listOf(ExtractorLink(trueLink, this.name, trueLink, mainUrl, Qualities.Unknown.value, false)) // links are valid in 8h
return listOf(
ExtractorLink(
trueLink,
this.name,
trueLink,
mainUrl,
Qualities.Unknown.value,
false
)
) // links are valid in 8h
}
}

View file

@ -1,9 +1,12 @@
package com.lagradost.cloudstream3.movieproviders
import com.fasterxml.jackson.module.kotlin.readValue
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.Qualities
import com.lagradost.cloudstream3.utils.loadExtractor
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
class AllMoviesForYouProvider : MainAPI() {
companion object {
@ -47,8 +50,21 @@ class AllMoviesForYouProvider : MainAPI() {
return returnValue
}
private fun getLink(document: String): String? {
return Regex("iframe src=\"(.*?)\"").find(document)?.groupValues?.get(1)
private fun getLink(document: Document): List<String>? {
val list = ArrayList<String>()
Regex("iframe src=\"(.*?)\"").find(document.html())?.groupValues?.get(1)?.let {
list.add(it)
}
document.select("div.OptionBx")?.forEach { element ->
val baseElement = element.selectFirst("> a.Button")
if (element.selectFirst("> p.AAIco-dns")?.text() == "Streamhub") {
baseElement?.attr("href")?.let { href ->
list.add(href)
}
}
}
return if (list.isEmpty()) null else list
}
override fun load(url: String): LoadResponse {
@ -118,7 +134,7 @@ class AllMoviesForYouProvider : MainAPI() {
rating
)
} else {
val data = getLink(response.text)
val data = getLink(document)
?: throw ErrorLoadingException("No Links Found")
return MovieLoadResponse(
@ -126,7 +142,7 @@ class AllMoviesForYouProvider : MainAPI() {
url,
this.name,
type,
data,
mapper.writeValueAsString(data),
backgroundPoster,
year?.toIntOrNull(),
descipt,
@ -145,19 +161,31 @@ class AllMoviesForYouProvider : MainAPI() {
): Boolean {
if (data.startsWith("$mainUrl/episode/")) {
val response = khttp.get(data)
val link = getLink(response.text)
if (link == null || link == data) return false
return loadLinks(link, isCasting, subtitleCallback, callback)
}
if (data.startsWith(mainUrl) && data != mainUrl) {
val response = khttp.get(data.replace("&#038;", "&"))
Regex("<iframe.*?src=\"(.*?)\"").find(response.text)?.groupValues?.get(1)?.let { url ->
loadExtractor(url.trimStart(), data, callback)
getLink(Jsoup.parse(response.text))?.let { links ->
for (link in links) {
if (link == data) continue
loadLinks(link, isCasting, subtitleCallback, callback)
}
return true
}
return false
} else if (data.startsWith(mainUrl) && data != mainUrl) {
val realDataUrl = data.replace("&#038;", "&").replace("&amp;", "&")
if (data.contains("trdownload")) {
callback(ExtractorLink(this.name, this.name, realDataUrl, mainUrl, Qualities.Unknown.value))
return true
}
val response = khttp.get(realDataUrl)
Regex("<iframe.*?src=\"(.*?)\"").find(response.text)?.groupValues?.get(1)?.let { url ->
loadExtractor(url.trimStart(), realDataUrl, callback)
}
return true
} else {
val links = mapper.readValue<List<String>>(data)
for (link in links) {
loadLinks(link, isCasting, subtitleCallback, callback)
}
return true
}
}
}

View file

@ -29,6 +29,9 @@ class TrailersToProvider : MainAPI() {
TvType.TvSeries,
)
override val vpnStatus: VPNStatus
get() = VPNStatus.MightBeNeeded
override fun getMainPage(): HomePageResponse? {
val response = khttp.get(mainUrl)
val document = Jsoup.parse(response.text)

View file

@ -143,7 +143,7 @@ fun ResultEpisode.getWatchProgress(): Float {
class ResultFragment : Fragment() {
companion object {
fun newInstance(url: String, apiName: String, startAction: Int = 0, startValue : Int = 0) =
fun newInstance(url: String, apiName: String, startAction: Int = 0, startValue: Int = 0) =
ResultFragment().apply {
arguments = Bundle().apply {
putString("url", url)
@ -252,6 +252,7 @@ class ResultFragment : Fragment() {
@SuppressLint("SetTextI18n")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
activity?.window?.decorView?.clearFocus()
hideKeyboard()
@ -526,6 +527,7 @@ class ResultFragment : Fragment() {
val isLoaded = when (episodeClick.action) {
ACTION_PLAY_EPISODE_IN_PLAYER -> true
ACTION_CLICK_DEFAULT -> true
ACTION_SHOW_TOAST -> true
ACTION_CHROME_CAST_EPISODE -> requireLinks(true)
ACTION_CHROME_CAST_MIRROR -> requireLinks(true)
else -> requireLinks(false)
@ -841,6 +843,13 @@ class ResultFragment : Fragment() {
if (d is LoadResponse) {
updateVisStatus(2)
result_vpn.text = when (api.vpnStatus) {
VPNStatus.MightBeNeeded -> getString(R.string.vpn_might_be_needed)
VPNStatus.Torrent -> getString(R.string.vpn_torrent)
else -> ""
}
result_vpn.visibility = if (api.vpnStatus == VPNStatus.None) GONE else VISIBLE
result_bookmark_button.text = "Watching"
currentHeaderName = d.name

View file

@ -72,8 +72,11 @@ val extractorApis: Array<ExtractorApi> = arrayOf(
XStreamCdn(),
StreamSB(),
Streamhub(),
DoodLaExtractor(),
// dood extractors
DoodToExtractor(),
DoodSoExtractor(),
DoodLaExtractor(),
)
fun getExtractorApiFromName(name: String): ExtractorApi {

View file

@ -10,6 +10,8 @@
tools:context=".ui.home.HomeFragment">
<FrameLayout
android:visibility="visible"
tools:visibility="gone"
android:id="@+id/home_loading"
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -34,6 +36,7 @@
</FrameLayout>
<LinearLayout
android:visibility="gone"
tools:visibility="gone"
android:id="@+id/home_loading_error"
android:orientation="vertical"
@ -71,6 +74,8 @@
/>
</LinearLayout>
<androidx.core.widget.NestedScrollView
tools:visibility="visible"
android:visibility="gone"
android:id="@+id/home_loaded"
android:layout_width="match_parent"
android:layout_height="match_parent">

View file

@ -18,6 +18,7 @@
android:layout_width="50dp" android:layout_height="50dp">
</ProgressBar>
<LinearLayout
android:visibility="gone"
tools:visibility="gone"
android:id="@+id/result_loading_error"
android:orientation="vertical"
@ -265,7 +266,12 @@
</ImageView>
</LinearLayout>
</GridLayout>
<TextView
android:id="@+id/result_vpn"
android:textSize="15sp"
tools:text="@string/vpn_torrent"
android:layout_width="match_parent" android:layout_height="wrap_content">
</TextView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View file

@ -95,4 +95,7 @@
<string name="action_remove_watching">Remove</string>
<string name="action_open_watching">More Info</string>
<string name="vpn_might_be_needed">A VPN might be needed for this provider to work correctly</string>
<string name="vpn_torrent">This providers is a torrent, a VPN is recommended</string>
</resources>