From a84468d7263afe4f8b0171c34c7c4341d03dc397 Mon Sep 17 00:00:00 2001 From: Jace <54625750+Jacekun@users.noreply.github.com> Date: Fri, 1 Apr 2022 22:27:46 +0800 Subject: [PATCH] [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. --- .../com/lagradost/cloudstream3/MainAPI.kt | 16 +++++++- .../movieproviders/PinoyMoviesEsProvider.kt | 34 +++++++++------- .../movieproviders/SflixProvider.kt | 39 ++++++++++++++----- .../ui/search/SearchResultBuilder.kt | 3 ++ app/src/main/res/values/strings.xml | 3 ++ 5 files changed, 71 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt b/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt index b3125e64..5e075016 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt @@ -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 } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviesEsProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviesEsProvider.kt index 874c5504..b975255b 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviesEsProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/PinoyMoviesEsProvider.kt @@ -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() ?: "" 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(innerPage) - //Log.i(this.name, "Result => (embed_url) ${embedData.embed_url}") - listOfLinks.add(embedData.embed_url) + if (!innerPage.isNullOrBlank()) { + tryParseJson(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>(data).forEach { link -> + tryParseJson>(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 } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SflixProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SflixProvider.kt index 98433478..3c1bc673 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SflixProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/SflixProvider.kt @@ -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 ) } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchResultBuilder.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchResultBuilder.kt index 78abb867..a2a74b54 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchResultBuilder.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchResultBuilder.kt @@ -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) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bf88d643..5bb5320c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -447,6 +447,9 @@ 4K SD UHD + HDR + SDR + Web Poster Image