forked from recloudstream/cloudstream
fixed sflix
This commit is contained in:
parent
487f6ea03a
commit
4215c094ff
1 changed files with 57 additions and 51 deletions
|
@ -122,8 +122,7 @@ class SflixProvider(providerUrl: String, providerName: String) : MainAPI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun load(url: String): LoadResponse {
|
override fun load(url: String): LoadResponse {
|
||||||
val html = app.get(url).text
|
val document = app.get(url).document
|
||||||
val document = Jsoup.parse(html)
|
|
||||||
|
|
||||||
val details = document.select("div.detail_page-watch")
|
val details = document.select("div.detail_page-watch")
|
||||||
val img = details.select("img.film-poster-img")
|
val img = details.select("img.film-poster-img")
|
||||||
|
@ -138,15 +137,14 @@ 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/")
|
val isMovie = url.contains("/movie/")
|
||||||
|
|
||||||
|
|
||||||
// https://sflix.to/movie/free-never-say-never-again-hd-18317 -> 18317
|
// https://sflix.to/movie/free-never-say-never-again-hd-18317 -> 18317
|
||||||
val idRegex = Regex(""".*-(\d+)""")
|
val idRegex = Regex(""".*-(\d+)""")
|
||||||
val dataId = details.attr("data-id")
|
val dataId = details.attr("data-id")
|
||||||
val id = if (dataId.isNullOrEmpty())
|
val id = if (dataId.isNullOrEmpty())
|
||||||
idRegex.find(url)?.groupValues?.get(1) ?: throw RuntimeException("Unable to get id from '$url'")
|
idRegex.find(url)?.groupValues?.get(1)
|
||||||
|
?: throw RuntimeException("Unable to get id from '$url'")
|
||||||
else dataId
|
else dataId
|
||||||
|
|
||||||
if (isMovie) {
|
if (isMovie) {
|
||||||
|
@ -160,7 +158,8 @@ class SflixProvider(providerUrl: String, providerName: String) : MainAPI() {
|
||||||
|| it.select("span").text().trim().equals("Vidcloud", ignoreCase = true)
|
|| it.select("span").text().trim().equals("Vidcloud", ignoreCase = true)
|
||||||
}?.attr("data-id")
|
}?.attr("data-id")
|
||||||
|
|
||||||
val webViewUrl = "$url${sourceId?.let { ".$it" } ?: ""}".replace("/movie/", "/watch-movie/")
|
val webViewUrl =
|
||||||
|
"$url${sourceId?.let { ".$it" } ?: ""}".replace("/movie/", "/watch-movie/")
|
||||||
|
|
||||||
return newMovieLoadResponse(title, url, TvType.Movie, webViewUrl) {
|
return newMovieLoadResponse(title, url, TvType.Movie, webViewUrl) {
|
||||||
this.year = year
|
this.year = year
|
||||||
|
@ -169,40 +168,43 @@ class SflixProvider(providerUrl: String, providerName: String) : MainAPI() {
|
||||||
setDuration(duration)
|
setDuration(duration)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val seasonsHtml = app.get("$mainUrl/ajax/v2/tv/seasons/$id").text
|
val seasonsDocument = app.get("$mainUrl/ajax/v2/tv/seasons/$id").document
|
||||||
val seasonsDocument = Jsoup.parse(seasonsHtml)
|
|
||||||
val episodes = arrayListOf<TvSeriesEpisode>()
|
val episodes = arrayListOf<TvSeriesEpisode>()
|
||||||
|
|
||||||
seasonsDocument.select("div.dropdown-menu.dropdown-menu-model > a").forEachIndexed { season, element ->
|
seasonsDocument.select("div.dropdown-menu.dropdown-menu-model > a")
|
||||||
val seasonId = element.attr("data-id")
|
.forEachIndexed { season, element ->
|
||||||
if (seasonId.isNullOrBlank()) return@forEachIndexed
|
val seasonId = element.attr("data-id")
|
||||||
|
if (seasonId.isNullOrBlank()) return@forEachIndexed
|
||||||
|
|
||||||
val seasonHtml = app.get("$mainUrl/ajax/v2/season/episodes/$seasonId").text
|
var episode = 0
|
||||||
val seasonDocument = Jsoup.parse(seasonHtml)
|
app.get("$mainUrl/ajax/v2/season/episodes/$seasonId").document
|
||||||
seasonDocument.select("div.flw-item.film_single-item.episode-item.eps-item")
|
.select("div.flw-item.film_single-item.episode-item.eps-item")
|
||||||
.forEachIndexed { _, it ->
|
.forEach {
|
||||||
val episodeImg = it.select("img")
|
val episodeImg = it.select("img") ?: return@forEach
|
||||||
val episodeTitle = episodeImg.attr("title")
|
val episodeTitle = episodeImg.attr("title") ?: return@forEach
|
||||||
val episodePosterUrl = episodeImg.attr("src")
|
val episodePosterUrl = episodeImg.attr("src") ?: return@forEach
|
||||||
val episodeData = it.attr("data-id")
|
val episodeData = it.attr("data-id") ?: return@forEach
|
||||||
|
|
||||||
// val episodeNum =
|
episode++
|
||||||
// Regex("""\d+""").find(it.select("div.episode-number").text())?.groupValues?.get(1)
|
|
||||||
// ?.toIntOrNull()
|
|
||||||
|
|
||||||
episodes.add(
|
val episodeNum =
|
||||||
TvSeriesEpisode(
|
(it.select("div.episode-number")?.text() ?: episodeTitle).let { str ->
|
||||||
episodeTitle,
|
Regex("""\d+""").find(str)?.groupValues?.firstOrNull()
|
||||||
season + 1,
|
?.toIntOrNull()
|
||||||
null,
|
} ?: episode
|
||||||
"$url:::$episodeData",
|
|
||||||
fixUrl(episodePosterUrl)
|
episodes.add(
|
||||||
|
TvSeriesEpisode(
|
||||||
|
episodeTitle.removePrefix("Episode $episodeNum: "),
|
||||||
|
season + 1,
|
||||||
|
episodeNum,
|
||||||
|
"$url:::$episodeData",
|
||||||
|
fixUrl(episodePosterUrl)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
|
return newTvSeriesLoadResponse(title, url, TvType.TvSeries, episodes) {
|
||||||
}
|
|
||||||
return newTvSeriesLoadResponse(title,url,TvType.TvSeries,episodes) {
|
|
||||||
this.posterUrl = posterUrl
|
this.posterUrl = posterUrl
|
||||||
this.year = year
|
this.year = year
|
||||||
this.plot = plot
|
this.plot = plot
|
||||||
|
@ -264,18 +266,19 @@ class SflixProvider(providerUrl: String, providerName: String) : MainAPI() {
|
||||||
).text
|
).text
|
||||||
|
|
||||||
val mapped = mapper.readValue<SourceObject>(sources)
|
val mapped = mapper.readValue<SourceObject>(sources)
|
||||||
|
|
||||||
mapped.tracks?.forEach {
|
mapped.tracks?.forEach {
|
||||||
it?.toSubtitleFile()?.let { subtitleFile ->
|
it?.toSubtitleFile()?.let { subtitleFile ->
|
||||||
subtitleCallback.invoke(subtitleFile)
|
subtitleCallback.invoke(subtitleFile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val list = listOf(
|
|
||||||
|
listOf(
|
||||||
mapped.sources to "source 1",
|
mapped.sources to "source 1",
|
||||||
mapped.sources1 to "source 2",
|
mapped.sources1 to "source 2",
|
||||||
mapped.sources2 to "source 3",
|
mapped.sources2 to "source 3",
|
||||||
mapped.sourcesBackup to "source backup"
|
mapped.sourcesBackup to "source backup"
|
||||||
)
|
).forEach { subList ->
|
||||||
list.forEach { subList ->
|
|
||||||
subList.first?.forEach {
|
subList.first?.forEach {
|
||||||
it?.toExtractorLink(this, subList.second)?.forEach(callback)
|
it?.toExtractorLink(this, subList.second)?.forEach(callback)
|
||||||
}
|
}
|
||||||
|
@ -288,19 +291,24 @@ class SflixProvider(providerUrl: String, providerName: String) : MainAPI() {
|
||||||
|
|
||||||
fun Sources.toExtractorLink(caller: MainAPI, name: String): List<ExtractorLink>? {
|
fun Sources.toExtractorLink(caller: MainAPI, name: String): List<ExtractorLink>? {
|
||||||
return this.file?.let { file ->
|
return this.file?.let { file ->
|
||||||
val isM3u8 = URI(this.file).path.endsWith(".m3u8") || this.type.equals("hls", ignoreCase = true)
|
val isM3u8 = URI(this.file).path.endsWith(".m3u8") || this.type.equals(
|
||||||
|
"hls",
|
||||||
|
ignoreCase = true
|
||||||
|
)
|
||||||
if (isM3u8) {
|
if (isM3u8) {
|
||||||
M3u8Helper().m3u8Generation(M3u8Helper.M3u8Stream(this.file, null), true).map { stream ->
|
M3u8Helper().m3u8Generation(M3u8Helper.M3u8Stream(this.file, null), true)
|
||||||
val qualityString = if ((stream.quality ?: 0) == 0) label ?: "" else "${stream.quality}p"
|
.map { stream ->
|
||||||
ExtractorLink(
|
val qualityString = if ((stream.quality ?: 0) == 0) label
|
||||||
caller.name,
|
?: "" else "${stream.quality}p"
|
||||||
"${caller.name} $qualityString $name",
|
ExtractorLink(
|
||||||
stream.streamUrl,
|
caller.name,
|
||||||
caller.mainUrl,
|
"${caller.name} $qualityString $name",
|
||||||
getQualityFromName(stream.quality.toString()),
|
stream.streamUrl,
|
||||||
true
|
caller.mainUrl,
|
||||||
)
|
getQualityFromName(stream.quality.toString()),
|
||||||
}
|
true
|
||||||
|
)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
listOf(ExtractorLink(
|
listOf(ExtractorLink(
|
||||||
caller.name,
|
caller.name,
|
||||||
|
@ -311,7 +319,6 @@ class SflixProvider(providerUrl: String, providerName: String) : MainAPI() {
|
||||||
false,
|
false,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,7 +330,6 @@ class SflixProvider(providerUrl: String, providerName: String) : MainAPI() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue