some fixes

This commit is contained in:
Lazycoder 2022-10-26 17:47:47 +02:00 committed by GitHub
parent e57632ce83
commit 291e405d3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,7 +11,7 @@ import org.jsoup.nodes.Element
class Movizland : MainAPI() { class Movizland : MainAPI() {
override var lang = "ar" override var lang = "ar"
override var mainUrl = "https://new.movizland.cyou" override var mainUrl = "https://movizland.cyou"
override var name = "Movizland" override var name = "Movizland"
override val usesWebView = false override val usesWebView = false
override val hasMainPage = true override val hasMainPage = true
@ -21,12 +21,34 @@ class Movizland : MainAPI() {
return Regex("""\d+""").find(this)?.groupValues?.firstOrNull()?.toIntOrNull() return Regex("""\d+""").find(this)?.groupValues?.firstOrNull()?.toIntOrNull()
} }
private fun String.getSeasonNameFromUrl(): String? {
return Regex("""\/series\/(.+)\/""").find(this)?.groupValues?.getOrNull(1)
}
private fun String.getDomainFromUrl(): String? {
return Regex("""^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:\/\n\?\=]+)""").find(this)?.groupValues?.firstOrNull()
}
private fun String.cleanTitle(): String {
val prefix = setOf("مشاهدة فيلم","مشاهدة وتحميل فيلم","فيلم","انمي","إنمي","مسلسل","برنامج")
val suffix = setOf("مدبلج للعربية","اون لاين","مترجم")
this.let{ clean ->
var aa = clean
prefix.forEach{ pre ->
aa = if (aa.startsWith(pre)) aa.replace(pre,"") else aa }
var bb = aa
suffix.mapNotNull{ suf ->
bb = if (bb.endsWith(suf)) bb.replace(suf,"") else bb }
return bb
}
}
private fun Element.toSearchResponse(): SearchResponse? { private fun Element.toSearchResponse(): SearchResponse? {
val url = select("div.BlockItem") val url = select(".BlockItem")
val title = select("div.BlockTitle").text() val title = url.select(".BlockTitle").text().cleanTitle()
val posterUrl = if (title.contains("فيلم")) {select("div.BlockImageItem img")?.attr("src")} else {select("div.BlockImageItem > img:nth-child(3)")?.attr("src")} val posterUrl = if (url.select(".BlockTitle").text().contains("فيلم")) {select(".BlockImageItem img")?.attr("src")} else {select(".BlockImageItem > img:nth-child(3)")?.attr("src")}
val year = select("ul.InfoEndBlock li").last()?.text()?.getIntFromText() val year = select(".InfoEndBlock li").last()?.text()?.getIntFromText()
var quality = select("ul.RestInformation li").last()?.text()?.replace(" |-|1080p|720p".toRegex(), "") var quality = select(".RestInformation li").last()?.text()?.replace(" |-|1080p|720p".toRegex(), "")
?.replace("WEB DL","WEBDL")?.replace("BluRay","BLURAY") ?.replace("WEB DL","WEBDL")?.replace("BluRay","BLURAY")
return MovieSearchResponse( return MovieSearchResponse(
title, title,
@ -54,7 +76,7 @@ class Movizland : MainAPI() {
} }
override suspend fun search(query: String): List<SearchResponse> { override suspend fun search(query: String): List<SearchResponse> {
val q = query.replace(" ", "%20") val q = query.replace(" ".toRegex(), "%20")
val result = arrayListOf<SearchResponse>() val result = arrayListOf<SearchResponse>()
listOf( listOf(
"$mainUrl/category/movies/?s=$q", "$mainUrl/category/movies/?s=$q",
@ -69,31 +91,56 @@ class Movizland : MainAPI() {
return result.distinct().sortedBy { it.name } return result.distinct().sortedBy { it.name }
} }
/*
private fun Element.toEpisode(): Episode { private fun Element.toEpisode(): Episode {
val a = select("div.BlockItem") val a = select("div.EpisodeItem")
val url = a.select("a")?.attr("href") val url = a.select("a")?.attr("href")
val title = a.select("div.BlockTitle").text() val title = a.text()
val thumbUrl = a.select("div.BlockImageItem img")?.attr("src") //val thumbUrl = a.select("div.BlockImageItem img")?.attr("src")
val Epsnum = a.select("div.EPSNumber").text() val Epsnum = a.select("em").text()
return newEpisode(url) { return newEpisode(url) {
name = title name = title
episode = Epsnum.getIntFromText() episode = Epsnum.getIntFromText()
posterUrl = thumbUrl //posterUrl = thumbUrl
}
} }
}*/
private fun getSeasonFromString(tit: String): Int {
if(tit.contains("الموسم الاول".toRegex())){ return 1 }
else if(tit.contains("الموسم الحادي عشر".toRegex())){ return 11 }
else if(tit.contains("الموسم الثاني عشر".toRegex())){return 12}
else if(tit.contains("الموسم الثالث عشر".toRegex())){return 13}
else if(tit.contains("الموسم الرابع عشر".toRegex())){return 14}
else if(tit.contains("الموسم الخامس عشر".toRegex())){return 15}
else if(tit.contains("الموسم السادس عشر".toRegex())){return 16}
else if(tit.contains("الموسم السابع عشر".toRegex())){return 17}
else if(tit.contains("الموسم الثامن عشر".toRegex())){return 18}
else if(tit.contains("الموسم التاسع عشر".toRegex())){return 19}
else if(tit.contains("الموسم الثاني".toRegex())){ return 2 }
else if(tit.contains("الموسم الثالث".toRegex())){ return 3 }
else if(tit.contains("الموسم الرابع".toRegex())){ return 4 }
else if(tit.contains("الموسم الخامس".toRegex())){ return 5 }
else if(tit.contains("الموسم السادس".toRegex())){ return 6 }
else if(tit.contains("الموسم السابع".toRegex())){ return 7 }
else if(tit.contains("الموسم الثامن".toRegex())){ return 8 }
else if(tit.contains("الموسم التاسع".toRegex())){ return 9 }
else if(tit.contains("الموسم العاشر".toRegex())){ return 10 }
else if(tit.contains("الموسم العشرون".toRegex())){return 20}
else { return 0 }
}
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
val posterUrl = doc.select("img")?.attr("data-src") val sdetails = doc.select(".SingleDetails")
val year = doc.select("div.SingleDetails a").last()?.text()?.getIntFromText() val posterUrl = sdetails.select("img")?.attr("data-src")
val title = doc.select("h2.postTitle").text() val year = sdetails.select("li:has(.fa-clock) a").text()?.getIntFromText()
val isMovie = title.contains("فيلم") val title = doc.select("h2.postTitle").text().cleanTitle()
val isMovie = if(doc.select("h2.postTitle").text().contains("عرض|فيلم".toRegex())) true else false
val synopsis = doc.select("section.story").text() val synopsis = doc.select("section.story").text()
val trailer = doc.select("div.InnerTrailer iframe").attr("data-src") val trailer = doc.select("div.InnerTrailer iframe").attr("data-src")
val tags = doc.select("div.SingleDetails li").map{ it.text() } val tags = sdetails.select("li:has(.fa-film) a").map{ it.text() }
return if (isMovie) { return if (isMovie) {
@ -110,16 +157,82 @@ class Movizland : MainAPI() {
addTrailer(trailer) addTrailer(trailer)
} }
} else { } else {
val episodes = doc.select("div.BlockItem").map { val episodes = ArrayList<Episode>()
it.toEpisode() val pageUrl = doc.select("meta[property='og:url']").attr("content")
val refererUrl = doc.select("body > header > div > div.Logo > a").attr("href")
if(doc.select(".BlockItem a").attr("href").contains("/series/")){//seasons
doc.select(".BlockItem").map { seas ->
seas.select("a").attr("href") }.apmap{
val Sedoc = app.get(it).document
val pagEl = Sedoc.select(".pagination > div > ul > li.active > a").isNotEmpty()
val pagSt = if(pagEl) true else false
if(pagSt){
Sedoc.select(".pagination > div > ul > li:nth-child(n):not(:last-child) a").map{ eppages ->
eppages.attr("href") }.apmap{
val epidoc = app.get(it).document
epidoc.select("div.BlockItem").map{ element ->
episodes.add(
Episode(
element.select("a").attr("href"),
element.select(".BlockTitle").text(),
getSeasonFromString(element.select(".BlockTitle").text()),
element.select(".EPSNumber").text().getIntFromText(),
)
)
}
}
}else{
Sedoc.select(".BlockItem").map{ el ->
episodes.add(
Episode(
el.select("a").attr("href"),
el.select(".BlockTitle").text(),
getSeasonFromString(el.select(".BlockTitle").text()),
el.select(".EPSNumber").text().getIntFromText(),
)
)
}
}
}
} else {//episodes
val pagEl = doc.select(".pagination > div > ul > li.active > a").isNotEmpty()
val pagSt = if(pagEl) true else false
if(pagSt){
doc.select(".pagination > div > ul > li:nth-child(n):not(:last-child) a").map{ eppages ->
eppages.attr("href") }.apmap{
val epidoc = app.get(it).document
epidoc.select("div.BlockItem").map{ element ->
episodes.add(
Episode(
element.select("a").attr("href"),
element.select(".BlockTitle").text(),
getSeasonFromString(element.select(".BlockTitle").text()),
element.select(".EPSNumber").text().getIntFromText(),
)
)
}
}
}else{
doc.select("div.BlockItem").map{ el ->
episodes.add(
Episode(
el.select("a").attr("href"),
el.select(".BlockTitle").text(),
getSeasonFromString(el.select(".BlockTitle").text()),
el.select(".EPSNumber").text().getIntFromText(),
)
)
}
}
} }
newTvSeriesLoadResponse(title, url, TvType.TvSeries, episodes) { newTvSeriesLoadResponse(title, url, TvType.TvSeries, episodes) {
this.posterUrl = posterUrl /*this.posterUrl = posterUrl
this.year = year this.year = year
this.tags = tags this.tags = tags
this.plot = synopsis this.plot = synopsis
addTrailer(trailer) addTrailer(trailer)*/
} }
} }
} }
@ -132,21 +245,10 @@ class Movizland : MainAPI() {
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
): Boolean { ): Boolean {
val doc = app.get(data).document val doc = app.get(data).document
doc.select("code[id*='Embed']").apmap { doc.select("code[id*='Embed'] iframe").apmap {
var sourceUrl = it.select("iframe").attr("data-srcout") var sourceUrl = it.attr("data-srcout")
loadExtractor(sourceUrl, data, subtitleCallback, callback) loadExtractor(sourceUrl, data, subtitleCallback, callback)
} }
doc.select("table tbody tr").map {
callback.invoke(
ExtractorLink(
this.name,
this.name,
it.select("a").attr("href"),
this.mainUrl,
quality = it.select("td:nth-child(2)").text().getIntFromText() ?: Qualities.Unknown.value,
)
)
}
return true return true
} }
} }