mirror of
https://github.com/recloudstream/cloudstream-extensions-multilingual.git
synced 2024-08-15 03:15:14 +00:00
CasaCinemaProvider
This commit is contained in:
parent
b4366f6368
commit
6b20e8642c
4 changed files with 186 additions and 0 deletions
25
CasaCinemaProvider/build.gradle.kts
Normal file
25
CasaCinemaProvider/build.gradle.kts
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
// use an integer for version numbers
|
||||||
|
version = 1
|
||||||
|
|
||||||
|
|
||||||
|
cloudstream {
|
||||||
|
// All of these properties are optional, you can safely remove them
|
||||||
|
|
||||||
|
// description = "Lorem Ipsum"
|
||||||
|
language= "it"
|
||||||
|
authors = listOf("Forthe")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Status int as the following:
|
||||||
|
* 0: Down
|
||||||
|
* 1: Ok
|
||||||
|
* 2: Slow
|
||||||
|
* 3: Beta only
|
||||||
|
* */
|
||||||
|
status = 1 // will be 3 if unspecified
|
||||||
|
tvTypes = listOf(
|
||||||
|
"TvSeries",
|
||||||
|
"Movie",
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
2
CasaCinemaProvider/src/main/AndroidManifest.xml
Normal file
2
CasaCinemaProvider/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest package="com.lagradost"/>
|
|
@ -0,0 +1,146 @@
|
||||||
|
package com.lagradost
|
||||||
|
import com.lagradost.cloudstream3.TvType
|
||||||
|
import com.lagradost.cloudstream3.MainAPI
|
||||||
|
import com.lagradost.cloudstream3.SearchResponse
|
||||||
|
import com.lagradost.cloudstream3.*
|
||||||
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
|
import com.lagradost.cloudstream3.utils.loadExtractor
|
||||||
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
|
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
||||||
|
import com.lagradost.cloudstream3.utils.ShortLink.unshorten
|
||||||
|
import com.lagradost.cloudstream3.network.CloudflareKiller
|
||||||
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addRating
|
||||||
|
import okhttp3.FormBody
|
||||||
|
import org.jsoup.nodes.Element
|
||||||
|
|
||||||
|
|
||||||
|
class CasaCinemaProvider : MainAPI() { // all providers must be an instance of MainAPI
|
||||||
|
override var mainUrl = "https://casacinema.lol/"
|
||||||
|
override var name = "CasaCinema"
|
||||||
|
override val supportedTypes = setOf(TvType.Movie, TvType.TvSeries)
|
||||||
|
override val hasChromecastSupport = true
|
||||||
|
override var lang = "it"
|
||||||
|
override val hasMainPage = true
|
||||||
|
private val interceptor = CloudflareKiller()
|
||||||
|
|
||||||
|
override val mainPage = mainPageOf(
|
||||||
|
"$mainUrl/category/serie-tv/page/" to "Ultime Serie Tv",
|
||||||
|
"$mainUrl/category/film/page/" to "Ultimi Film",
|
||||||
|
)
|
||||||
|
|
||||||
|
override suspend fun getMainPage(
|
||||||
|
page: Int,
|
||||||
|
request: MainPageRequest): HomePageResponse {
|
||||||
|
|
||||||
|
val url = request.data + page
|
||||||
|
|
||||||
|
val soup = app.get(url).document
|
||||||
|
val home = soup.select("ul.posts>li").mapNotNull {
|
||||||
|
it.toSearchResult()
|
||||||
|
}
|
||||||
|
return newHomePageResponse(arrayListOf(HomePageList(request.name, home)), hasNext = true)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun Element.toSearchResult(): SearchResponse {
|
||||||
|
val title= this.selectFirst(".title")?.text()?.replace("[HD]","")?.substringBefore("(")?:
|
||||||
|
throw ErrorLoadingException("No Title found")
|
||||||
|
|
||||||
|
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 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()?: throw ErrorLoadingException("No Episode Name")
|
||||||
|
val epNum = epTitle.substringAfter("Episodio ").toInt()
|
||||||
|
return Episode(
|
||||||
|
data,
|
||||||
|
epTitle,
|
||||||
|
season,
|
||||||
|
epNum
|
||||||
|
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun search(query: String): List<SearchResponse> {
|
||||||
|
val queryFormatted = query.replace(" ", "+")
|
||||||
|
val url = "$mainUrl/?s=$queryFormatted"
|
||||||
|
val doc = app.get(url,referer= mainUrl, interceptor=interceptor).document
|
||||||
|
return doc.select("ul.posts>li").map {
|
||||||
|
it.toSearchResult()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun load(url: String): LoadResponse {
|
||||||
|
val document = app.get(url).document
|
||||||
|
val type = 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 year = document.selectFirst("div.element>a.tag")?.text()?.substringBefore("-")
|
||||||
|
val poster = document.selectFirst("img.thumbnail")?.attr("src")
|
||||||
|
val rating = document.selectFirst("div.rating>div.value")?.text()?.trim()?.toRatingInt()
|
||||||
|
|
||||||
|
if (type == TvType.TvSeries) {
|
||||||
|
val episodeList = document.select("div.accordion>div.accordion-item").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)
|
||||||
|
}
|
||||||
|
}.flatten()
|
||||||
|
|
||||||
|
return newTvSeriesLoadResponse(
|
||||||
|
title,
|
||||||
|
url,
|
||||||
|
TvType.TvSeries,
|
||||||
|
episodeList){
|
||||||
|
this.year = year?.toIntOrNull()
|
||||||
|
this.plot = description
|
||||||
|
addPoster(poster)
|
||||||
|
addRating(rating)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val actors: List<ActorData> =
|
||||||
|
document.select("div.cast_wraper>ul>li").map { actordata ->
|
||||||
|
val actorName = 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))
|
||||||
|
}
|
||||||
|
val data = document.select(".embed-player").map { it.attr("data-id") }.toJson()
|
||||||
|
return newMovieLoadResponse(
|
||||||
|
title,
|
||||||
|
data,
|
||||||
|
TvType.Movie,
|
||||||
|
data
|
||||||
|
) {
|
||||||
|
this.year = year?.toIntOrNull()
|
||||||
|
this.plot = description
|
||||||
|
this.actors = actors
|
||||||
|
addPoster(poster)
|
||||||
|
addRating(rating)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun loadLinks(
|
||||||
|
data: String,
|
||||||
|
isCasting: Boolean,
|
||||||
|
subtitleCallback: (SubtitleFile) -> Unit,
|
||||||
|
callback: (ExtractorLink) -> Unit
|
||||||
|
): Boolean {
|
||||||
|
parseJson<List<String>>(data).map { videoUrl ->
|
||||||
|
loadExtractor(unshorten(videoUrl), data, subtitleCallback, callback)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.lagradost
|
||||||
|
|
||||||
|
import com.lagradost.cloudstream3.plugins.CloudstreamPlugin
|
||||||
|
import com.lagradost.cloudstream3.plugins.Plugin
|
||||||
|
import android.content.Context
|
||||||
|
|
||||||
|
@CloudstreamPlugin
|
||||||
|
class CasaCinemaProviderPlugin: Plugin() {
|
||||||
|
override fun load(context: Context) {
|
||||||
|
// All providers should be added in this manner. Please don't edit the providers list directly.
|
||||||
|
registerMainAPI(CasaCinemaProvider())
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue