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://sflix.to", "Sflix"),
SflixProvider("https://dopebox.to", "Dopebox"), SflixProvider("https://dopebox.to", "Dopebox"),
SflixProvider("https://solarmovie.pe", "Solarmovie"),
//TmdbProvider(), //TmdbProvider(),

View file

@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty
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.setDuration import com.lagradost.cloudstream3.LoadResponse.Companion.setDuration
import com.lagradost.cloudstream3.mvvm.suspendSafeApiCall
import com.lagradost.cloudstream3.network.WebViewResolver import com.lagradost.cloudstream3.network.WebViewResolver
import com.lagradost.cloudstream3.utils.AppUtils.parseJson import com.lagradost.cloudstream3.utils.AppUtils.parseJson
import com.lagradost.cloudstream3.utils.AppUtils.toJson 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 document = app.get(url).document
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")
val posterUrl = img.attr("src") val posterUrl = img?.attr("src")
val title = img.attr("title") val title = img?.attr("title") ?: throw ErrorLoadingException("No Title")
/* /*
val year = Regex("""[Rr]eleased:\s*(\d{4})""").find( 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( val duration = Regex("""[Dd]uration:\s*(\d*)""").find(
document.select("div.elements").text() document.select("div.elements").text()
)?.groupValues?.get(1)?.trim()?.plus(" min")*/ )?.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 year: Int? = null
var tags: List<String>? = null var tags: List<String>? = null
var cast: 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/") val isMovie = url.contains("/movie/")
@ -169,9 +170,16 @@ class SflixProvider(providerUrl: String, providerName: String) : MainAPI() {
// Supported streams, they're identical // Supported streams, they're identical
val sourceIds = Jsoup.parse(episodes).select("a").mapNotNull { element -> 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) { if (element.select("span")?.text()?.trim()?.isValidServer() == true) {
if (sourceId.isNullOrEmpty()) {
fixUrlNull(element.attr("href"))
} else {
"$url.$sourceId".replace("/movie/", "/watch-movie/") "$url.$sourceId".replace("/movie/", "/watch-movie/")
}
} else { } else {
null null
} }
@ -189,19 +197,25 @@ class SflixProvider(providerUrl: String, providerName: String) : MainAPI() {
} else { } else {
val seasonsDocument = app.get("$mainUrl/ajax/v2/tv/seasons/$id").document val seasonsDocument = app.get("$mainUrl/ajax/v2/tv/seasons/$id").document
val episodes = arrayListOf<TvSeriesEpisode>() val episodes = arrayListOf<TvSeriesEpisode>()
var seasonItems = seasonsDocument.select("div.dropdown-menu.dropdown-menu-model > a")
seasonsDocument.select("div.dropdown-menu.dropdown-menu-model > a") if (seasonItems.isNullOrEmpty())
.forEachIndexed { season, element -> seasonItems = seasonsDocument.select("div.dropdown-menu > a.dropdown-item")
seasonItems?.forEachIndexed { season, element ->
val seasonId = element.attr("data-id") val seasonId = element.attr("data-id")
if (seasonId.isNullOrBlank()) return@forEachIndexed if (seasonId.isNullOrBlank()) return@forEachIndexed
var episode = 0 var episode = 0
app.get("$mainUrl/ajax/v2/season/episodes/$seasonId").document val seasonEpisodes = app.get("$mainUrl/ajax/v2/season/episodes/$seasonId").document
.select("div.flw-item.film_single-item.episode-item.eps-item") var seasonEpisodesItems =
.forEach { seasonEpisodes.select("div.flw-item.film_single-item.episode-item.eps-item")
val episodeImg = it.select("img") ?: return@forEach if (seasonEpisodesItems.isNullOrEmpty()) {
val episodeTitle = episodeImg.attr("title") ?: return@forEach seasonEpisodesItems =
val episodePosterUrl = episodeImg.attr("src") ?: return@forEach 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 val episodeData = it.attr("data-id") ?: return@forEach
episode++ episode++
@ -215,11 +229,11 @@ class SflixProvider(providerUrl: String, providerName: String) : MainAPI() {
episodes.add( episodes.add(
TvSeriesEpisode( TvSeriesEpisode(
episodeTitle.removePrefix("Episode $episodeNum: "), episodeTitle?.removePrefix("Episode $episodeNum: "),
season + 1, season + 1,
episodeNum, episodeNum,
Pair(url, episodeData).toJson(), Pair(url, episodeData).toJson(),
fixUrl(episodePosterUrl) fixUrlNull(episodePosterUrl)
) )
) )
} }
@ -277,6 +291,7 @@ class SflixProvider(providerUrl: String, providerName: String) : MainAPI() {
} ?: tryParseJson<List<String>>(data))?.distinct() } ?: tryParseJson<List<String>>(data))?.distinct()
urls?.apmap { url -> urls?.apmap { url ->
suspendSafeApiCall {
val sources = app.get( val sources = app.get(
url, url,
interceptor = WebViewResolver( interceptor = WebViewResolver(
@ -303,6 +318,7 @@ class SflixProvider(providerUrl: String, providerName: String) : MainAPI() {
} }
} }
} }
}
return !urls.isNullOrEmpty() return !urls.isNullOrEmpty()
} }