mirror of
https://github.com/recloudstream/cloudstream-extensions-multilingual.git
synced 2024-08-15 03:15:14 +00:00
remove exception, check nextpage and search enhancement
This commit is contained in:
parent
6b20e8642c
commit
1defdd66af
3 changed files with 93 additions and 81 deletions
|
@ -1,5 +1,5 @@
|
||||||
// use an integer for version numbers
|
// use an integer for version numbers
|
||||||
version = 1
|
version = 2
|
||||||
|
|
||||||
|
|
||||||
cloudstream {
|
cloudstream {
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
package com.lagradost
|
package com.lagradost
|
||||||
import com.lagradost.cloudstream3.TvType
|
|
||||||
|
import com.lagradost.cloudstream3.*
|
||||||
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addRating
|
||||||
import com.lagradost.cloudstream3.MainAPI
|
import com.lagradost.cloudstream3.MainAPI
|
||||||
import com.lagradost.cloudstream3.SearchResponse
|
import com.lagradost.cloudstream3.SearchResponse
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.TvType
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
import com.lagradost.cloudstream3.network.CloudflareKiller
|
||||||
import com.lagradost.cloudstream3.utils.loadExtractor
|
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
||||||
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
import com.lagradost.cloudstream3.utils.ShortLink.unshorten
|
import com.lagradost.cloudstream3.utils.ShortLink.unshorten
|
||||||
import com.lagradost.cloudstream3.network.CloudflareKiller
|
import com.lagradost.cloudstream3.utils.loadExtractor
|
||||||
import com.lagradost.cloudstream3.LoadResponse.Companion.addRating
|
|
||||||
import okhttp3.FormBody
|
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
|
|
||||||
|
|
||||||
class CasaCinemaProvider : MainAPI() { // all providers must be an instance of MainAPI
|
class CasaCinemaProvider : MainAPI() { // all providers must be an instance of MainAPI
|
||||||
override var mainUrl = "https://casacinema.lol/"
|
override var mainUrl = "https://casacinema.lol/"
|
||||||
override var name = "CasaCinema"
|
override var name = "CasaCinema"
|
||||||
|
@ -23,36 +22,44 @@ class CasaCinemaProvider : MainAPI() { // all providers must be an instance of M
|
||||||
override val hasMainPage = true
|
override val hasMainPage = true
|
||||||
private val interceptor = CloudflareKiller()
|
private val interceptor = CloudflareKiller()
|
||||||
|
|
||||||
override val mainPage = mainPageOf(
|
override val mainPage =
|
||||||
|
mainPageOf(
|
||||||
"$mainUrl/category/serie-tv/page/" to "Ultime Serie Tv",
|
"$mainUrl/category/serie-tv/page/" to "Ultime Serie Tv",
|
||||||
"$mainUrl/category/film/page/" to "Ultimi Film",
|
"$mainUrl/category/film/page/" to "Ultimi Film",
|
||||||
)
|
)
|
||||||
|
|
||||||
override suspend fun getMainPage(
|
override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse {
|
||||||
page: Int,
|
|
||||||
request: MainPageRequest): HomePageResponse {
|
|
||||||
|
|
||||||
val url = request.data + page
|
val url = request.data + page
|
||||||
|
|
||||||
val soup = app.get(url).document
|
val soup = app.get(url).document
|
||||||
val home = soup.select("ul.posts>li").mapNotNull {
|
val home = soup.select("ul.posts>li").mapNotNull { it.toSearchResult() }
|
||||||
it.toSearchResult()
|
val hasNext = soup.select("div.navigation>ul>li>a").last()?.text() == "Pagina successiva »"
|
||||||
}
|
return newHomePageResponse(arrayListOf(HomePageList(request.name, home)), hasNext = hasNext)
|
||||||
return newHomePageResponse(arrayListOf(HomePageList(request.name, home)), hasNext = true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Element.toSearchResult(): SearchResponse {
|
private fun Element.toSearchResult(): SearchResponse {
|
||||||
val title= this.selectFirst(".title")?.text()?.replace("[HD]","")?.substringBefore("(")?:
|
val title =
|
||||||
throw ErrorLoadingException("No Title found")
|
this.selectFirst(".title")?.text()?.replace("[HD]", "")?.substringBefore("(")
|
||||||
|
?: "No title"
|
||||||
val link = this.selectFirst("a")?.attr("href")?:
|
val isMovie = (this.selectFirst(".title")?.text() ?: "").contains("\\(\\d{4}\\)".toRegex())
|
||||||
throw ErrorLoadingException("No Link found")
|
val link =
|
||||||
|
this.selectFirst("a")?.attr("href") ?: throw ErrorLoadingException("No Link found")
|
||||||
|
|
||||||
val quality = this.selectFirst("div.hd")?.text()
|
val quality = this.selectFirst("div.hd")?.text()
|
||||||
|
|
||||||
val posterUrl = this.selectFirst("a")?.attr("data-thumbnail")
|
val posterUrl = this.selectFirst("a")?.attr("data-thumbnail")
|
||||||
|
|
||||||
return newTvSeriesSearchResponse(title, link, TvType.TvSeries){
|
if(isMovie){
|
||||||
|
return newMovieSearchResponse(title, link, TvType.Movie) {
|
||||||
|
addPoster(posterUrl)
|
||||||
|
if (quality != null) {
|
||||||
|
addQuality(quality)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return newTvSeriesSearchResponse(title, link, TvType.TvSeries) {
|
||||||
addPoster(posterUrl)
|
addPoster(posterUrl)
|
||||||
if (quality != null) {
|
if (quality != null) {
|
||||||
addQuality(quality)
|
addQuality(quality)
|
||||||
|
@ -60,50 +67,57 @@ class CasaCinemaProvider : MainAPI() { // all providers must be an instance of M
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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()?: throw ErrorLoadingException("No Episode Name")
|
|
||||||
val epNum = epTitle.substringAfter("Episodio ").toInt()
|
|
||||||
return Episode(
|
|
||||||
data,
|
|
||||||
epTitle,
|
|
||||||
season,
|
|
||||||
epNum
|
|
||||||
|
|
||||||
)
|
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> {
|
override suspend fun search(query: String): List<SearchResponse> {
|
||||||
val queryFormatted = query.replace(" ", "+")
|
val queryFormatted = query.replace(" ", "+")
|
||||||
val url = "$mainUrl/?s=$queryFormatted"
|
val url = "$mainUrl/?s=$queryFormatted"
|
||||||
val doc = app.get(url,referer= mainUrl, interceptor=interceptor).document
|
val doc = app.get(url, referer = mainUrl, interceptor = interceptor).document
|
||||||
return doc.select("ul.posts>li").map {
|
return doc.select("ul.posts>li").map { it.toSearchResult() }
|
||||||
it.toSearchResult()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun load(url: String): LoadResponse {
|
override suspend fun load(url: String): LoadResponse {
|
||||||
val document = app.get(url).document
|
val document = app.get(url).document
|
||||||
val type = if (document.selectFirst("h3")?.text() == "Altri Film:") TvType.Movie else TvType.TvSeries
|
val type =
|
||||||
val title = document.selectFirst("div.row > h1")?.text()?.replace("[HD]","")?.substringBefore("(")?: throw ErrorLoadingException("No Title found")
|
if (document.selectFirst("h3")?.text() == "Altri Film:") TvType.Movie
|
||||||
|
else TvType.TvSeries
|
||||||
|
val title =
|
||||||
|
document.selectFirst("div.row > h1")
|
||||||
|
?.text()
|
||||||
|
?.replace("[HD]", "")
|
||||||
|
?.substringBefore("(")
|
||||||
|
?: throw ErrorLoadingException("No Title found")
|
||||||
val description = document.select("div.element").last()?.text()
|
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("-")
|
||||||
val poster = document.selectFirst("img.thumbnail")?.attr("src")
|
val poster = document.selectFirst("img.thumbnail")?.attr("src")
|
||||||
val rating = document.selectFirst("div.rating>div.value")?.text()?.trim()?.toRatingInt()
|
val rating = document.selectFirst("div.rating>div.value")?.text()?.trim()?.toRatingInt()
|
||||||
|
|
||||||
if (type == TvType.TvSeries) {
|
if (type == TvType.TvSeries) {
|
||||||
val episodeList = document.select("div.accordion>div.accordion-item").map { element ->
|
val episodeList =
|
||||||
val season = element.selectFirst("li.s_title>span.season-title")?.text()?.toIntOrNull()?:throw ErrorLoadingException("No Season found")
|
document.select("div.accordion>div.accordion-item")
|
||||||
element.select("div.episode-wrap").map{ episode ->
|
.map { element ->
|
||||||
|
val season =
|
||||||
|
element.selectFirst("li.s_title>span.season-title")
|
||||||
|
?.text()
|
||||||
|
?.toIntOrNull()
|
||||||
|
?: throw ErrorLoadingException("No Season found")
|
||||||
|
element.select("div.episode-wrap").map { episode ->
|
||||||
episode.toEpisode(season)
|
episode.toEpisode(season)
|
||||||
}
|
}
|
||||||
}.flatten()
|
}
|
||||||
|
.flatten()
|
||||||
|
|
||||||
return newTvSeriesLoadResponse(
|
return newTvSeriesLoadResponse(title, url, TvType.TvSeries, episodeList) {
|
||||||
title,
|
|
||||||
url,
|
|
||||||
TvType.TvSeries,
|
|
||||||
episodeList){
|
|
||||||
this.year = year?.toIntOrNull()
|
this.year = year?.toIntOrNull()
|
||||||
this.plot = description
|
this.plot = description
|
||||||
addPoster(poster)
|
addPoster(poster)
|
||||||
|
@ -112,17 +126,14 @@ class CasaCinemaProvider : MainAPI() { // all providers must be an instance of M
|
||||||
} else {
|
} else {
|
||||||
val actors: List<ActorData> =
|
val actors: List<ActorData> =
|
||||||
document.select("div.cast_wraper>ul>li").map { actordata ->
|
document.select("div.cast_wraper>ul>li").map { actordata ->
|
||||||
val actorName = actordata.selectFirst("strong")?.text()?:throw ErrorLoadingException("No Actor name found")
|
val actorName =
|
||||||
val actorImage : String? = actordata.selectFirst("figure>img")?.attr("src")
|
actordata.selectFirst("strong")?.text()
|
||||||
|
?: throw ErrorLoadingException("No Actor name found")
|
||||||
|
val actorImage: String? = actordata.selectFirst("figure>img")?.attr("src")
|
||||||
ActorData(actor = Actor(actorName, image = actorImage))
|
ActorData(actor = Actor(actorName, image = actorImage))
|
||||||
}
|
}
|
||||||
val data = document.select(".embed-player").map { it.attr("data-id") }.toJson()
|
val data = document.select(".embed-player").map { it.attr("data-id") }.toJson()
|
||||||
return newMovieLoadResponse(
|
return newMovieLoadResponse(title, data, TvType.Movie, data) {
|
||||||
title,
|
|
||||||
data,
|
|
||||||
TvType.Movie,
|
|
||||||
data
|
|
||||||
) {
|
|
||||||
this.year = year?.toIntOrNull()
|
this.year = year?.toIntOrNull()
|
||||||
this.plot = description
|
this.plot = description
|
||||||
this.actors = actors
|
this.actors = actors
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
package com.lagradost
|
package com.lagradost
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import com.lagradost.cloudstream3.plugins.CloudstreamPlugin
|
import com.lagradost.cloudstream3.plugins.CloudstreamPlugin
|
||||||
import com.lagradost.cloudstream3.plugins.Plugin
|
import com.lagradost.cloudstream3.plugins.Plugin
|
||||||
import android.content.Context
|
|
||||||
|
|
||||||
@CloudstreamPlugin
|
@CloudstreamPlugin
|
||||||
class CasaCinemaProviderPlugin: Plugin() {
|
class CasaCinemaProviderPlugin : Plugin() {
|
||||||
override fun load(context: Context) {
|
override fun load(context: Context) {
|
||||||
// All providers should be added in this manner. Please don't edit the providers list directly.
|
// All providers should be added in this manner. Please don't edit the providers list
|
||||||
|
// directly.
|
||||||
registerMainAPI(CasaCinemaProvider())
|
registerMainAPI(CasaCinemaProvider())
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue