[Feature] Add quality and year to various providers. (#887)

* add more quality to SearchQuality enum. Add quality to Pinoymovieses provider.

* add quality and year to sflix.
This commit is contained in:
Jace 2022-04-01 22:27:46 +08:00 committed by GitHub
parent c11a96a3e1
commit a84468d726
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 71 additions and 24 deletions

View file

@ -554,11 +554,14 @@ enum class SearchQuality {
Telecine, // TC
HQ,
HD,
HDR, // high dynamic range
BlueRay,
DVD,
SD,
FourK,
UHD,
SDR, // standard dynamic range
WebRip
}
/**Add anything to here if you find a site that uses some specific naming convention*/
@ -567,22 +570,33 @@ fun getQualityFromString(string: String?) : SearchQuality? {
return when(check) {
"cam" -> SearchQuality.Cam
"camrip" -> SearchQuality.CamRip
"hdcam" -> SearchQuality.HdCam
"highquality" -> SearchQuality.HQ
"hq" -> SearchQuality.HQ
"highdefinition" -> SearchQuality.HD
"hdrip" -> SearchQuality.HD
"hd" -> SearchQuality.HD
"camrip" -> SearchQuality.CamRip
"rip" -> SearchQuality.CamRip
"telecine" -> SearchQuality.Telecine
"tc" -> SearchQuality.Telecine
"telesync" -> SearchQuality.Telesync
"ts" -> SearchQuality.Telesync
"dvd" -> SearchQuality.DVD
"blueray" -> SearchQuality.BlueRay
"bluray" -> SearchQuality.BlueRay
"br" -> SearchQuality.BlueRay
"standard" -> SearchQuality.SD
"sd" -> SearchQuality.SD
"4k" -> SearchQuality.FourK
"uhd" -> SearchQuality.UHD // may also be 4k or 8k
"blue" -> SearchQuality.BlueRay
"wp" -> SearchQuality.WorkPrint
"workprint" -> SearchQuality.WorkPrint
"webrip" -> SearchQuality.WebRip
"web" -> SearchQuality.WebRip
"hdr" -> SearchQuality.HDR
"sdr" -> SearchQuality.SDR
else -> null
}
}

View file

@ -1,12 +1,13 @@
package com.lagradost.cloudstream3.movieproviders
import android.util.Log
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.module.kotlin.readValue
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.extractors.FEmbed
import com.lagradost.cloudstream3.extractors.helper.VstreamhubHelper
import com.lagradost.cloudstream3.network.DdosGuardKiller
import com.lagradost.cloudstream3.utils.AppUtils.toJson
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.loadExtractor
import org.jsoup.select.Elements
@ -55,6 +56,8 @@ class PinoyMoviesEsProvider : MainAPI() {
val rex = Regex("\\((\\d+)")
year = rex.find(name)?.value?.replace("(", "")?.toIntOrNull()
}
//Log.i(this.name, "ApiError -> ${it.selectFirst("span.quality")?.text()}")
val searchQual = getQualityFromString(it.selectFirst("span.quality")?.text())
MovieSearchResponse(
name = name,
@ -62,7 +65,8 @@ class PinoyMoviesEsProvider : MainAPI() {
apiName = this.name,
type = TvType.Movie,
posterUrl = image,
year = year
year = year,
quality = searchQual
)
}?.distinctBy { c -> c.url } ?: listOf()
//Add to list of homepages
@ -116,14 +120,16 @@ class PinoyMoviesEsProvider : MainAPI() {
val title = urlTitle.text()?.trim() ?: "<No Title>"
val year = urlTitle.select("span.year")?.text()?.toIntOrNull()
val image = it.select("div.poster > img")?.attr("src")
val searchQual = getQualityFromString(it.selectFirst("span.quality")?.text())
MovieSearchResponse(
title,
link,
this.name,
TvType.Movie,
image,
year
name = title,
url = link,
apiName = this.name,
type = TvType.Movie,
posterUrl = image,
year = year,
quality = searchQual
)
}?.distinctBy { it.url } ?: listOf()
}
@ -177,10 +183,10 @@ class PinoyMoviesEsProvider : MainAPI() {
)
val innerPage = app.post("https://pinoymovies.es/wp-admin/admin-ajax.php ",
referer = url, data = content).document.select("body")?.text()?.trim()
if (!innerPage.isNullOrEmpty()) {
val embedData = mapper.readValue<EmbedUrl>(innerPage)
//Log.i(this.name, "Result => (embed_url) ${embedData.embed_url}")
listOfLinks.add(embedData.embed_url)
if (!innerPage.isNullOrBlank()) {
tryParseJson<EmbedUrl>(innerPage)?.let {
listOfLinks.add(it.embed_url)
}
}
}
return MovieLoadResponse(
@ -205,7 +211,7 @@ class PinoyMoviesEsProvider : MainAPI() {
): Boolean {
// parse movie servers
var count = 0
mapper.readValue<List<String>>(data).forEach { link ->
tryParseJson<List<String>>(data)?.forEach { link ->
//Log.i(this.name, "Result => (link) $link")
if (link.startsWith("https://vstreamhub.com")) {
VstreamhubHelper.getUrls(link, callback)
@ -225,4 +231,4 @@ class PinoyMoviesEsProvider : MainAPI() {
}
return count > 0
}
}
}

View file

@ -59,7 +59,7 @@ open class SflixProvider : MainAPI() {
map.forEach {
all.add(HomePageList(
it.key,
document.select(it.value).select("div.film-poster").map { element ->
document.select(it.value).select("div.flw-item").map { element ->
element.toSearchResult()
}
))
@ -67,7 +67,7 @@ open class SflixProvider : MainAPI() {
document.select("section.block_area.block_area_home.section-id-02").forEach {
val title = it.select("h2.cat-heading").text().trim()
val elements = it.select("div.film-poster").map { element ->
val elements = it.select("div.flw-item").map { element ->
element.toSearchResult()
}
all.add(HomePageList(title, elements))
@ -500,19 +500,39 @@ open class SflixProvider : MainAPI() {
}
private fun Element.toSearchResult(): SearchResponse {
val img = this.select("img")
val inner = this.selectFirst("div.film-poster")
val img = inner.select("img")
val title = img.attr("title")
val posterUrl = img.attr("data-src")
val href = fixUrl(this.select("a").attr("href"))
val posterUrl = img.attr("data-src") ?: img.attr("src")
val href = fixUrl(inner.select("a").attr("href"))
val isMovie = href.contains("/movie/")
val otherInfo = this.selectFirst("div.film-detail > div.fd-infor")?.select("span")?.toList() ?: listOf()
var rating: Int? = null
var year: Int? = null
var quality: SearchQuality? = null
when (otherInfo.size) {
1 -> {
year = otherInfo[0]?.text()?.trim()?.toIntOrNull()
}
2 -> {
year = otherInfo[0]?.text()?.trim()?.toIntOrNull()
}
3 -> {
rating = otherInfo[0]?.text()?.toRatingInt()
quality = getQualityFromString(otherInfo[1]?.text())
year = otherInfo[2]?.text()?.trim()?.toIntOrNull()
}
}
return if (isMovie) {
MovieSearchResponse(
title,
href,
this@SflixProvider.name,
TvType.Movie,
posterUrl,
null
posterUrl = posterUrl,
year = year,
quality = quality
)
} else {
TvSeriesSearchResponse(
@ -521,8 +541,9 @@ open class SflixProvider : MainAPI() {
this@SflixProvider.name,
TvType.Movie,
posterUrl,
null,
null
year = null,
episodes = year,
quality = quality
)
}
}

View file

@ -61,6 +61,9 @@ object SearchResultBuilder {
SearchQuality.SD -> R.string.quality_sd
SearchQuality.FourK -> R.string.quality_4k
SearchQuality.UHD -> R.string.quality_uhd
SearchQuality.SDR -> R.string.quality_sdr
SearchQuality.HDR -> R.string.quality_hdr
SearchQuality.WebRip -> R.string.quality_webrip
else -> null
}?.let { textRes ->
textQuality?.setText(textRes)

View file

@ -447,6 +447,9 @@
<string name="quality_4k">4K</string>
<string name="quality_sd">SD</string>
<string name="quality_uhd">UHD</string>
<string name="quality_hdr">HDR</string>
<string name="quality_sdr">SDR</string>
<string name="quality_webrip">Web</string>
<string name="poster_image">Poster Image</string>
</resources>