forked from recloudstream/cloudstream
added recommendations to superstream
This commit is contained in:
parent
c9f393d0e3
commit
52a656a234
1 changed files with 30 additions and 13 deletions
|
@ -172,7 +172,7 @@ class SuperStream : MainAPI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend inline fun <reified T : Any> queryApiParsed(query: String): T {
|
private suspend inline fun <reified T : Any> queryApiParsed(query: String): T {
|
||||||
return queryApi(query).parsed()
|
return queryApi(query).also { println("queryApiParsed== ${it.text}") }.parsed()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getExpiryDate(): Long {
|
private fun getExpiryDate(): Long {
|
||||||
|
@ -247,6 +247,8 @@ class SuperStream : MainAPI() {
|
||||||
|
|
||||||
private data class Data(
|
private data class Data(
|
||||||
@JsonProperty("id") val id: Int? = null,
|
@JsonProperty("id") val id: Int? = null,
|
||||||
|
@JsonProperty("mid") val mid: Int? = null,
|
||||||
|
@JsonProperty("tid") val tid: Int? = null,
|
||||||
@JsonProperty("box_type") val boxType: Int? = null,
|
@JsonProperty("box_type") val boxType: Int? = null,
|
||||||
@JsonProperty("title") val title: String? = null,
|
@JsonProperty("title") val title: String? = null,
|
||||||
@JsonProperty("poster_org") val posterOrg: String? = null,
|
@JsonProperty("poster_org") val posterOrg: String? = null,
|
||||||
|
@ -261,16 +263,17 @@ class SuperStream : MainAPI() {
|
||||||
@JsonProperty("data") val data: ArrayList<Data> = arrayListOf()
|
@JsonProperty("data") val data: ArrayList<Data> = arrayListOf()
|
||||||
)
|
)
|
||||||
|
|
||||||
override suspend fun search(query: String): List<SearchResponse> {
|
private fun Data.toSearchResponse(): SearchResponse? {
|
||||||
|
val it = this
|
||||||
val apiQuery =
|
val type = if (it.boxType == TYPE_MOVIES) TvType.Movie else TvType.TvSeries
|
||||||
// Originally 8 pagelimit
|
return newMovieSearchResponse(
|
||||||
"""{"childmode":"$hideNsfw","app_version":"11.5","appid":"$appId","module":"Search3","channel":"Website","page":"1","lang":"en","type":"all","keyword":"$query","pagelimit":"20","expired_date":"${getExpiryDate()}","platform":"android"}"""
|
name = it.title ?: return null,
|
||||||
val searchResponse = parseJson<MainData>(queryApi(apiQuery).text).data.mapNotNull {
|
url = (it.id?.let { id -> LoadData(id, it.boxType ?: return@let null) } ?: it.mid?.let { id ->
|
||||||
val type = if (it.boxType == 1) TvType.Movie else TvType.TvSeries
|
LoadData(
|
||||||
newMovieSearchResponse(
|
id,
|
||||||
name = it.title ?: return@mapNotNull null,
|
TYPE_MOVIES
|
||||||
url = LoadData(it.id ?: return@mapNotNull null, it.boxType).toJson(),
|
)
|
||||||
|
} ?: it.tid?.let { id -> LoadData(id, TYPE_SERIES) })?.toJson() ?: return null,
|
||||||
type = type,
|
type = type,
|
||||||
fix = false
|
fix = false
|
||||||
) {
|
) {
|
||||||
|
@ -279,6 +282,15 @@ class SuperStream : MainAPI() {
|
||||||
quality = getQualityFromString(it.qualityTag?.replace("-", "") ?: "")
|
quality = getQualityFromString(it.qualityTag?.replace("-", "") ?: "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun search(query: String): List<SearchResponse> {
|
||||||
|
|
||||||
|
val apiQuery =
|
||||||
|
// Originally 8 pagelimit
|
||||||
|
"""{"childmode":"$hideNsfw","app_version":"11.5","appid":"$appId","module":"Search3","channel":"Website","page":"1","lang":"en","type":"all","keyword":"$query","pagelimit":"20","expired_date":"${getExpiryDate()}","platform":"android"}"""
|
||||||
|
val searchResponse = parseJson<MainData>(queryApi(apiQuery).text).data.mapNotNull {
|
||||||
|
it.toSearchResponse()
|
||||||
|
}
|
||||||
return searchResponse
|
return searchResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,6 +321,7 @@ class SuperStream : MainAPI() {
|
||||||
@JsonProperty("trailer_url") val trailerUrl: String? = null,
|
@JsonProperty("trailer_url") val trailerUrl: String? = null,
|
||||||
@JsonProperty("imdb_link") val imdbLink: String? = null,
|
@JsonProperty("imdb_link") val imdbLink: String? = null,
|
||||||
@JsonProperty("box_type") val boxType: Int? = null,
|
@JsonProperty("box_type") val boxType: Int? = null,
|
||||||
|
@JsonProperty("recommend") val recommend: List<Data> = listOf() // series does not have any recommendations :pensive:
|
||||||
)
|
)
|
||||||
|
|
||||||
private data class MovieDataProp(
|
private data class MovieDataProp(
|
||||||
|
@ -444,7 +457,8 @@ class SuperStream : MainAPI() {
|
||||||
@JsonProperty("language") val language: ArrayList<SeriesLanguage> = arrayListOf(),
|
@JsonProperty("language") val language: ArrayList<SeriesLanguage> = arrayListOf(),
|
||||||
@JsonProperty("box_type") val boxType: Int? = null,
|
@JsonProperty("box_type") val boxType: Int? = null,
|
||||||
@JsonProperty("year_year") val yearYear: String? = null,
|
@JsonProperty("year_year") val yearYear: String? = null,
|
||||||
@JsonProperty("season_episode") val seasonEpisode: String? = null
|
@JsonProperty("season_episode") val seasonEpisode: String? = null,
|
||||||
|
@JsonProperty("recommend") val recommend: List<Data> = listOf()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -471,6 +485,7 @@ class SuperStream : MainAPI() {
|
||||||
null
|
null
|
||||||
),
|
),
|
||||||
) {
|
) {
|
||||||
|
this.recommendations = data.recommend.mapNotNull { it.toSearchResponse() }
|
||||||
this.posterUrl = data.posterOrg ?: data.poster
|
this.posterUrl = data.posterOrg ?: data.poster
|
||||||
this.year = data.year
|
this.year = data.year
|
||||||
this.plot = data.description
|
this.plot = data.description
|
||||||
|
@ -514,6 +529,8 @@ class SuperStream : MainAPI() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
|
this.recommendations = data.recommend.mapNotNull { it.toSearchResponse() }
|
||||||
|
|
||||||
this.year = data.year
|
this.year = data.year
|
||||||
this.plot = data.description
|
this.plot = data.description
|
||||||
this.posterUrl = data.posterOrg ?: data.poster
|
this.posterUrl = data.posterOrg ?: data.poster
|
||||||
|
|
Loading…
Reference in a new issue