mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Update MyCimaProvider.kt (#769)
This commit is contained in:
parent
7e3e13c224
commit
3bad9cad5e
1 changed files with 29 additions and 28 deletions
|
@ -16,7 +16,7 @@ class MyCimaProvider : MainAPI() {
|
||||||
override val supportedTypes = setOf(TvType.TvSeries, TvType.Movie)
|
override val supportedTypes = setOf(TvType.TvSeries, TvType.Movie)
|
||||||
|
|
||||||
private fun String.getImageURL(): String? {
|
private fun String.getImageURL(): String? {
|
||||||
return Regex("""--im(age|g):url\((.*?)\);""").find(this)?.groupValues?.getOrNull(2)
|
return this.replace("--im(age|g):url\\(|\\);".toRegex(), "")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun String.getIntFromText(): Int? {
|
private fun String.getIntFromText(): Int? {
|
||||||
|
@ -30,9 +30,7 @@ class MyCimaProvider : MainAPI() {
|
||||||
val year = select("div.GridItem span.year")?.text()
|
val year = select("div.GridItem span.year")?.text()
|
||||||
val title = select("div.Thumb--GridItem strong").text()
|
val title = select("div.Thumb--GridItem strong").text()
|
||||||
.replace("$year", "")
|
.replace("$year", "")
|
||||||
.replace("مشاهدة فيلم","")
|
.replace("مشاهدة|فيلم|مسلسل|مترجم".toRegex(), "")
|
||||||
.replace("مسلسل","")
|
|
||||||
.replace("مترجم","")
|
|
||||||
.replace("( نسخة مدبلجة )"," ( نسخة مدبلجة ) ")
|
.replace("( نسخة مدبلجة )"," ( نسخة مدبلجة ) ")
|
||||||
// If you need to differentiate use the url.
|
// If you need to differentiate use the url.
|
||||||
return MovieSearchResponse(
|
return MovieSearchResponse(
|
||||||
|
@ -90,17 +88,14 @@ 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("مشاهدة فيلم","")
|
.replace("مشاهدة|فيلم|مسلسل|مترجم".toRegex(), "")
|
||||||
.replace("مسلسل","")
|
|
||||||
.replace("مترجم","")
|
|
||||||
.replace("فيلم","")
|
|
||||||
// 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 {
|
||||||
it.text().contains("المدة")
|
it.text().contains("المدة")
|
||||||
}?.text()?.getIntFromText()
|
}?.text()?.getIntFromText()
|
||||||
|
|
||||||
val synopsis = doc.select("div.StoryMovieContent").text() ?: doc.select("div.PostItemContent").text()
|
val synopsis = doc.select("div.StoryMovieContent").text().ifEmpty { doc.select("div.PostItemContent").text() }
|
||||||
|
|
||||||
val tags = doc.select("li:nth-child(3) > p > a").map { it.text() }
|
val tags = doc.select("li:nth-child(3) > p > a").map { it.text() }
|
||||||
|
|
||||||
|
@ -128,20 +123,16 @@ class MyCimaProvider : MainAPI() {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val episodes = ArrayList<TvSeriesEpisode>()
|
val episodes = ArrayList<TvSeriesEpisode>()
|
||||||
val seasons = doc.select("div.List--Seasons--Episodes a").map {
|
val seasons = doc.select("div.List--Seasons--Episodes a").not(".selected").map {
|
||||||
it.attr("href")
|
it.attr("href")
|
||||||
}
|
}
|
||||||
if(seasons.isNotEmpty()) {
|
val moreButton = doc.select("div.MoreEpisodes--Button")
|
||||||
seasons.apmap { surl ->
|
val season = doc.select("div.List--Seasons--Episodes a.selected").text().getIntFromText()
|
||||||
if(surl.contains("%d9%85%d8%af%d8%a8%d9%84%d8%ac")) return@apmap
|
doc.select("div.Seasons--Episodes div.Episodes--Seasons--Episodes a")
|
||||||
val seasonsite = app.get(surl).document
|
|
||||||
val moreButton = seasonsite.select("div.MoreEpisodes--Button")
|
|
||||||
val season = seasonsite.select("div.List--Seasons--Episodes a.selected").text().getIntFromText() ?: 1
|
|
||||||
seasonsite.select("div.Seasons--Episodes div.Episodes--Seasons--Episodes a")
|
|
||||||
.apmap { episodes.add(TvSeriesEpisode(it.text(), season, it.text().getIntFromText(), it.attr("href"), null, null))}
|
.apmap { episodes.add(TvSeriesEpisode(it.text(), season, it.text().getIntFromText(), it.attr("href"), null, null))}
|
||||||
if(moreButton.isNotEmpty()) {
|
if(moreButton.isNotEmpty()) {
|
||||||
val n = seasonsite.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 = seasonsite.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)
|
arrayListOf(n, n+40, n+80, n+120, n+160, n+200, n+240, n+280, n+320, n+360)
|
||||||
.apmap { it ->
|
.apmap { it ->
|
||||||
if(it > totals!!) return@apmap
|
if(it > totals!!) return@apmap
|
||||||
|
@ -151,18 +142,28 @@ class MyCimaProvider : MainAPI() {
|
||||||
val document = Jsoup.parse(json.output?.replace("""\""", ""))
|
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)) }
|
document.select("a").map { episodes.add(TvSeriesEpisode(it.text(), season, it.text().getIntFromText(), it.attr("href"), null, null)) }
|
||||||
}
|
}
|
||||||
} else return@apmap
|
|
||||||
}
|
}
|
||||||
} else {
|
if(seasons.isNotEmpty()) {
|
||||||
doc.select("div.Seasons--Episodes div.Episodes--Seasons--Episodes a").map {
|
seasons.apmap { surl ->
|
||||||
episodes.add(TvSeriesEpisode(
|
if(surl.contains("%d9%85%d8%af%d8%a8%d9%84%d8%ac")) return@apmap
|
||||||
it.text(),
|
val seasonsite = app.get(surl).document
|
||||||
doc.select("div.List--Seasons--Episodes a.selected").text().getIntFromText(),
|
val fmoreButton = seasonsite.select("div.MoreEpisodes--Button")
|
||||||
it.text().getIntFromText(),
|
val fseason = seasonsite.select("div.List--Seasons--Episodes a.selected").text().getIntFromText() ?: 1
|
||||||
it.attr("href"),
|
seasonsite.select("div.Seasons--Episodes div.Episodes--Seasons--Episodes a")
|
||||||
null,
|
.apmap { episodes.add(TvSeriesEpisode(it.text(), fseason, it.text().getIntFromText(), it.attr("href"), null, null))}
|
||||||
null
|
if(fmoreButton.isNotEmpty()) {
|
||||||
))
|
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()
|
||||||
|
arrayListOf(n, n+40, n+80, n+120, n+160, n+200, n+240, n+280, n+320, n+360)
|
||||||
|
.apmap { it ->
|
||||||
|
if(it > totals!!) return@apmap
|
||||||
|
val ajaxURL = "$mainUrl/AjaxCenter/MoreEpisodes/${fmoreButton.attr("data-term")}/$it"
|
||||||
|
val jsonResponse = app.get(ajaxURL)
|
||||||
|
val json = parseJson<MoreEPS>(jsonResponse.text)
|
||||||
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newTvSeriesLoadResponse(title, url, TvType.TvSeries, episodes.distinct().sortedBy { it.episode }) {
|
newTvSeriesLoadResponse(title, url, TvType.TvSeries, episodes.distinct().sortedBy { it.episode }) {
|
||||||
|
|
Loading…
Reference in a new issue