StremioX & StremioC: added imdb id

This commit is contained in:
hexated 2023-08-11 20:22:36 +07:00
parent ed82b78f9b
commit 5a35077a4f
4 changed files with 29 additions and 8 deletions

View file

@ -1,5 +1,5 @@
// use an integer for version numbers
version = 9
version = 10
cloudstream {

View file

@ -5,6 +5,7 @@ import com.hexated.SubsExtractors.invokeOpenSubs
import com.hexated.SubsExtractors.invokeWatchsomuch
import com.lagradost.cloudstream3.*
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.utils.*
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 lists = mutableListOf<HomePageList>()
res.catalogs.apmap { catalog ->
catalog.toHomePageList(this)?.let {
catalog.toHomePageList(this).let {
if (it.list.isNotEmpty()) lists.add(it)
}
}
@ -47,7 +48,7 @@ class StremioC : MainAPI() {
return list.distinct()
}
override suspend fun load(url: String): LoadResponse? {
override suspend fun load(url: String): LoadResponse {
val res = parseJson<CatalogEntry>(url)
mainUrl =
if ((res.type == "movie" || res.type == "series") && isImdborTmdb(res.id)) cinemataUrl else mainUrl
@ -161,7 +162,7 @@ class StremioC : MainAPI() {
return entries
}
suspend fun toHomePageList(provider: StremioC): HomePageList? {
suspend fun toHomePageList(provider: StremioC): HomePageList {
val entries = mutableListOf<SearchResponse>()
types.forEach { type ->
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 {
if (videos == null || videos.isEmpty()) {
if (videos.isNullOrEmpty()) {
return provider.newMovieLoadResponse(
name,
"${provider.mainUrl}/meta/${type}/${id}.json",
@ -226,6 +227,7 @@ class StremioC : MainAPI() {
tags = genre ?: genres
addActors(cast)
addTrailer(trailersSources?.map { "https://www.youtube.com/watch?v=${it.source}" }?.randomOrNull())
addImdbId(imdbId)
}
} else {
return provider.newTvSeriesLoadResponse(
@ -244,6 +246,7 @@ class StremioC : MainAPI() {
tags = genre ?: genres
addActors(cast)
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 otherTrackers = resp
.split("\n")
.filterIndexed { i, s -> i % 2 == 0 }
.filterIndexed { i, _ -> i % 2 == 0 }
.filter { s -> s.isNotEmpty() }.joinToString("") { "&tr=$it" }
val sourceTrackers = sources

View file

@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonProperty
import com.hexated.SubsExtractors.invokeOpenSubs
import com.hexated.SubsExtractors.invokeWatchsomuch
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.utils.*
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
@ -123,7 +125,8 @@ open class StremioX : MainAPI() {
val title = res.title ?: res.name ?: return null
val poster = getOriImageUrl(res.posterPath)
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 genres = res.genres?.mapNotNull { it.name }
val isAnime =
@ -155,7 +158,7 @@ open class StremioX : MainAPI() {
eps.seasonNumber,
eps.episodeNumber
).toJson(),
name = eps.name,
name = eps.name + if (isUpcoming(eps.airDate)) " - [UPCOMING]" else "",
season = eps.seasonNumber,
episode = eps.episodeNumber,
posterUrl = getImageUrl(eps.stillPath),
@ -179,6 +182,8 @@ open class StremioX : MainAPI() {
this.recommendations = recommendations
this.actors = actors
addTrailer(trailer)
addTMDbId(data.id.toString())
addImdbId(res.external_ids?.imdb_id)
}
} else {
newMovieLoadResponse(
@ -188,6 +193,7 @@ open class StremioX : MainAPI() {
LoadData(res.external_ids?.imdb_id).toJson()
) {
this.posterUrl = poster
this.comingSoon = isUpcoming(releaseDate)
this.backgroundPosterUrl = bgPoster
this.year = year
this.plot = res.overview
@ -197,6 +203,8 @@ open class StremioX : MainAPI() {
this.recommendations = recommendations
this.actors = actors
addTrailer(trailer)
addTMDbId(data.id.toString())
addImdbId(res.external_ids?.imdb_id)
}
}
}

View file

@ -1,9 +1,12 @@
package com.hexated
import com.lagradost.cloudstream3.APIHolder
import com.lagradost.nicehttp.Requests.Companion.await
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import java.text.SimpleDateFormat
import java.util.Locale
import java.util.concurrent.TimeUnit
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 {
if (url.startsWith("http")) {
return url