some small changes for akwam, mycima (#812)

* Update MyCimaProvider.kt

* Update AkwamProvider.kt

* ah
This commit is contained in:
Zaw 2022-03-19 01:24:49 +03:00 committed by GitHub
parent 2cd65246fb
commit 035aa22626
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 30 deletions

View file

@ -2,7 +2,6 @@ package com.lagradost.cloudstream3.movieproviders
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.LoadResponse.Companion.addActors import com.lagradost.cloudstream3.LoadResponse.Companion.addActors
import com.lagradost.cloudstream3.network.AppResponse
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.Qualities import com.lagradost.cloudstream3.utils.Qualities
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
@ -165,10 +164,10 @@ class AkwamProvider : MainAPI() {
} }
// Maybe possible to not use the url shortener but cba investigating that. // // Maybe possible to not use the url shortener but cba investigating that.
private suspend fun skipUrlShortener(url: String): AppResponse { // private suspend fun skipUrlShortener(url: String): AppResponse {
return app.get(app.get(url).document.select("a.download-link").attr("href")) // return app.get(app.get(url).document.select("a.download-link").attr("href"))
} // }
private fun getQualityFromId(id: Int?): Qualities { private fun getQualityFromId(id: Int?): Qualities {
return when (id) { return when (id) {
@ -190,14 +189,15 @@ class AkwamProvider : MainAPI() {
val links = doc.select("div.tab-content.quality").map { val links = doc.select("div.tab-content.quality").map {
val quality = getQualityFromId(it.attr("id").getIntFromText()) val quality = getQualityFromId(it.attr("id").getIntFromText())
it.select(".col-lg-6 > a").map { linkElement -> it.select(".col-lg-6 > a:contains(تحميل)").map { linkElement ->
linkElement.attr("href") to quality if(linkElement.attr("href").contains("/download/")) { linkElement.attr("href") to quality } else {
// Only uses the download links, primarily to prevent unnecessary duplicate requests. "$mainUrl/download${linkElement.attr("href").split("/link")[1]}${data.split("/movie|/episode|/show/episode".toRegex())[1]}" to quality // just in case if they add the shorts urls again
}.filter { link -> link.first.contains("/link/") } }
}
}.flatten() }.flatten()
links.map { links.map {
val linkDoc = skipUrlShortener(it.first).document val linkDoc = app.get(it.first).document
val button = linkDoc.select("div.btn-loader > a") val button = linkDoc.select("div.btn-loader > a")
val url = button.attr("href") val url = button.attr("href")

View file

@ -13,7 +13,7 @@ class MyCimaProvider : MainAPI() {
override var name = "MyCima" override var name = "MyCima"
override val usesWebView = false override val usesWebView = false
override val hasMainPage = true override val hasMainPage = true
override val supportedTypes = setOf(TvType.TvSeries, TvType.Movie) override val supportedTypes = setOf(TvType.TvSeries, TvType.Movie, TvType.Anime)
private fun String.getImageURL(): String? { private fun String.getImageURL(): String? {
return this.replace("--im(age|g):url\\(|\\);".toRegex(), "") return this.replace("--im(age|g):url\\(|\\);".toRegex(), "")
@ -63,9 +63,10 @@ class MyCimaProvider : 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(" ","%20")
val result = arrayListOf<SearchResponse>() val result = arrayListOf<SearchResponse>()
listOf("$mainUrl/search/$q", "$mainUrl/search/$q/list/series/").apmap { url -> listOf("$mainUrl/search/$q",
"$mainUrl/search/$q/list/series/",
"$mainUrl/search/$q/list/anime/").apmap { url ->
val d = app.get(url).document val d = app.get(url).document
if(d.select("a.hoverable.active").text().contains("الانيمي و الكرتون")) return@apmap null
d.select("div.Grid--MycimaPosts div.GridItem").mapNotNull { d.select("div.Grid--MycimaPosts div.GridItem").mapNotNull {
if(it.text().contains("اعلان")) return@mapNotNull null if(it.text().contains("اعلان")) return@mapNotNull null
it.toSearchResponse()?.let { it1 -> result.add(it1) } it.toSearchResponse()?.let { it1 -> result.add(it1) }
@ -88,7 +89,7 @@ class MyCimaProvider : MainAPI() {
val year = doc.select("div.Title--Content--Single-begin h1 a.unline")?.text()?.getIntFromText() val year = doc.select("div.Title--Content--Single-begin h1 a.unline")?.text()?.getIntFromText()
val title = doc.select("div.Title--Content--Single-begin h1").text() val title = doc.select("div.Title--Content--Single-begin h1").text()
.replace("($year)", "") .replace("($year)", "")
.replace("مشاهدة|فيلم|مسلسل|مترجم".toRegex(), "") .replace("مشاهدة|فيلم|مسلسل|مترجم|انمي".toRegex(), "")
// A bit iffy to parse twice like this, but it'll do. // A bit iffy to parse twice like this, but it'll do.
val duration = val duration =
doc.select("ul.Terms--Content--Single-begin li").firstOrNull { doc.select("ul.Terms--Content--Single-begin li").firstOrNull {
@ -106,6 +107,9 @@ class MyCimaProvider : MainAPI() {
?: return@mapNotNull null ?: return@mapNotNull null
Actor(name, image) Actor(name, image)
} }
val recommendations = doc.select("div.Grid--MycimaPosts div.GridItem")?.mapNotNull { element ->
element.toSearchResponse()
}
return if (isMovie) { return if (isMovie) {
newMovieLoadResponse( newMovieLoadResponse(
@ -119,6 +123,7 @@ class MyCimaProvider : MainAPI() {
this.plot = synopsis this.plot = synopsis
this.tags = tags this.tags = tags
this.duration = duration this.duration = duration
this.recommendations = recommendations
addActors(actors) addActors(actors)
} }
} else { } else {
@ -133,14 +138,16 @@ class MyCimaProvider : MainAPI() {
if(moreButton.isNotEmpty()) { if(moreButton.isNotEmpty()) {
val n = doc.select("div.Seasons--Episodes div.Episodes--Seasons--Episodes a").size val n = doc.select("div.Seasons--Episodes div.Episodes--Seasons--Episodes a").size
val totals = doc.select("div.Episodes--Seasons--Episodes a").first().text().getIntFromText() val totals = doc.select("div.Episodes--Seasons--Episodes a").first().text().getIntFromText()
arrayListOf(n, n+40, n+80, n+120, n+160, n+200, n+240, n+280, n+320, n+360) val mEPS = arrayListOf(n, n+40, n+80, n+120, n+160, n+200, n+240, n+280, n+320, n+360, n+400, n+440, n+480, n+520, n+660, n+700, n+740, n+780, n+820, n+860, n+900, n+940, n+980, n+1020, n+1060, n+1100, n+1140, n+1180, n+1220, totals)
.apmap { it -> mEPS.apmap { it ->
if(it > totals!!) return@apmap if (it != null) {
val ajaxURL = "$mainUrl/AjaxCenter/MoreEpisodes/${moreButton.attr("data-term")}/$it" if(it > totals!!) return@apmap
val jsonResponse = app.get(ajaxURL) val ajaxURL = "$mainUrl/AjaxCenter/MoreEpisodes/${moreButton.attr("data-term")}/$it"
val json = parseJson<MoreEPS>(jsonResponse.text) val jsonResponse = app.get(ajaxURL)
val document = Jsoup.parse(json.output?.replace("""\""", "")) val json = parseJson<MoreEPS>(jsonResponse.text)
document.select("a").map { episodes.add(TvSeriesEpisode(it.text(), season, it.text().getIntFromText(), it.attr("href"), null, null)) } val document = Jsoup.parse(json.output?.replace("""\""", ""))
document.select("a").map { episodes.add(TvSeriesEpisode(it.text(), season, it.text().getIntFromText(), it.attr("href"), null, null)) }
}
} }
} }
if(seasons.isNotEmpty()) { if(seasons.isNotEmpty()) {
@ -154,14 +161,16 @@ class MyCimaProvider : MainAPI() {
if(fmoreButton.isNotEmpty()) { if(fmoreButton.isNotEmpty()) {
val n = seasonsite.select("div.Seasons--Episodes div.Episodes--Seasons--Episodes a").size val n = seasonsite.select("div.Seasons--Episodes div.Episodes--Seasons--Episodes a").size
val totals = seasonsite.select("div.Episodes--Seasons--Episodes a").first().text().getIntFromText() val totals = seasonsite.select("div.Episodes--Seasons--Episodes a").first().text().getIntFromText()
arrayListOf(n, n+40, n+80, n+120, n+160, n+200, n+240, n+280, n+320, n+360) val mEPS = arrayListOf(n, n+40, n+80, n+120, n+160, n+200, n+240, n+280, n+320, n+360, n+400, n+440, n+480, n+520, n+660, n+700, n+740, n+780, n+820, n+860, n+900, n+940, n+980, n+1020, n+1060, n+1100, n+1140, n+1180, n+1220, totals)
.apmap { it -> mEPS.apmap { it ->
if(it > totals!!) return@apmap if (it != null) {
val ajaxURL = "$mainUrl/AjaxCenter/MoreEpisodes/${fmoreButton.attr("data-term")}/$it" if(it > totals!!) return@apmap
val jsonResponse = app.get(ajaxURL) val ajaxURL = "$mainUrl/AjaxCenter/MoreEpisodes/${fmoreButton.attr("data-term")}/$it"
val json = parseJson<MoreEPS>(jsonResponse.text) val jsonResponse = app.get(ajaxURL)
val document = Jsoup.parse(json.output?.replace("""\""", "")) val json = parseJson<MoreEPS>(jsonResponse.text)
document.select("a").map { episodes.add(TvSeriesEpisode(it.text(), fseason, it.text().getIntFromText(), it.attr("href"), null, null)) } val document = Jsoup.parse(json.output?.replace("""\""", ""))
document.select("a").map { episodes.add(TvSeriesEpisode(it.text(), fseason, it.text().getIntFromText(), it.attr("href"), null, null)) }
}
} }
} else return@apmap } else return@apmap
} }
@ -172,6 +181,7 @@ class MyCimaProvider : MainAPI() {
this.tags = tags this.tags = tags
this.year = year this.year = year
this.plot = synopsis this.plot = synopsis
this.recommendations = recommendations
addActors(actors) addActors(actors)
} }
} }