mirror of
https://github.com/recloudstream/cloudstream-extensions-multilingual.git
synced 2024-08-15 03:15:14 +00:00
Fixes and Improvements
This commit is contained in:
parent
94462ea208
commit
eda7ca36a2
2 changed files with 137 additions and 84 deletions
|
@ -1,5 +1,5 @@
|
|||
// use an integer for version numbers
|
||||
version = 2
|
||||
version = 3
|
||||
|
||||
|
||||
cloudstream {
|
||||
|
@ -22,4 +22,5 @@ cloudstream {
|
|||
"Movie",
|
||||
)
|
||||
|
||||
iconUrl = "https://www.google.com/s2/favicons?domain=casacinema.lol&sz=%size%"
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.lagradost.cloudstream3.utils.ExtractorLink
|
|||
import com.lagradost.cloudstream3.utils.ShortLink.unshorten
|
||||
import com.lagradost.cloudstream3.utils.loadExtractor
|
||||
import org.jsoup.nodes.Element
|
||||
import android.util.Log
|
||||
|
||||
class CasaCinemaProvider : MainAPI() { // all providers must be an instance of MainAPI
|
||||
override var mainUrl = "https://casacinema.lol/"
|
||||
|
@ -32,50 +33,12 @@ class CasaCinemaProvider : MainAPI() { // all providers must be an instance of M
|
|||
|
||||
val url = request.data + page
|
||||
|
||||
val soup = app.get(url).document
|
||||
val soup = app.get(url, referer = mainUrl).document
|
||||
val home = soup.select("ul.posts>li").mapNotNull { it.toSearchResult() }
|
||||
val hasNext = soup.select("div.navigation>ul>li>a").last()?.text() == "Pagina successiva »"
|
||||
return newHomePageResponse(arrayListOf(HomePageList(request.name, home)), hasNext = hasNext)
|
||||
}
|
||||
|
||||
private fun Element.toSearchResult(): SearchResponse {
|
||||
val title =
|
||||
this.selectFirst(".title")?.text()?.replace("[HD]", "")?.substringBefore("(")
|
||||
?: "No title"
|
||||
val isMovie = (this.selectFirst(".title")?.text() ?: "").contains("\\(\\d{4}\\)".toRegex())
|
||||
val link =
|
||||
this.selectFirst("a")?.attr("href") ?: throw ErrorLoadingException("No Link found")
|
||||
|
||||
val quality = this.selectFirst("div.hd")?.text()
|
||||
|
||||
val posterUrl = this.selectFirst("a")?.attr("data-thumbnail")
|
||||
|
||||
if (isMovie) {
|
||||
return newMovieSearchResponse(title, link, TvType.Movie) {
|
||||
addPoster(posterUrl)
|
||||
if (quality != null) {
|
||||
addQuality(quality)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return newTvSeriesSearchResponse(title, link, TvType.TvSeries) {
|
||||
addPoster(posterUrl)
|
||||
if (quality != null) {
|
||||
addQuality(quality)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun Element.toEpisode(season: Int): Episode {
|
||||
val data =
|
||||
this.select("div.fix-table>table>tbody>tr>td>a[target=_blank]")
|
||||
.map { it.attr("href") }
|
||||
.toJson() // isecure.link
|
||||
val epTitle = this.selectFirst("li.other_link>a")?.text() ?: "No Ep. Title 0"
|
||||
val epNum = epTitle.substringAfter("Episodio ").toInt()
|
||||
return Episode(data, epTitle, season, epNum)
|
||||
}
|
||||
|
||||
override suspend fun search(query: String): List<SearchResponse> {
|
||||
val queryFormatted = query.replace(" ", "+")
|
||||
|
@ -84,22 +47,55 @@ class CasaCinemaProvider : MainAPI() { // all providers must be an instance of M
|
|||
return doc.select("ul.posts>li").map { it.toSearchResult() }
|
||||
}
|
||||
|
||||
private fun Element.toSearchResult(): SearchResponse {
|
||||
val title =
|
||||
this.selectFirst(".title")
|
||||
?.text()
|
||||
?.trim()
|
||||
?.replace("[HD]", "")
|
||||
?.replace("\\(\\d{4}\\)".toRegex(), "")
|
||||
?: "No title"
|
||||
val isMovie = (this.selectFirst(".title")?.text() ?: "").contains("\\(\\d{4}\\)".toRegex())
|
||||
val link =
|
||||
this.selectFirst("a")?.attr("href") ?: throw ErrorLoadingException("No Link found")
|
||||
|
||||
val quality = this.selectFirst("div.hd")?.text()
|
||||
val posterUrl = this.selectFirst("a")?.attr("data-thumbnail")
|
||||
|
||||
return if (isMovie) {
|
||||
newMovieSearchResponse(title, link, TvType.Movie) {
|
||||
addPoster(posterUrl)
|
||||
quality?.let { addQuality(it) }
|
||||
}
|
||||
} else {
|
||||
newTvSeriesSearchResponse(title, link, TvType.TvSeries) {
|
||||
addPoster(posterUrl)
|
||||
quality?.let { addQuality(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun load(url: String): LoadResponse {
|
||||
val document = app.get(url).document
|
||||
val document = app.get(url, referer = mainUrl).document
|
||||
val type =
|
||||
if (document.selectFirst("h3")?.text() == "Altri Film:") TvType.Movie
|
||||
else TvType.TvSeries
|
||||
if (document.select("div.seasons-wraper").isNotEmpty()) TvType.TvSeries
|
||||
else TvType.Movie
|
||||
val title =
|
||||
document.selectFirst("div.row > h1")
|
||||
?.text()
|
||||
?.trim()
|
||||
?.replace("[HD]", "")
|
||||
?.substringBefore("(")
|
||||
?.replace("\\(\\d{4}\\)".toRegex(), "")
|
||||
?: "No Title found"
|
||||
val description = document.select("div.element").last()?.text()
|
||||
val year = document.selectFirst("div.element>a.tag")?.text()?.substringBefore("-")
|
||||
val year = document.selectFirst("div.element>a.tag")
|
||||
?.text()
|
||||
?.substringBefore("-")
|
||||
?.substringAfter(",")
|
||||
?.filter { it.isDigit() }
|
||||
val poster = document.selectFirst("img.thumbnail")?.attr("src")
|
||||
val rating = document.selectFirst("div.rating>div.value")?.text()?.trim()?.toRatingInt()
|
||||
|
||||
val recomm = document.select("div.crp_related>ul>li").map { it.toRecommendResult() }
|
||||
if (type == TvType.TvSeries) {
|
||||
val episodeList =
|
||||
document.select("div.accordion>div.accordion-item")
|
||||
|
@ -118,6 +114,7 @@ class CasaCinemaProvider : MainAPI() { // all providers must be an instance of M
|
|||
return newTvSeriesLoadResponse(title, url, TvType.TvSeries, episodeList) {
|
||||
this.year = year?.toIntOrNull()
|
||||
this.plot = description
|
||||
this.recommendations = recomm
|
||||
addPoster(poster)
|
||||
addRating(rating)
|
||||
}
|
||||
|
@ -134,12 +131,67 @@ class CasaCinemaProvider : MainAPI() { // all providers must be an instance of M
|
|||
this.year = year?.toIntOrNull()
|
||||
this.plot = description
|
||||
this.actors = actors
|
||||
this.recommendations = recomm
|
||||
addPoster(poster)
|
||||
addRating(rating)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun Element.toRecommendResult(): SearchResponse {
|
||||
val title =
|
||||
this.selectFirst("span.crp_title")
|
||||
?.text()
|
||||
?.trim()
|
||||
?.replace("[HD]", "")
|
||||
?.replace("\\(\\d{4}\\)".toRegex(), "")
|
||||
?: "No title"
|
||||
val isMovie =
|
||||
(this.selectFirst("span.crp_title")?.text() ?: "").contains("\\(\\d{4}\\)".toRegex())
|
||||
val link =
|
||||
this.selectFirst("a")?.attr("href") ?: throw ErrorLoadingException("No Link found")
|
||||
|
||||
val quality =
|
||||
this.selectFirst("span.crp_title")?.text()?.substringAfter("[")?.substringBefore("]")
|
||||
val posterUrl = this.selectFirst("img")?.attr("src")
|
||||
|
||||
return if (isMovie) {
|
||||
newMovieSearchResponse(title, link, TvType.Movie) {
|
||||
addPoster(posterUrl)
|
||||
if (quality != null) {
|
||||
addQuality(quality)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
newTvSeriesSearchResponse(title, link, TvType.TvSeries) {
|
||||
addPoster(posterUrl)
|
||||
if (quality != null) {
|
||||
addQuality(quality)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun Element.toEpisode(season: Int): Episode {
|
||||
val data =
|
||||
this.select("div.fix-table>table>tbody>tr>td>a[target=_blank]")
|
||||
.map { it.attr("href") }
|
||||
.toJson() // isecure.link
|
||||
val epNum =
|
||||
this.selectFirst("li.season-no")
|
||||
?.text()
|
||||
?.substringAfter("x")
|
||||
?.substringBefore(" ")
|
||||
|
||||
val epTitle =
|
||||
this.selectFirst("li.other_link>a")?.text().orEmpty().ifBlank {
|
||||
"Episodio $epNum"
|
||||
}
|
||||
val posterUrl = this.selectFirst("figure>img")?.attr("src")
|
||||
return Episode(data, epTitle, season, epNum?.toInt(), posterUrl = posterUrl)
|
||||
}
|
||||
|
||||
|
||||
override suspend fun loadLinks(
|
||||
data: String,
|
||||
isCasting: Boolean,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue