cineblog code fix

This commit is contained in:
antonydp 2022-11-30 22:47:47 +01:00 committed by GitHub
parent 9b932ca90f
commit c0cbda7287
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,6 +3,8 @@ package com.lagradost
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.loadExtractor import com.lagradost.cloudstream3.utils.loadExtractor
import okhttp3.FormBody
import org.jsoup.nodes.Element
class CineBlogProvider : MainAPI() { class CineBlogProvider : MainAPI() {
@ -29,118 +31,94 @@ class CineBlogProvider : MainAPI() {
): HomePageResponse { ): HomePageResponse {
val url = request.data.replace("number", page.toString()) val url = request.data.replace("number", page.toString())
val soup = app.get(url, referer = url.substringBefore("page")).document val soup = app.get(url, referer = url.substringBefore("page")).document
val home = soup.select("article.item").map { val home = soup.select("article.item").mapNotNull {
val title = it.selectFirst("div.data > h3 > a")!!.text().substringBefore("(") it.toSearchResult()
val link = it.selectFirst("div.poster > a")!!.attr("href")
val quality = getQualityFromString(it.selectFirst("span.quality")?.text())
TvSeriesSearchResponse(
title,
link,
this.name,
TvType.Movie,
it.selectFirst("img")!!.attr("src"),
null,
null,
quality = quality
)
} }
return newHomePageResponse(request.name, home) return newHomePageResponse(arrayListOf(HomePageList(request.name, home)), hasNext = true)
}
private fun Element.toSearchResult(): SearchResponse{
val title = this.selectFirst("div.data > h3 > a")?.text()?.substringBefore("(") ?:
this.selectFirst("a > img")?.attr("alt")?.substringBeforeLast("(") ?:
throw ErrorLoadingException("No Title found")
val link = this.selectFirst("div.poster > a")?.attr("href") ?:
this.selectFirst("a")?.attr("href") ?:
throw ErrorLoadingException("No Link found")
val quality = this.selectFirst("span.quality")?.text()
val posterUrl = this.selectFirst("img")?.attr("src") ?:
this.selectFirst("a > img")?.attr("src")
return newMovieSearchResponse(title, link, TvType.Movie){
addPoster(posterUrl)
if (quality != null) {
addQuality(quality)
}
}
}
private fun Element.toEpisode(season: Int): Episode {
val href = this.selectFirst("div.episodiotitle > a")?.attr("href")?: throw ErrorLoadingException("No Link found")
val epNum = this.selectFirst("div.numerando")?.text()?.substringAfter("-")?.filter { it.isDigit() }?.toIntOrNull()
val epTitle = this.selectFirst("div.episodiotitle > a")?.text()?: throw ErrorLoadingException("No Title found")
val posterUrl = this.selectFirst("div.imagen > img")?.attr("src")
return Episode(
href,
epTitle,
season,
epNum,
posterUrl,
)
} }
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 ).document val doc = app.get(url,referer= mainUrl ).document
return doc.select("div.result-item").map { return doc.select("div.result-item").map {
val href = it.selectFirst("div.image > div > a")!!.attr("href") it.toSearchResult()
val poster = it.selectFirst("div.image > div > a > img")!!.attr("src")
val name = it.selectFirst("div.details > div.title > a")!!.text().substringBefore("(")
MovieSearchResponse(
name,
href,
this.name,
TvType.Movie,
poster
)
} }
} }
override suspend fun load(url: String): LoadResponse { override suspend fun load(url: String): LoadResponse {
val page = app.get(url) val document = app.get(url).document
val document = page.document
val type = if (url.contains("film")) TvType.Movie else TvType.TvSeries val type = if (url.contains("film")) TvType.Movie else TvType.TvSeries
val title = document.selectFirst("div.data > h1")!!.text().substringBefore("(") val title = document.selectFirst("div.data > h1")?.text()?.substringBefore("(")?: throw ErrorLoadingException("No Title found")
val description = document.select("#info > div.wp-content > p").html().toString() val description = document.select("#info > div.wp-content > p").html().toString()
val rating = null val year = document.selectFirst(" div.data > div.extra > span.date")?.text()?.substringAfter(",")?.filter { it.isDigit() }.let { it?.dropLast(4) }
var year = document.selectFirst(" div.data > div.extra > span.date")!!.text().substringAfter(",") val poster =
.filter { it.isDigit() }
if (year.length > 4) {
year = year.dropLast(4)
}
val poster =
document.selectFirst("#dt_galery")?.selectFirst("a")?.attr("href")?.trim()?: document.selectFirst("#dt_galery")?.selectFirst("a")?.attr("href")?.trim()?:
document.selectFirst("div.poster > img")!!.attr("src") document.selectFirst("div.poster > img")?.attr("src")
val recommendations = document.select("#single_relacionados >article").map {
val recomm = document.select("#single_relacionados >article").map { it.toSearchResult()
val href = it.selectFirst("a")!!.attr("href")
val posterUrl = it.selectFirst("a > img")!!.attr("src")
val name = it.selectFirst("a > img")!!.attr("alt").substringBeforeLast("(")
MovieSearchResponse(
name,
href,
this.name,
TvType.Movie,
posterUrl
)
} }
if (type == TvType.TvSeries) { if (type == TvType.TvSeries) {
val episodeList = document.select("#seasons > div").reversed().map { element ->
val episodeList = ArrayList<Episode>() val season = element.selectFirst("div.se-q > span.se-t")?.text()?.toIntOrNull()?:throw ErrorLoadingException("No Season found")
document.select("#seasons > div").reversed().map { element ->
val season = element.selectFirst("div.se-q > span.se-t")!!.text().toInt()
element.select("div.se-a > ul > li").filter { it -> it.text()!="There are still no episodes this season" }.map{ episode -> element.select("div.se-a > ul > li").filter { it -> it.text()!="There are still no episodes this season" }.map{ episode ->
val href = episode.selectFirst("div.episodiotitle > a")!!.attr("href") episode.toEpisode(season)
val epNum =episode.selectFirst("div.numerando")!!.text().substringAfter("-").filter { it.isDigit() }.toIntOrNull()
val epTitle = episode.selectFirst("div.episodiotitle > a")!!.text()
val posterUrl = episode.selectFirst("div.imagen > img")!!.attr("src")
episodeList.add(
Episode(
href,
epTitle,
season,
epNum,
posterUrl,
)
)
} }
} }.flatten()
return TvSeriesLoadResponse(
return newTvSeriesLoadResponse(
title, title,
url, url,
this.name,
type, type,
episodeList, episodeList){
fixUrlNull(poster), this.recommendations = recommendations
year.toIntOrNull(), this.year = year?.toIntOrNull()
description, this.plot = description
null, addPoster(poster)
rating, }
null,
null,
mutableListOf(),
recomm
)
} else { } else {
val actors: List<ActorData> = val actors: List<ActorData> =
document.select("div.person").filter{ it -> it.selectFirst("div.img > a > img")?.attr("src")!!.contains("/no/cast.png").not()}.map { actordata -> document.select("div.person").filter{ it -> it.selectFirst("div.img > a > img")?.attr("src")?.contains("/no/cast.png")?.not()?:false}.map { actordata ->
val actorName = actordata.selectFirst("div.data > div.name > a")!!.text() val actorName = actordata.selectFirst("div.data > div.name > a")?.text()?:throw ErrorLoadingException("No Actor name found")
val actorImage : String? = actordata.selectFirst("div.img > a > img")?.attr("src") val actorImage : String? = actordata.selectFirst("div.img > a > img")?.attr("src")
val roleActor = actordata.selectFirst("div.data > div.caracter")!!.text() val roleActor = actordata.selectFirst("div.data > div.caracter")?.text()
ActorData(actor = Actor(actorName, image = actorImage), roleString = roleActor ) ActorData(actor = Actor(actorName, image = actorImage), roleString = roleActor )
} }
return newMovieLoadResponse( return newMovieLoadResponse(
@ -149,13 +127,11 @@ class CineBlogProvider : MainAPI() {
type, type,
url url
) { ) {
posterUrl = fixUrlNull(poster) this.recommendations = recommendations
this.year = year.toIntOrNull() this.year = year?.toIntOrNull()
this.plot = description this.plot = description
this.rating = rating
this.recommendations = recomm
this.duration = null
this.actors = actors this.actors = actors
addPoster(poster)
} }
} }
} }
@ -169,11 +145,14 @@ class CineBlogProvider : MainAPI() {
val doc = app.get(data).document val doc = app.get(data).document
val type = if( data.contains("film") ){"movie"} else {"tv"} val type = if( data.contains("film") ){"movie"} else {"tv"}
val idpost=doc.select("#player-option-1").attr("data-post") val idpost=doc.select("#player-option-1").attr("data-post")
val test = app.post("$mainUrl/wp-admin/admin-ajax.php", headers = mapOf(
val test = app.post("$mainUrl/wp-admin/admin-ajax.php",
headers = mapOf(
"content-type" to "application/x-www-form-urlencoded; charset=UTF-8", "content-type" to "application/x-www-form-urlencoded; charset=UTF-8",
"accept" to "*/*", "accept" to "*/*",
"X-Requested-With" to "XMLHttpRequest", "X-Requested-With" to "XMLHttpRequest",
), data = mapOf( ),
data = mapOf(
"action" to "doo_player_ajax", "action" to "doo_player_ajax",
"post" to idpost, "post" to idpost,
"nume" to "1", "nume" to "1",