2
1
Fork 1
mirror of https://github.com/yoyzo/arab synced 2024-08-15 03:15:00 +00:00

fix cloudflare for faselhd

This commit is contained in:
Zaw 2022-10-28 23:09:16 +02:00
parent 212cf30cdb
commit 31103c783c
2 changed files with 13 additions and 14 deletions

View file

@ -1,4 +1,4 @@
version = 5
version = 6
cloudstream {
description = ""

View file

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