mirror of
https://github.com/recloudstream/cloudstream-extensions-multilingual.git
synced 2024-08-15 03:15:14 +00:00
small fixes
This commit is contained in:
parent
baea5409f1
commit
55856dbcd7
1 changed files with 51 additions and 48 deletions
|
@ -9,7 +9,7 @@ import com.lagradost.cloudstream3.*
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
|
|
||||||
class StreamingcommunityProvider: MainAPI() {
|
class StreamingcommunityProvider : MainAPI() {
|
||||||
override var lang = "it"
|
override var lang = "it"
|
||||||
override var mainUrl = "https://streamingcommunity.cafe"
|
override var mainUrl = "https://streamingcommunity.cafe"
|
||||||
override var name = "StreamingCommunity"
|
override var name = "StreamingCommunity"
|
||||||
|
@ -19,9 +19,10 @@ class StreamingcommunityProvider: MainAPI() {
|
||||||
TvType.Movie,
|
TvType.Movie,
|
||||||
TvType.TvSeries,
|
TvType.TvSeries,
|
||||||
)
|
)
|
||||||
private val userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"
|
private val userAgent =
|
||||||
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"
|
||||||
|
|
||||||
override suspend fun getMainPage(page: Int, request : MainPageRequest): HomePageResponse {
|
override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse {
|
||||||
val webpage = app.get(mainUrl, headers = mapOf("user-agent" to userAgent))
|
val webpage = app.get(mainUrl, headers = mapOf("user-agent" to userAgent))
|
||||||
val document = webpage.document
|
val document = webpage.document
|
||||||
mainUrl = webpage.url
|
mainUrl = webpage.url
|
||||||
|
@ -31,7 +32,7 @@ class StreamingcommunityProvider: MainAPI() {
|
||||||
val searchResponses = videoData.subList(0, 12).apmap { searchr ->
|
val searchResponses = videoData.subList(0, 12).apmap { searchr ->
|
||||||
searchr.toSearchResponse()
|
searchr.toSearchResponse()
|
||||||
}
|
}
|
||||||
HomePageList(it.attr("slider-name"),searchResponses)
|
HomePageList(it.attr("slider-name"), searchResponses)
|
||||||
}
|
}
|
||||||
if (items.isEmpty()) throw ErrorLoadingException()
|
if (items.isEmpty()) throw ErrorLoadingException()
|
||||||
return HomePageResponse(items)
|
return HomePageResponse(items)
|
||||||
|
@ -44,79 +45,73 @@ class StreamingcommunityProvider: MainAPI() {
|
||||||
val document = app.get(url, headers = mapOf("user-agent" to userAgent)).document
|
val document = app.get(url, headers = mapOf("user-agent" to userAgent)).document
|
||||||
|
|
||||||
val films =
|
val films =
|
||||||
document.selectFirst("the-search-page")!!.attr("records-json").replace(""", """"""")
|
document.selectFirst("the-search-page")!!.attr("records-json")
|
||||||
|
.replace(""", """"""")
|
||||||
|
|
||||||
val searchResults = parseJson<List<VideoElement>>(films)
|
val searchResults = parseJson<List<VideoElement>>(films)
|
||||||
return searchResults.apmap { result ->
|
return searchResults.apmap { result ->
|
||||||
result.toSearchResponse()
|
result.toSearchResponse()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun load(url: String): LoadResponse {
|
override suspend fun load(url: String): LoadResponse {
|
||||||
|
val document = app.get(url, headers = mapOf("user-agent" to userAgent)).document
|
||||||
val document = app.get(url,headers = mapOf("user-agent" to userAgent)).document
|
val poster = Regex("url\\('(.*)'").find(
|
||||||
val poster = Regex("url\\('(.*)'").find(document.selectFirst("div.title-wrap")?.attributes()
|
document.selectFirst("div.title-wrap")?.attributes()
|
||||||
?.get("style") ?: "")?.groupValues?.last() //posterMap[url]
|
?.get("style") ?: ""
|
||||||
|
)?.groupValues?.lastOrNull() //posterMap[url]
|
||||||
val id = url.substringBefore("-").filter { it.isDigit() }
|
val id = url.substringBefore("-").filter { it.isDigit() }
|
||||||
val data = app.post("$mainUrl/api/titles/preview/$id", referer = mainUrl, headers = mapOf("user-agent" to userAgent)).text
|
val datajs = app.post(
|
||||||
|
"$mainUrl/api/titles/preview/$id",
|
||||||
|
referer = mainUrl,
|
||||||
|
headers = mapOf("user-agent" to userAgent)
|
||||||
|
).parsed<Moviedata>()
|
||||||
|
|
||||||
val datajs = parseJson<Moviedata>(data)
|
val type = if (datajs.type == "movie") {
|
||||||
val type: TvType = if (datajs.type == "movie") {
|
|
||||||
TvType.Movie
|
TvType.Movie
|
||||||
} else {
|
} else {
|
||||||
TvType.TvSeries
|
TvType.TvSeries
|
||||||
}
|
}
|
||||||
|
|
||||||
val trailerInfoJs = document.select("slider-trailer").attr("videos")
|
val trailerInfoJs = document.select("slider-trailer").attr("videos")
|
||||||
val trailerInfo = parseJson<List<TrailerElement>>(trailerInfoJs)
|
val trailerInfo = parseJson<List<TrailerElement>>(trailerInfoJs)
|
||||||
val trailerUrl: String? = if (trailerInfo.isNotEmpty()) {
|
val trailerUrl = trailerInfo.firstOrNull()?.url?.let { code ->
|
||||||
"https://www.youtube.com/watch?v=${trailerInfo[0].url}"
|
"https://www.youtube.com/watch?v=$code"
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val year = datajs.releaseDate.substringBefore("-")
|
val year = datajs.releaseDate.substringBefore("-")
|
||||||
val correlates = document.selectFirst("slider-title")!!.attr("titles-json")
|
val correlates = document.selectFirst("slider-title")!!.attr("titles-json")
|
||||||
val correlatesData = parseJson<List<VideoElement>>(correlates)
|
val correlatesData = parseJson<List<VideoElement>>(correlates)
|
||||||
val number : Int = if (correlatesData.size<=15) {correlatesData.size} else correlatesData.size-15
|
// Max size 15 to prevent network spam
|
||||||
|
val size = minOf(correlatesData.size, 15)
|
||||||
|
|
||||||
val correlatesList =correlatesData.take(number).apmap {
|
val correlatesList = correlatesData.take(size).apmap {
|
||||||
it.toSearchResponse()
|
it.toSearchResponse()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == TvType.TvSeries) {
|
if (type == TvType.TvSeries) {
|
||||||
|
|
||||||
val name = datajs.name
|
val name = datajs.name
|
||||||
val episodeList = arrayListOf<Episode>()
|
|
||||||
|
|
||||||
val episodes =
|
val episodes =
|
||||||
Html.fromHtml(document.selectFirst("season-select")!!.attr("seasons")).toString()
|
Html.fromHtml(document.selectFirst("season-select")!!.attr("seasons")).toString()
|
||||||
val jsonEpisodes = parseJson<List<Season>>(episodes)
|
val jsonEpisodes = parseJson<List<Season>>(episodes)
|
||||||
|
|
||||||
jsonEpisodes.map { seasons ->
|
val episodeList = jsonEpisodes.map { seasons ->
|
||||||
val season = seasons.number.toInt()
|
val season = seasons.number.toInt()
|
||||||
val sid = seasons.title_id
|
val sid = seasons.title_id
|
||||||
val episode = seasons.episodes
|
seasons.episodes.map { ep ->
|
||||||
episode.map { ep ->
|
|
||||||
val href = "$mainUrl/watch/$sid?e=${ep.id}"
|
val href = "$mainUrl/watch/$sid?e=${ep.id}"
|
||||||
val postImage = if (ep.images.isNotEmpty()) {
|
val postImage = ep.images.firstOrNull()?.originalURL
|
||||||
ep.images.first().originalURL
|
|
||||||
} else {
|
newEpisode(href) {
|
||||||
""
|
this.name = ep.name
|
||||||
|
this.season = season
|
||||||
|
this.episode = ep.number.toInt()
|
||||||
|
this.description = ep.plot
|
||||||
|
this.posterUrl = postImage
|
||||||
}
|
}
|
||||||
episodeList.add(
|
|
||||||
|
|
||||||
newEpisode(href) {
|
|
||||||
this.name = ep.name
|
|
||||||
this.season = season
|
|
||||||
this.episode = ep.number.toInt()
|
|
||||||
this.description = ep.plot
|
|
||||||
this.posterUrl = postImage
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}.flatten()
|
||||||
|
|
||||||
|
|
||||||
if (episodeList.isEmpty()) throw ErrorLoadingException("No Seasons Found")
|
if (episodeList.isEmpty()) throw ErrorLoadingException("No Seasons Found")
|
||||||
|
|
||||||
|
@ -130,10 +125,7 @@ class StreamingcommunityProvider: MainAPI() {
|
||||||
addTrailer(trailerUrl)
|
addTrailer(trailerUrl)
|
||||||
this.recommendations = correlatesList
|
this.recommendations = correlatesList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return newMovieLoadResponse(
|
return newMovieLoadResponse(
|
||||||
document.selectFirst("div > div > h1")!!.text(),
|
document.selectFirst("div > div > h1")!!.text(),
|
||||||
document.select("a.play-hitzone").attr("href"),
|
document.select("a.play-hitzone").attr("href"),
|
||||||
|
@ -149,7 +141,6 @@ class StreamingcommunityProvider: MainAPI() {
|
||||||
addTrailer(trailerUrl)
|
addTrailer(trailerUrl)
|
||||||
this.recommendations = correlatesList
|
this.recommendations = correlatesList
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +177,7 @@ class StreamingcommunityProvider: MainAPI() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun VideoElement.toSearchResponse() : MovieSearchResponse{
|
private suspend fun VideoElement.toSearchResponse(): MovieSearchResponse {
|
||||||
val id = this.id
|
val id = this.id
|
||||||
val name = this.slug
|
val name = this.slug
|
||||||
val img = this.images[0].url
|
val img = this.images[0].url
|
||||||
|
@ -195,9 +186,13 @@ class StreamingcommunityProvider: MainAPI() {
|
||||||
val posterUrl = "https://$ip/images/$number/$img"
|
val posterUrl = "https://$ip/images/$number/$img"
|
||||||
val videoUrl = "$mainUrl/titles/$id-$name"
|
val videoUrl = "$mainUrl/titles/$id-$name"
|
||||||
//posterMap[videourl] = posterurl
|
//posterMap[videourl] = posterurl
|
||||||
val data = app.post("$mainUrl/api/titles/preview/$id", referer = mainUrl, headers = mapOf("user-agent" to userAgent)).text
|
val data = app.post(
|
||||||
|
"$mainUrl/api/titles/preview/$id",
|
||||||
|
referer = mainUrl,
|
||||||
|
headers = mapOf("user-agent" to userAgent)
|
||||||
|
).text
|
||||||
val datajs = parseJson<Moviedata>(data)
|
val datajs = parseJson<Moviedata>(data)
|
||||||
val type: TvType = if (datajs.type == "movie") {
|
val type = if (datajs.type == "movie") {
|
||||||
TvType.Movie
|
TvType.Movie
|
||||||
} else {
|
} else {
|
||||||
TvType.TvSeries
|
TvType.TvSeries
|
||||||
|
@ -254,25 +249,30 @@ data class Moviedata(
|
||||||
@JsonProperty("votes") val votes: List<Vote>,
|
@JsonProperty("votes") val votes: List<Vote>,
|
||||||
@JsonProperty("runtime") val runtime: Long? = null
|
@JsonProperty("runtime") val runtime: Long? = null
|
||||||
)
|
)
|
||||||
|
|
||||||
data class Genre(
|
data class Genre(
|
||||||
@JsonProperty("name") val name: String,
|
@JsonProperty("name") val name: String,
|
||||||
@JsonProperty("pivot") val pivot: Pivot,
|
@JsonProperty("pivot") val pivot: Pivot,
|
||||||
)
|
)
|
||||||
|
|
||||||
data class Pivot(
|
data class Pivot(
|
||||||
@JsonProperty("titleID") val titleID: Long,
|
@JsonProperty("titleID") val titleID: Long,
|
||||||
@JsonProperty("genreID") val genreID: Long,
|
@JsonProperty("genreID") val genreID: Long,
|
||||||
)
|
)
|
||||||
|
|
||||||
data class Vote(
|
data class Vote(
|
||||||
@JsonProperty("title_id") val title_id: Long,
|
@JsonProperty("title_id") val title_id: Long,
|
||||||
@JsonProperty("average") val average: String,
|
@JsonProperty("average") val average: String,
|
||||||
@JsonProperty("count") val count: Long,
|
@JsonProperty("count") val count: Long,
|
||||||
@JsonProperty("type") val type: String,
|
@JsonProperty("type") val type: String,
|
||||||
)
|
)
|
||||||
|
|
||||||
data class VideoElement(
|
data class VideoElement(
|
||||||
@JsonProperty("id") val id: Long,
|
@JsonProperty("id") val id: Long,
|
||||||
@JsonProperty("slug") val slug: String,
|
@JsonProperty("slug") val slug: String,
|
||||||
@JsonProperty("images") val images: List<Image>,
|
@JsonProperty("images") val images: List<Image>,
|
||||||
)
|
)
|
||||||
|
|
||||||
data class Image(
|
data class Image(
|
||||||
@JsonProperty("imageable_id") val imageableID: Long,
|
@JsonProperty("imageable_id") val imageableID: Long,
|
||||||
@JsonProperty("imageable_type") val imageableType: String,
|
@JsonProperty("imageable_type") val imageableType: String,
|
||||||
|
@ -311,6 +311,7 @@ data class Season(
|
||||||
@JsonProperty("updated_at") val updatedAt: String? = "",
|
@JsonProperty("updated_at") val updatedAt: String? = "",
|
||||||
@JsonProperty("episodes") val episodes: List<Episodejson>
|
@JsonProperty("episodes") val episodes: List<Episodejson>
|
||||||
)
|
)
|
||||||
|
|
||||||
data class Episodejson(
|
data class Episodejson(
|
||||||
@JsonProperty("id") val id: Long,
|
@JsonProperty("id") val id: Long,
|
||||||
@JsonProperty("number") val number: Long,
|
@JsonProperty("number") val number: Long,
|
||||||
|
@ -319,6 +320,7 @@ data class Episodejson(
|
||||||
@JsonProperty("season_id") val seasonID: Long,
|
@JsonProperty("season_id") val seasonID: Long,
|
||||||
@JsonProperty("images") val images: List<ImageSeason>
|
@JsonProperty("images") val images: List<ImageSeason>
|
||||||
)
|
)
|
||||||
|
|
||||||
data class ImageSeason(
|
data class ImageSeason(
|
||||||
@JsonProperty("imageable_id") val imageableID: Long,
|
@JsonProperty("imageable_id") val imageableID: Long,
|
||||||
@JsonProperty("imageable_type") val imageableType: String,
|
@JsonProperty("imageable_type") val imageableType: String,
|
||||||
|
@ -328,6 +330,7 @@ data class ImageSeason(
|
||||||
@JsonProperty("type") val type: String,
|
@JsonProperty("type") val type: String,
|
||||||
@JsonProperty("original_url") val originalURL: String
|
@JsonProperty("original_url") val originalURL: String
|
||||||
)
|
)
|
||||||
|
|
||||||
data class TrailerElement(
|
data class TrailerElement(
|
||||||
@JsonProperty("id") val id: Long? = null,
|
@JsonProperty("id") val id: Long? = null,
|
||||||
@JsonProperty("url") val url: String? = null,
|
@JsonProperty("url") val url: String? = null,
|
||||||
|
@ -347,4 +350,4 @@ data class TrailerElement(
|
||||||
@JsonProperty("proxy_id") val proxyID: Any? = null,
|
@JsonProperty("proxy_id") val proxyID: Any? = null,
|
||||||
@JsonProperty("proxy_default_id") val proxyDefaultID: Any? = null,
|
@JsonProperty("proxy_default_id") val proxyDefaultID: Any? = null,
|
||||||
@JsonProperty("scws_id") val scwsID: Any? = null
|
@JsonProperty("scws_id") val scwsID: Any? = null
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue