2022-08-16 20:11:46 +00:00
|
|
|
package com.faselhd
|
|
|
|
|
|
|
|
|
|
|
|
import com.lagradost.cloudstream3.*
|
|
|
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
2022-08-28 12:36:55 +00:00
|
|
|
import com.lagradost.nicehttp.requestCreator
|
|
|
|
import com.lagradost.cloudstream3.network.WebViewResolver
|
|
|
|
import com.lagradost.cloudstream3.utils.M3u8Helper
|
2022-08-30 09:52:41 +00:00
|
|
|
import com.lagradost.cloudstream3.utils.Qualities
|
|
|
|
import com.lagradost.cloudstream3.network.CloudflareKiller
|
2022-08-16 20:11:46 +00:00
|
|
|
import org.jsoup.nodes.Element
|
|
|
|
|
|
|
|
class FaselHD : MainAPI() {
|
|
|
|
override var lang = "ar"
|
|
|
|
override var mainUrl = "https://faselhd.io"
|
|
|
|
override var name = "FaselHD"
|
|
|
|
override val usesWebView = false
|
|
|
|
override val hasMainPage = true
|
|
|
|
override val supportedTypes = setOf(TvType.TvSeries, TvType.Movie, TvType.AsianDrama, TvType.Anime)
|
2022-08-28 12:36:55 +00:00
|
|
|
|
2022-08-16 20:11:46 +00:00
|
|
|
private fun String.getIntFromText(): Int? {
|
|
|
|
return Regex("""\d+""").find(this)?.groupValues?.firstOrNull()?.toIntOrNull()
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun Element.toSearchResponse(): SearchResponse? {
|
|
|
|
val url = select("div.postDiv a").attr("href") ?: return null
|
|
|
|
val posterUrl = select("div.postDiv a div img").attr("data-src") ?:
|
|
|
|
select("div.postDiv a div img").attr("src")
|
|
|
|
val title = select("div.postDiv a div img").attr("alt")
|
|
|
|
val quality = select(".quality").first()?.text()?.replace("1080p |-".toRegex(), "")
|
|
|
|
val type = if(title.contains("فيلم")) TvType.Movie else TvType.TvSeries
|
|
|
|
return MovieSearchResponse(
|
|
|
|
title.replace("الموسم الأول|برنامج|فيلم|مترجم|اون لاين|مسلسل|مشاهدة|انمي|أنمي".toRegex(),""),
|
|
|
|
url,
|
|
|
|
this@FaselHD.name,
|
|
|
|
type,
|
|
|
|
posterUrl,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
quality = getQualityFromString(quality)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
override val mainPage = mainPageOf(
|
|
|
|
"$mainUrl/all-movies/page/" to "Movies",
|
|
|
|
"$mainUrl/series/page/" to "Series",
|
|
|
|
"$mainUrl/movies_top_imdb/page/" to "Top Movies IMDB",
|
|
|
|
)
|
|
|
|
|
|
|
|
override suspend fun getMainPage(page: Int, request : MainPageRequest): HomePageResponse {
|
2022-10-27 21:21:41 +00:00
|
|
|
var doc = app.get(request.data + page).document
|
|
|
|
if(doc.select("title").text() === "Just a moment...") doc = app.get(request.data + page, interceptor = CloudflareKiller()).document
|
2022-08-16 20:11:46 +00:00
|
|
|
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()
|
|
|
|
}
|
|
|
|
return newHomePageResponse(request.name, list)
|
|
|
|
}
|
|
|
|
|
|
|
|
override suspend fun search(query: String): List<SearchResponse> {
|
|
|
|
val q = query.replace(" ","+")
|
2022-10-27 21:21:41 +00:00
|
|
|
var d = app.get("$mainUrl/?s=$q").document
|
|
|
|
if(d.select("title").text() === "Just a moment...") d = app.get("$mainUrl/?s=$q", interceptor = CloudflareKiller()).document
|
2022-08-16 20:11:46 +00:00
|
|
|
return d.select("div[id=\"postList\"] div[class=\"col-xl-2 col-lg-2 col-md-3 col-sm-3\"]")
|
|
|
|
.mapNotNull {
|
|
|
|
it.toSearchResponse()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
override suspend fun load(url: String): LoadResponse {
|
2022-10-27 21:21:41 +00:00
|
|
|
var doc = app.get(url).document
|
|
|
|
if(doc.select("title").text() === "Just a moment...") doc = app.get(url, interceptor = CloudflareKiller()).document
|
2022-08-16 20:11:46 +00:00
|
|
|
val isMovie = doc.select("div.epAll").isEmpty()
|
|
|
|
val posterUrl = doc.select("div.posterImg img").attr("src")
|
|
|
|
.ifEmpty { doc.select("div.seasonDiv.active img").attr("data-src") }
|
|
|
|
|
|
|
|
val year = doc.select("div[id=\"singleList\"] div[class=\"col-xl-6 col-lg-6 col-md-6 col-sm-6\"]").firstOrNull {
|
|
|
|
it.text().contains("سنة|موعد".toRegex())
|
|
|
|
}?.text()?.getIntFromText()
|
|
|
|
|
|
|
|
val title =
|
|
|
|
doc.select("title").text().replace(" - فاصل إعلاني", "")
|
|
|
|
.replace("الموسم الأول|برنامج|فيلم|مترجم|اون لاين|مسلسل|مشاهدة|انمي|أنمي|$year".toRegex(),"")
|
|
|
|
// A bit iffy to parse twice like this, but it'll do.
|
|
|
|
val duration = doc.select("div[id=\"singleList\"] div[class=\"col-xl-6 col-lg-6 col-md-6 col-sm-6\"]").firstOrNull {
|
|
|
|
it.text().contains("مدة|توقيت".toRegex())
|
|
|
|
}?.text()?.getIntFromText()
|
|
|
|
|
|
|
|
val tags = doc.select("div[id=\"singleList\"] div[class=\"col-xl-6 col-lg-6 col-md-6 col-sm-6\"]:contains(تصنيف الفيلم) a").map {
|
|
|
|
it.text()
|
|
|
|
}
|
|
|
|
val recommendations = doc.select("div#postList div.postDiv").mapNotNull {
|
|
|
|
it.toSearchResponse()
|
|
|
|
}
|
|
|
|
val synopsis = doc.select("div.singleDesc p").text()
|
|
|
|
return if (isMovie) {
|
|
|
|
newMovieLoadResponse(
|
|
|
|
title,
|
|
|
|
url,
|
|
|
|
TvType.Movie,
|
|
|
|
url
|
|
|
|
) {
|
|
|
|
this.posterUrl = posterUrl
|
|
|
|
this.year = year
|
|
|
|
this.plot = synopsis
|
|
|
|
this.duration = duration
|
|
|
|
this.tags = tags
|
|
|
|
this.recommendations = recommendations
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
val episodes = ArrayList<Episode>()
|
|
|
|
doc.select("div.epAll a").map {
|
|
|
|
episodes.add(
|
|
|
|
Episode(
|
|
|
|
it.attr("href"),
|
|
|
|
it.text(),
|
|
|
|
doc.select("div.seasonDiv.active div.title").text().getIntFromText() ?: 1,
|
|
|
|
it.text().getIntFromText(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
doc.select("div[id=\"seasonList\"] div[class=\"col-xl-2 col-lg-3 col-md-6\"] div.seasonDiv")
|
|
|
|
.not(".active").apmap { it ->
|
|
|
|
val s = app.get("$mainUrl/?p="+it.attr("data-href")).document
|
|
|
|
s.select("div.epAll a").map {
|
|
|
|
episodes.add(
|
|
|
|
Episode(
|
|
|
|
it.attr("href"),
|
|
|
|
it.text(),
|
|
|
|
s.select("div.seasonDiv.active div.title").text().getIntFromText(),
|
|
|
|
it.text().getIntFromText(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
newTvSeriesLoadResponse(title, url, TvType.TvSeries, episodes.distinct().sortedBy { it.episode }) {
|
|
|
|
this.duration = duration
|
|
|
|
this.posterUrl = posterUrl
|
|
|
|
this.year = year
|
|
|
|
this.plot = synopsis
|
|
|
|
this.tags = tags
|
|
|
|
this.recommendations = recommendations
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override suspend fun loadLinks(
|
|
|
|
data: String,
|
|
|
|
isCasting: Boolean,
|
|
|
|
subtitleCallback: (SubtitleFile) -> Unit,
|
|
|
|
callback: (ExtractorLink) -> Unit
|
|
|
|
): Boolean {
|
2022-10-27 21:21:41 +00:00
|
|
|
var doc = app.get(data).document
|
|
|
|
if(doc.select("title").text() === "Just a moment...") doc = app.get(data, interceptor = CloudflareKiller()).document
|
2022-09-01 09:02:44 +00:00
|
|
|
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") {
|
2022-09-02 21:26:23 +00:00
|
|
|
val player = app.post(url, interceptor = CloudflareKiller(), referer = mainUrl).document
|
2022-09-01 09:02:44 +00:00
|
|
|
callback.invoke(
|
|
|
|
ExtractorLink(
|
|
|
|
this.name,
|
|
|
|
this.name + " Download Source",
|
|
|
|
player.select("div.dl-link a").attr("href"),
|
|
|
|
this.mainUrl,
|
|
|
|
Qualities.Unknown.value
|
|
|
|
)
|
|
|
|
)
|
|
|
|
} else if(method == "iframe") {
|
|
|
|
val webView = WebViewResolver(
|
|
|
|
Regex("""master\.m3u8""")
|
|
|
|
).resolveUsingWebView(
|
|
|
|
requestCreator(
|
|
|
|
"GET", url, referer = mainUrl
|
|
|
|
)
|
|
|
|
).first
|
|
|
|
M3u8Helper.generateM3u8(
|
|
|
|
this.name,
|
|
|
|
webView?.url.toString(),
|
|
|
|
referer = mainUrl
|
|
|
|
).forEach(callback)
|
|
|
|
}
|
|
|
|
}
|
2022-08-16 20:11:46 +00:00
|
|
|
return true
|
|
|
|
}
|
2022-08-21 19:00:08 +00:00
|
|
|
}
|