Add rating and youtube trailer link to Sflix provider. (#868)

This commit is contained in:
Jace 2022-03-28 17:15:57 +08:00 committed by GitHub
parent bec54ac72c
commit 1d5dc41346
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -16,6 +16,7 @@ import com.lagradost.cloudstream3.movieproviders.*
import com.lagradost.cloudstream3.ui.player.SubtitleData
import com.lagradost.cloudstream3.utils.ExtractorLink
import java.util.*
import kotlin.math.absoluteValue
const val USER_AGENT =
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
@ -903,3 +904,6 @@ fun fetchUrls(text: String?): List<String> {
Regex("""(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&\/\/=]*))""")
return linkRegex.findAll(text).map { it.value.trim().removeSurrounding("\"") }.toList()
}
fun String?.toRatingInt() : Int? =
this?.trim()?.toDoubleOrNull()?.absoluteValue?.times(1000f)?.toInt()

View File

@ -129,6 +129,10 @@ open class SflixProvider() : MainAPI() {
var year: Int? = null
var tags: List<String>? = null
var cast: List<String>? = null
val youtubeTrailer = document.selectFirst("iframe#iframe-trailer")?.attr("data-src")
val rating = document.selectFirst(".fs-item > .imdb")?.text()?.trim()
?.removePrefix("IMDB:")?.toRatingInt()
document.select("div.elements > .row > div > .row-line")?.forEach { element ->
val type = element?.select(".type")?.text() ?: return@forEach
when {
@ -210,6 +214,8 @@ open class SflixProvider() : MainAPI() {
this.tags = tags
this.recommendations = recommendations
this.comingSoon = comingSoon
this.trailerUrl = youtubeTrailer
this.rating = rating
}
} else {
val seasonsDocument = app.get("$mainUrl/ajax/v2/tv/seasons/$id").document
@ -264,6 +270,8 @@ open class SflixProvider() : MainAPI() {
addActors(cast)
this.tags = tags
this.recommendations = recommendations
this.trailerUrl = youtubeTrailer
this.rating = rating
}
}
}