forked from recloudstream/cloudstream
added trailer to superstream
This commit is contained in:
parent
52a656a234
commit
3a2041c52f
4 changed files with 68 additions and 12 deletions
|
@ -21,6 +21,7 @@ import com.lagradost.cloudstream3.ui.player.SubtitleData
|
|||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||
import com.lagradost.cloudstream3.utils.Qualities
|
||||
import com.lagradost.cloudstream3.utils.loadExtractor
|
||||
import okhttp3.Interceptor
|
||||
import java.text.SimpleDateFormat
|
||||
|
@ -980,7 +981,7 @@ interface LoadResponse {
|
|||
private val aniListIdPrefix = aniListApi.idPrefix
|
||||
var isTrailersEnabled = true
|
||||
|
||||
fun LoadResponse.isMovie() : Boolean {
|
||||
fun LoadResponse.isMovie(): Boolean {
|
||||
return this.type.isMovieType()
|
||||
}
|
||||
|
||||
|
@ -1025,25 +1026,71 @@ interface LoadResponse {
|
|||
}
|
||||
|
||||
/**better to call addTrailer with mutible trailers directly instead of calling this multiple times*/
|
||||
suspend fun LoadResponse.addTrailer(trailerUrl: String?, referer: String? = null) {
|
||||
if (!isTrailersEnabled || trailerUrl == null) return
|
||||
suspend fun LoadResponse.addTrailer(
|
||||
trailerUrl: String?,
|
||||
referer: String? = null,
|
||||
addRaw: Boolean = false
|
||||
) {
|
||||
if (!isTrailersEnabled || trailerUrl.isNullOrBlank()) return
|
||||
val links = arrayListOf<ExtractorLink>()
|
||||
val subs = arrayListOf<SubtitleFile>()
|
||||
loadExtractor(trailerUrl, referer, { subs.add(it) }, { links.add(it) })
|
||||
if (!loadExtractor(
|
||||
trailerUrl,
|
||||
referer,
|
||||
{ subs.add(it) },
|
||||
{ links.add(it) }) && addRaw
|
||||
) {
|
||||
this.trailers.add(
|
||||
TrailerData(
|
||||
listOf(
|
||||
ExtractorLink(
|
||||
"",
|
||||
"Trailer",
|
||||
trailerUrl,
|
||||
referer ?: "",
|
||||
Qualities.Unknown.value,
|
||||
trailerUrl.contains(".m3u8")
|
||||
)
|
||||
), listOf()
|
||||
)
|
||||
)
|
||||
} else {
|
||||
this.trailers.add(TrailerData(links, subs))
|
||||
}
|
||||
}
|
||||
|
||||
fun LoadResponse.addTrailer(newTrailers: List<ExtractorLink>) {
|
||||
trailers.addAll(newTrailers.map { TrailerData(listOf(it)) })
|
||||
}
|
||||
|
||||
suspend fun LoadResponse.addTrailer(trailerUrls: List<String>?, referer: String? = null) {
|
||||
suspend fun LoadResponse.addTrailer(
|
||||
trailerUrls: List<String>?,
|
||||
referer: String? = null,
|
||||
addRaw: Boolean = false
|
||||
) {
|
||||
if (!isTrailersEnabled || trailerUrls == null) return
|
||||
val trailers = trailerUrls.apmap { trailerUrl ->
|
||||
val trailers = trailerUrls.filter { it.isNotBlank() }.apmap { trailerUrl ->
|
||||
val links = arrayListOf<ExtractorLink>()
|
||||
val subs = arrayListOf<SubtitleFile>()
|
||||
loadExtractor(trailerUrl, referer, { subs.add(it) }, { links.add(it) })
|
||||
if (!loadExtractor(
|
||||
trailerUrl,
|
||||
referer,
|
||||
{ subs.add(it) },
|
||||
{ links.add(it) }) && addRaw
|
||||
) {
|
||||
arrayListOf(
|
||||
ExtractorLink(
|
||||
"",
|
||||
"Trailer",
|
||||
trailerUrl,
|
||||
referer ?: "",
|
||||
Qualities.Unknown.value,
|
||||
trailerUrl.contains(".m3u8")
|
||||
)
|
||||
) to arrayListOf()
|
||||
} else {
|
||||
links to subs
|
||||
}
|
||||
}.map { (links, subs) -> TrailerData(links, subs) }
|
||||
this.trailers.addAll(trailers)
|
||||
}
|
||||
|
@ -1124,7 +1171,7 @@ data class NextAiring(
|
|||
data class SeasonData(
|
||||
val season: Int,
|
||||
val name: String? = null,
|
||||
val displaySeason : Int? = null, // will use season if null
|
||||
val displaySeason: Int? = null, // will use season if null
|
||||
)
|
||||
|
||||
interface EpisodeResponse {
|
||||
|
|
|
@ -19,6 +19,13 @@ class YoutubeShortLinkExtractor : YoutubeExtractor() {
|
|||
}
|
||||
}
|
||||
|
||||
class YoutubeMobileExtractor : YoutubeExtractor() {
|
||||
override val mainUrl = "https://m.youtube.com"
|
||||
}
|
||||
class YoutubeNoCookieExtractor : YoutubeExtractor() {
|
||||
override val mainUrl = "https://www.youtube-nocookie.com"
|
||||
}
|
||||
|
||||
open class YoutubeExtractor : ExtractorApi() {
|
||||
override val mainUrl = "https://www.youtube.com"
|
||||
override val requiresReferer = false
|
||||
|
|
|
@ -172,7 +172,7 @@ class SuperStream : MainAPI() {
|
|||
}
|
||||
|
||||
private suspend inline fun <reified T : Any> queryApiParsed(query: String): T {
|
||||
return queryApi(query).also { println("queryApiParsed== ${it.text}") }.parsed()
|
||||
return queryApi(query).parsed()
|
||||
}
|
||||
|
||||
private fun getExpiryDate(): Long {
|
||||
|
@ -530,7 +530,7 @@ class SuperStream : MainAPI() {
|
|||
}
|
||||
) {
|
||||
this.recommendations = data.recommend.mapNotNull { it.toSearchResponse() }
|
||||
|
||||
addTrailer(data.trailerUrl)
|
||||
this.year = data.year
|
||||
this.plot = data.description
|
||||
this.posterUrl = data.posterOrg ?: data.poster
|
||||
|
|
|
@ -312,6 +312,8 @@ val extractorApis: Array<ExtractorApi> = arrayOf(
|
|||
|
||||
YoutubeExtractor(),
|
||||
YoutubeShortLinkExtractor(),
|
||||
YoutubeMobileExtractor(),
|
||||
YoutubeNoCookieExtractor(),
|
||||
Streamlare(),
|
||||
VidSrcExtractor(),
|
||||
VidSrcExtractor2(),
|
||||
|
|
Loading…
Reference in a new issue