mirror of
https://github.com/hexated/cloudstream-extensions-hexated.git
synced 2024-08-15 00:03:22 +00:00
StremioX & StremioC: added imdb id
This commit is contained in:
parent
ed82b78f9b
commit
5a35077a4f
4 changed files with 29 additions and 8 deletions
|
@ -1,5 +1,5 @@
|
||||||
// use an integer for version numbers
|
// use an integer for version numbers
|
||||||
version = 9
|
version = 10
|
||||||
|
|
||||||
|
|
||||||
cloudstream {
|
cloudstream {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.hexated.SubsExtractors.invokeOpenSubs
|
||||||
import com.hexated.SubsExtractors.invokeWatchsomuch
|
import com.hexated.SubsExtractors.invokeWatchsomuch
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
import com.lagradost.cloudstream3.LoadResponse.Companion.addActors
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addActors
|
||||||
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addImdbId
|
||||||
import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer
|
||||||
import com.lagradost.cloudstream3.utils.*
|
import com.lagradost.cloudstream3.utils.*
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
|
@ -27,7 +28,7 @@ class StremioC : MainAPI() {
|
||||||
val res = tryParseJson<Manifest>(request("${mainUrl}/manifest.json").body.string()) ?: return null
|
val res = tryParseJson<Manifest>(request("${mainUrl}/manifest.json").body.string()) ?: return null
|
||||||
val lists = mutableListOf<HomePageList>()
|
val lists = mutableListOf<HomePageList>()
|
||||||
res.catalogs.apmap { catalog ->
|
res.catalogs.apmap { catalog ->
|
||||||
catalog.toHomePageList(this)?.let {
|
catalog.toHomePageList(this).let {
|
||||||
if (it.list.isNotEmpty()) lists.add(it)
|
if (it.list.isNotEmpty()) lists.add(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +48,7 @@ class StremioC : MainAPI() {
|
||||||
return list.distinct()
|
return list.distinct()
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun load(url: String): LoadResponse? {
|
override suspend fun load(url: String): LoadResponse {
|
||||||
val res = parseJson<CatalogEntry>(url)
|
val res = parseJson<CatalogEntry>(url)
|
||||||
mainUrl =
|
mainUrl =
|
||||||
if ((res.type == "movie" || res.type == "series") && isImdborTmdb(res.id)) cinemataUrl else mainUrl
|
if ((res.type == "movie" || res.type == "series") && isImdborTmdb(res.id)) cinemataUrl else mainUrl
|
||||||
|
@ -161,7 +162,7 @@ class StremioC : MainAPI() {
|
||||||
return entries
|
return entries
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun toHomePageList(provider: StremioC): HomePageList? {
|
suspend fun toHomePageList(provider: StremioC): HomePageList {
|
||||||
val entries = mutableListOf<SearchResponse>()
|
val entries = mutableListOf<SearchResponse>()
|
||||||
types.forEach { type ->
|
types.forEach { type ->
|
||||||
val json = request("${provider.mainUrl}/catalog/${type}/${id}.json").body.string()
|
val json = request("${provider.mainUrl}/catalog/${type}/${id}.json").body.string()
|
||||||
|
@ -211,7 +212,7 @@ class StremioC : MainAPI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun toLoadResponse(provider: StremioC, imdbId: String?): LoadResponse {
|
suspend fun toLoadResponse(provider: StremioC, imdbId: String?): LoadResponse {
|
||||||
if (videos == null || videos.isEmpty()) {
|
if (videos.isNullOrEmpty()) {
|
||||||
return provider.newMovieLoadResponse(
|
return provider.newMovieLoadResponse(
|
||||||
name,
|
name,
|
||||||
"${provider.mainUrl}/meta/${type}/${id}.json",
|
"${provider.mainUrl}/meta/${type}/${id}.json",
|
||||||
|
@ -226,6 +227,7 @@ class StremioC : MainAPI() {
|
||||||
tags = genre ?: genres
|
tags = genre ?: genres
|
||||||
addActors(cast)
|
addActors(cast)
|
||||||
addTrailer(trailersSources?.map { "https://www.youtube.com/watch?v=${it.source}" }?.randomOrNull())
|
addTrailer(trailersSources?.map { "https://www.youtube.com/watch?v=${it.source}" }?.randomOrNull())
|
||||||
|
addImdbId(imdbId)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return provider.newTvSeriesLoadResponse(
|
return provider.newTvSeriesLoadResponse(
|
||||||
|
@ -244,6 +246,7 @@ class StremioC : MainAPI() {
|
||||||
tags = genre ?: genres
|
tags = genre ?: genres
|
||||||
addActors(cast)
|
addActors(cast)
|
||||||
addTrailer(trailersSources?.map { "https://www.youtube.com/watch?v=${it.source}" }?.randomOrNull())
|
addTrailer(trailersSources?.map { "https://www.youtube.com/watch?v=${it.source}" }?.randomOrNull())
|
||||||
|
addImdbId(imdbId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,7 +340,7 @@ class StremioC : MainAPI() {
|
||||||
val resp = app.get(TRACKER_LIST_URL).text
|
val resp = app.get(TRACKER_LIST_URL).text
|
||||||
val otherTrackers = resp
|
val otherTrackers = resp
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.filterIndexed { i, s -> i % 2 == 0 }
|
.filterIndexed { i, _ -> i % 2 == 0 }
|
||||||
.filter { s -> s.isNotEmpty() }.joinToString("") { "&tr=$it" }
|
.filter { s -> s.isNotEmpty() }.joinToString("") { "&tr=$it" }
|
||||||
|
|
||||||
val sourceTrackers = sources
|
val sourceTrackers = sources
|
||||||
|
|
|
@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.hexated.SubsExtractors.invokeOpenSubs
|
import com.hexated.SubsExtractors.invokeOpenSubs
|
||||||
import com.hexated.SubsExtractors.invokeWatchsomuch
|
import com.hexated.SubsExtractors.invokeWatchsomuch
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addImdbId
|
||||||
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addTMDbId
|
||||||
import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer
|
import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer
|
||||||
import com.lagradost.cloudstream3.utils.*
|
import com.lagradost.cloudstream3.utils.*
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
|
@ -123,7 +125,8 @@ open class StremioX : MainAPI() {
|
||||||
val title = res.title ?: res.name ?: return null
|
val title = res.title ?: res.name ?: return null
|
||||||
val poster = getOriImageUrl(res.posterPath)
|
val poster = getOriImageUrl(res.posterPath)
|
||||||
val bgPoster = getOriImageUrl(res.backdropPath)
|
val bgPoster = getOriImageUrl(res.backdropPath)
|
||||||
val year = (res.releaseDate ?: res.firstAirDate)?.split("-")?.first()?.toIntOrNull()
|
val releaseDate = res.releaseDate ?: res.firstAirDate
|
||||||
|
val year = releaseDate?.split("-")?.first()?.toIntOrNull()
|
||||||
val rating = res.vote_average.toString().toRatingInt()
|
val rating = res.vote_average.toString().toRatingInt()
|
||||||
val genres = res.genres?.mapNotNull { it.name }
|
val genres = res.genres?.mapNotNull { it.name }
|
||||||
val isAnime =
|
val isAnime =
|
||||||
|
@ -155,7 +158,7 @@ open class StremioX : MainAPI() {
|
||||||
eps.seasonNumber,
|
eps.seasonNumber,
|
||||||
eps.episodeNumber
|
eps.episodeNumber
|
||||||
).toJson(),
|
).toJson(),
|
||||||
name = eps.name,
|
name = eps.name + if (isUpcoming(eps.airDate)) " - [UPCOMING]" else "",
|
||||||
season = eps.seasonNumber,
|
season = eps.seasonNumber,
|
||||||
episode = eps.episodeNumber,
|
episode = eps.episodeNumber,
|
||||||
posterUrl = getImageUrl(eps.stillPath),
|
posterUrl = getImageUrl(eps.stillPath),
|
||||||
|
@ -179,6 +182,8 @@ open class StremioX : MainAPI() {
|
||||||
this.recommendations = recommendations
|
this.recommendations = recommendations
|
||||||
this.actors = actors
|
this.actors = actors
|
||||||
addTrailer(trailer)
|
addTrailer(trailer)
|
||||||
|
addTMDbId(data.id.toString())
|
||||||
|
addImdbId(res.external_ids?.imdb_id)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newMovieLoadResponse(
|
newMovieLoadResponse(
|
||||||
|
@ -188,6 +193,7 @@ open class StremioX : MainAPI() {
|
||||||
LoadData(res.external_ids?.imdb_id).toJson()
|
LoadData(res.external_ids?.imdb_id).toJson()
|
||||||
) {
|
) {
|
||||||
this.posterUrl = poster
|
this.posterUrl = poster
|
||||||
|
this.comingSoon = isUpcoming(releaseDate)
|
||||||
this.backgroundPosterUrl = bgPoster
|
this.backgroundPosterUrl = bgPoster
|
||||||
this.year = year
|
this.year = year
|
||||||
this.plot = res.overview
|
this.plot = res.overview
|
||||||
|
@ -197,6 +203,8 @@ open class StremioX : MainAPI() {
|
||||||
this.recommendations = recommendations
|
this.recommendations = recommendations
|
||||||
this.actors = actors
|
this.actors = actors
|
||||||
addTrailer(trailer)
|
addTrailer(trailer)
|
||||||
|
addTMDbId(data.id.toString())
|
||||||
|
addImdbId(res.external_ids?.imdb_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
package com.hexated
|
package com.hexated
|
||||||
|
|
||||||
|
import com.lagradost.cloudstream3.APIHolder
|
||||||
import com.lagradost.nicehttp.Requests.Companion.await
|
import com.lagradost.nicehttp.Requests.Companion.await
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Locale
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
const val defaultTimeOut = 30L
|
const val defaultTimeOut = 30L
|
||||||
|
@ -54,6 +57,13 @@ fun getEpisodeSlug(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isUpcoming(dateString: String?): Boolean {
|
||||||
|
if (dateString == null) return false
|
||||||
|
val format = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
|
||||||
|
val dateTime = format.parse(dateString)?.time ?: return false
|
||||||
|
return APIHolder.unixTimeMS < dateTime
|
||||||
|
}
|
||||||
|
|
||||||
fun fixUrl(url: String, domain: String): String {
|
fun fixUrl(url: String, domain: String): String {
|
||||||
if (url.startsWith("http")) {
|
if (url.startsWith("http")) {
|
||||||
return url
|
return url
|
||||||
|
|
Loading…
Reference in a new issue