mirror of
https://github.com/hexated/cloudstream-extensions-hexated.git
synced 2024-08-15 00:03:22 +00:00
update
This commit is contained in:
parent
408d91f5a5
commit
7142755991
5 changed files with 53 additions and 29 deletions
|
@ -45,7 +45,7 @@ open class Gomov : MainAPI() {
|
|||
private fun Element.toSearchResult(): SearchResponse? {
|
||||
val title = this.selectFirst("h2.entry-title > a")?.text()?.trim() ?: return null
|
||||
val href = fixUrl(this.selectFirst("a")!!.attr("href"))
|
||||
val posterUrl = fixUrlNull(this.selectFirst("a > img").getImgAttr()).fixImageQuality()
|
||||
val posterUrl = fixUrlNull(this.selectFirst("a > img")?.getImageAttr()).fixImageQuality()
|
||||
val quality = this.select("div.gmr-qual, div.gmr-quality-item > a").text().trim().replace("-", "")
|
||||
return if (quality.isEmpty()) {
|
||||
val episode =
|
||||
|
@ -66,7 +66,7 @@ open class Gomov : MainAPI() {
|
|||
private fun Element.toRecommendResult(): SearchResponse? {
|
||||
val title = this.selectFirst("a > span.idmuvi-rp-title")?.text()?.trim() ?: return null
|
||||
val href = this.selectFirst("a")!!.attr("href")
|
||||
val posterUrl = fixUrlNull(this.selectFirst("a > img").getImgAttr().fixImageQuality())
|
||||
val posterUrl = fixUrlNull(this.selectFirst("a > img")?.getImageAttr().fixImageQuality())
|
||||
return newMovieSearchResponse(title, href, TvType.Movie) {
|
||||
this.posterUrl = posterUrl
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ open class Gomov : MainAPI() {
|
|||
document.selectFirst("h1.entry-title")?.text()?.substringBefore("Season")?.substringBefore("Episode")?.trim()
|
||||
.toString()
|
||||
val poster =
|
||||
fixUrlNull(document.selectFirst("figure.pull-left > img").getImgAttr())?.fixImageQuality()
|
||||
fixUrlNull(document.selectFirst("figure.pull-left > img")?.getImageAttr())?.fixImageQuality()
|
||||
val tags = document.select("span.gmr-movie-genre:contains(Genre:) > a").map { it.text() }
|
||||
|
||||
val year =
|
||||
|
@ -176,24 +176,29 @@ open class Gomov : MainAPI() {
|
|||
|
||||
}
|
||||
|
||||
private fun Element?.getImgAttr() : String? {
|
||||
return this?.attr("data-src").takeIf { it?.isNotEmpty() == true } ?: this?.attr("src")
|
||||
private fun Element.getImageAttr(): String? {
|
||||
return when {
|
||||
this.hasAttr("data-src") -> this.attr("abs:data-src")
|
||||
this.hasAttr("data-lazy-src") -> this.attr("abs:data-lazy-src")
|
||||
this.hasAttr("srcset") -> this.attr("abs:srcset").substringBefore(" ")
|
||||
else -> this.attr("abs:src")
|
||||
}
|
||||
}
|
||||
|
||||
private fun Element?.getIframeAttr() : String? {
|
||||
return this?.attr("data-litespeed-src").takeIf { it?.isNotEmpty() == true } ?: this?.attr("src")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun String?.fixImageQuality(): String? {
|
||||
if (this == null) return null
|
||||
val regex = Regex("(-\\d*x\\d*)").find(this)?.groupValues?.get(0) ?: return this
|
||||
return this.replace(regex, "")
|
||||
}
|
||||
|
||||
fun getBaseUrl(url: String): String {
|
||||
return URI(url).let {
|
||||
"${it.scheme}://${it.host}"
|
||||
private fun String?.fixImageQuality(): String? {
|
||||
if (this == null) return null
|
||||
val regex = Regex("(-\\d*x\\d*)").find(this)?.groupValues?.get(0) ?: return this
|
||||
return this.replace(regex, "")
|
||||
}
|
||||
|
||||
private fun getBaseUrl(url: String): String {
|
||||
return URI(url).let {
|
||||
"${it.scheme}://${it.host}"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue