This commit is contained in:
LagradOst 2022-02-07 14:32:24 +01:00
parent c191d16b01
commit d315b557ec
2 changed files with 76 additions and 59 deletions

View file

@ -65,6 +65,7 @@ object APIHolder {
SflixProvider("https://sflix.to", "Sflix"),
SflixProvider("https://dopebox.to", "Dopebox"),
SflixProvider("https://solarmovie.pe", "Solarmovie"),
//TmdbProvider(),

View file

@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.LoadResponse.Companion.addActors
import com.lagradost.cloudstream3.LoadResponse.Companion.setDuration
import com.lagradost.cloudstream3.mvvm.suspendSafeApiCall
import com.lagradost.cloudstream3.network.WebViewResolver
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
import com.lagradost.cloudstream3.utils.AppUtils.toJson
@ -99,9 +100,9 @@ class SflixProvider(providerUrl: String, providerName: String) : MainAPI() {
val document = app.get(url).document
val details = document.select("div.detail_page-watch")
val img = details.select("img.film-poster-img")
val posterUrl = img.attr("src")
val title = img.attr("title")
val img = details?.select("img.film-poster-img")
val posterUrl = img?.attr("src")
val title = img?.attr("title") ?: throw ErrorLoadingException("No Title")
/*
val year = Regex("""[Rr]eleased:\s*(\d{4})""").find(
@ -110,7 +111,7 @@ class SflixProvider(providerUrl: String, providerName: String) : MainAPI() {
val duration = Regex("""[Dd]uration:\s*(\d*)""").find(
document.select("div.elements").text()
)?.groupValues?.get(1)?.trim()?.plus(" min")*/
var duration = document.selectFirst(".fs-item > .duration").text()?.trim()
var duration = document.selectFirst(".fs-item > .duration")?.text()?.trim()
var year: Int? = null
var tags: List<String>? = null
var cast: List<String>? = null
@ -133,7 +134,7 @@ class SflixProvider(providerUrl: String, providerName: String) : MainAPI() {
}
}
}
val plot = details.select("div.description").text().replace("Overview:", "").trim()
val plot = details.select("div.description")?.text()?.replace("Overview:", "")?.trim()
val isMovie = url.contains("/movie/")
@ -169,9 +170,16 @@ class SflixProvider(providerUrl: String, providerName: String) : MainAPI() {
// Supported streams, they're identical
val sourceIds = Jsoup.parse(episodes).select("a").mapNotNull { element ->
val sourceId = element.attr("data-id") ?: return@mapNotNull null
var sourceId = element.attr("data-id")
if (sourceId.isNullOrEmpty())
sourceId = element.attr("data-linkid")
if (element.select("span")?.text()?.trim()?.isValidServer() == true) {
"$url.$sourceId".replace("/movie/", "/watch-movie/")
if (sourceId.isNullOrEmpty()) {
fixUrlNull(element.attr("href"))
} else {
"$url.$sourceId".replace("/movie/", "/watch-movie/")
}
} else {
null
}
@ -189,41 +197,47 @@ class SflixProvider(providerUrl: String, providerName: String) : MainAPI() {
} else {
val seasonsDocument = app.get("$mainUrl/ajax/v2/tv/seasons/$id").document
val episodes = arrayListOf<TvSeriesEpisode>()
var seasonItems = seasonsDocument.select("div.dropdown-menu.dropdown-menu-model > a")
if (seasonItems.isNullOrEmpty())
seasonItems = seasonsDocument.select("div.dropdown-menu > a.dropdown-item")
seasonItems?.forEachIndexed { season, element ->
val seasonId = element.attr("data-id")
if (seasonId.isNullOrBlank()) return@forEachIndexed
seasonsDocument.select("div.dropdown-menu.dropdown-menu-model > a")
.forEachIndexed { season, element ->
val seasonId = element.attr("data-id")
if (seasonId.isNullOrBlank()) return@forEachIndexed
var episode = 0
app.get("$mainUrl/ajax/v2/season/episodes/$seasonId").document
.select("div.flw-item.film_single-item.episode-item.eps-item")
.forEach {
val episodeImg = it.select("img") ?: return@forEach
val episodeTitle = episodeImg.attr("title") ?: return@forEach
val episodePosterUrl = episodeImg.attr("src") ?: return@forEach
val episodeData = it.attr("data-id") ?: return@forEach
episode++
val episodeNum =
(it.select("div.episode-number")?.text()
?: episodeTitle).let { str ->
Regex("""\d+""").find(str)?.groupValues?.firstOrNull()
?.toIntOrNull()
} ?: episode
episodes.add(
TvSeriesEpisode(
episodeTitle.removePrefix("Episode $episodeNum: "),
season + 1,
episodeNum,
Pair(url, episodeData).toJson(),
fixUrl(episodePosterUrl)
)
)
}
var episode = 0
val seasonEpisodes = app.get("$mainUrl/ajax/v2/season/episodes/$seasonId").document
var seasonEpisodesItems =
seasonEpisodes.select("div.flw-item.film_single-item.episode-item.eps-item")
if (seasonEpisodesItems.isNullOrEmpty()) {
seasonEpisodesItems =
seasonEpisodes.select("ul > li > a")
}
seasonEpisodesItems.forEach {
val episodeImg = it?.select("img")
val episodeTitle = episodeImg?.attr("title") ?: it.ownText()
val episodePosterUrl = episodeImg?.attr("src")
val episodeData = it.attr("data-id") ?: return@forEach
episode++
val episodeNum =
(it.select("div.episode-number")?.text()
?: episodeTitle).let { str ->
Regex("""\d+""").find(str)?.groupValues?.firstOrNull()
?.toIntOrNull()
} ?: episode
episodes.add(
TvSeriesEpisode(
episodeTitle?.removePrefix("Episode $episodeNum: "),
season + 1,
episodeNum,
Pair(url, episodeData).toJson(),
fixUrlNull(episodePosterUrl)
)
)
}
}
return newTvSeriesLoadResponse(title, url, TvType.TvSeries, episodes) {
this.posterUrl = posterUrl
this.year = year
@ -277,29 +291,31 @@ class SflixProvider(providerUrl: String, providerName: String) : MainAPI() {
} ?: tryParseJson<List<String>>(data))?.distinct()
urls?.apmap { url ->
val sources = app.get(
url,
interceptor = WebViewResolver(
Regex("""/getSources"""),
)
).text
suspendSafeApiCall {
val sources = app.get(
url,
interceptor = WebViewResolver(
Regex("""/getSources"""),
)
).text
val mapped = parseJson<SourceObject>(sources)
val mapped = parseJson<SourceObject>(sources)
mapped.tracks?.forEach {
it?.toSubtitleFile()?.let { subtitleFile ->
subtitleCallback.invoke(subtitleFile)
mapped.tracks?.forEach {
it?.toSubtitleFile()?.let { subtitleFile ->
subtitleCallback.invoke(subtitleFile)
}
}
}
listOf(
mapped.sources to "",
mapped.sources1 to "source 2",
mapped.sources2 to "source 3",
mapped.sourcesBackup to "source backup"
).forEach { (sources, sourceName) ->
sources?.forEach {
it?.toExtractorLink(this, sourceName)?.forEach(callback)
listOf(
mapped.sources to "",
mapped.sources1 to "source 2",
mapped.sources2 to "source 3",
mapped.sourcesBackup to "source backup"
).forEach { (sources, sourceName) ->
sources?.forEach {
it?.toExtractorLink(this, sourceName)?.forEach(callback)
}
}
}
}