fix cloudflare for faselhd
This commit is contained in:
parent
212cf30cdb
commit
31103c783c
2 changed files with 13 additions and 14 deletions
|
@ -1,4 +1,4 @@
|
||||||
version = 5
|
version = 6
|
||||||
|
|
||||||
cloudstream {
|
cloudstream {
|
||||||
description = ""
|
description = ""
|
||||||
|
|
|
@ -13,10 +13,12 @@ import org.jsoup.nodes.Element
|
||||||
class FaselHD : MainAPI() {
|
class FaselHD : MainAPI() {
|
||||||
override var lang = "ar"
|
override var lang = "ar"
|
||||||
override var mainUrl = "https://faselhd.io"
|
override var mainUrl = "https://faselhd.io"
|
||||||
|
private val alternativeUrl = "https://www.faselhd.club"
|
||||||
override var name = "FaselHD"
|
override var name = "FaselHD"
|
||||||
override val usesWebView = false
|
override val usesWebView = false
|
||||||
override val hasMainPage = true
|
override val hasMainPage = true
|
||||||
override val supportedTypes = setOf(TvType.TvSeries, TvType.Movie, TvType.AsianDrama, TvType.Anime)
|
override val supportedTypes = setOf(TvType.TvSeries, TvType.Movie, TvType.AsianDrama, TvType.Anime)
|
||||||
|
private val cfKiller = CloudflareKiller()
|
||||||
|
|
||||||
private fun String.getIntFromText(): Int? {
|
private fun String.getIntFromText(): Int? {
|
||||||
return Regex("""\d+""").find(this)?.groupValues?.firstOrNull()?.toIntOrNull()
|
return Regex("""\d+""").find(this)?.groupValues?.firstOrNull()?.toIntOrNull()
|
||||||
|
@ -37,7 +39,8 @@ class FaselHD : MainAPI() {
|
||||||
posterUrl,
|
posterUrl,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
quality = getQualityFromString(quality)
|
quality = getQualityFromString(quality),
|
||||||
|
posterHeaders = cfKiller.getCookieHeaders(alternativeUrl).toMap()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
override val mainPage = mainPageOf(
|
override val mainPage = mainPageOf(
|
||||||
|
@ -49,10 +52,8 @@ class FaselHD : MainAPI() {
|
||||||
override suspend fun getMainPage(page: Int, request : MainPageRequest): HomePageResponse {
|
override suspend fun getMainPage(page: Int, request : MainPageRequest): HomePageResponse {
|
||||||
var doc = app.get(request.data + page).document
|
var doc = app.get(request.data + page).document
|
||||||
if(doc.select("title").text() == "Just a moment...") {
|
if(doc.select("title").text() == "Just a moment...") {
|
||||||
println("Found Cloudflare.")
|
doc = app.get(request.data.replace(mainUrl, alternativeUrl) + page, interceptor = cfKiller, timeout = 120).document
|
||||||
doc = app.get(request.data + page, interceptor = CloudflareKiller()).document
|
|
||||||
}
|
}
|
||||||
println("HTML: "+doc.html())
|
|
||||||
val list = doc.select("div[id=\"postList\"] div[class=\"col-xl-2 col-lg-2 col-md-3 col-sm-3\"]")
|
val list = doc.select("div[id=\"postList\"] div[class=\"col-xl-2 col-lg-2 col-md-3 col-sm-3\"]")
|
||||||
.mapNotNull { element ->
|
.mapNotNull { element ->
|
||||||
element.toSearchResponse()
|
element.toSearchResponse()
|
||||||
|
@ -64,8 +65,7 @@ class FaselHD : MainAPI() {
|
||||||
val q = query.replace(" ","+")
|
val q = query.replace(" ","+")
|
||||||
var d = app.get("$mainUrl/?s=$q").document
|
var d = app.get("$mainUrl/?s=$q").document
|
||||||
if(d.select("title").text() == "Just a moment...") {
|
if(d.select("title").text() == "Just a moment...") {
|
||||||
println("Found Cloudflare.")
|
d = app.get("$alternativeUrl/?s=$q", interceptor = cfKiller, timeout = 120).document
|
||||||
d = app.get("$mainUrl/?s=$q", interceptor = CloudflareKiller()).document
|
|
||||||
}
|
}
|
||||||
return d.select("div[id=\"postList\"] div[class=\"col-xl-2 col-lg-2 col-md-3 col-sm-3\"]")
|
return d.select("div[id=\"postList\"] div[class=\"col-xl-2 col-lg-2 col-md-3 col-sm-3\"]")
|
||||||
.mapNotNull {
|
.mapNotNull {
|
||||||
|
@ -77,8 +77,7 @@ class FaselHD : MainAPI() {
|
||||||
override suspend fun load(url: String): LoadResponse {
|
override suspend fun load(url: String): LoadResponse {
|
||||||
var doc = app.get(url).document
|
var doc = app.get(url).document
|
||||||
if(doc.select("title").text() == "Just a moment...") {
|
if(doc.select("title").text() == "Just a moment...") {
|
||||||
println("Found Cloudflare.")
|
doc = app.get(url, interceptor = cfKiller, timeout = 120).document
|
||||||
doc = app.get(url, interceptor = CloudflareKiller()).document
|
|
||||||
}
|
}
|
||||||
val isMovie = doc.select("div.epAll").isEmpty()
|
val isMovie = doc.select("div.epAll").isEmpty()
|
||||||
val posterUrl = doc.select("div.posterImg img").attr("src")
|
val posterUrl = doc.select("div.posterImg img").attr("src")
|
||||||
|
@ -116,6 +115,7 @@ class FaselHD : MainAPI() {
|
||||||
this.duration = duration
|
this.duration = duration
|
||||||
this.tags = tags
|
this.tags = tags
|
||||||
this.recommendations = recommendations
|
this.recommendations = recommendations
|
||||||
|
this.posterHeaders = cfKiller.getCookieHeaders(alternativeUrl).toMap()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val episodes = ArrayList<Episode>()
|
val episodes = ArrayList<Episode>()
|
||||||
|
@ -133,8 +133,7 @@ class FaselHD : MainAPI() {
|
||||||
.not(".active").apmap { it ->
|
.not(".active").apmap { it ->
|
||||||
var s = app.get("$mainUrl/?p="+it.attr("data-href")).document
|
var s = app.get("$mainUrl/?p="+it.attr("data-href")).document
|
||||||
if(s.select("title").text() == "Just a moment...") {
|
if(s.select("title").text() == "Just a moment...") {
|
||||||
println("Found Cloudflare.")
|
s = app.get("$alternativeUrl/?p="+it.attr("data-href"), interceptor = cfKiller).document
|
||||||
s = app.get("$mainUrl/?p="+it.attr("data-href"), interceptor = CloudflareKiller()).document
|
|
||||||
}
|
}
|
||||||
s.select("div.epAll a").map {
|
s.select("div.epAll a").map {
|
||||||
episodes.add(
|
episodes.add(
|
||||||
|
@ -154,6 +153,7 @@ class FaselHD : MainAPI() {
|
||||||
this.plot = synopsis
|
this.plot = synopsis
|
||||||
this.tags = tags
|
this.tags = tags
|
||||||
this.recommendations = recommendations
|
this.recommendations = recommendations
|
||||||
|
this.posterHeaders = cfKiller.getCookieHeaders(alternativeUrl).toMap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,15 +166,14 @@ class FaselHD : MainAPI() {
|
||||||
): Boolean {
|
): Boolean {
|
||||||
var doc = app.get(data).document
|
var doc = app.get(data).document
|
||||||
if(doc.select("title").text() == "Just a moment...") {
|
if(doc.select("title").text() == "Just a moment...") {
|
||||||
println("Found Cloudflare.")
|
doc = app.get(data, interceptor = cfKiller).document
|
||||||
doc = app.get(data, interceptor = CloudflareKiller()).document
|
|
||||||
}
|
}
|
||||||
listOf(
|
listOf(
|
||||||
doc.select(".downloadLinks a").attr("href") to "download",
|
doc.select(".downloadLinks a").attr("href") to "download",
|
||||||
doc.select("iframe[name=\"player_iframe\"]").attr("src") to "iframe"
|
doc.select("iframe[name=\"player_iframe\"]").attr("src") to "iframe"
|
||||||
).apmap { (url, method) ->
|
).apmap { (url, method) ->
|
||||||
if(method == "download") {
|
if(method == "download") {
|
||||||
val player = app.post(url, interceptor = CloudflareKiller(), referer = mainUrl).document
|
val player = app.post(url, interceptor = cfKiller, referer = mainUrl, timeout = 120).document
|
||||||
callback.invoke(
|
callback.invoke(
|
||||||
ExtractorLink(
|
ExtractorLink(
|
||||||
this.name,
|
this.name,
|
||||||
|
|
Loading…
Reference in a new issue