forked from recloudstream/cloudstream
		
	[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:
		
							parent
							
								
									c11a96a3e1
								
							
						
					
					
						commit
						a84468d726
					
				
					 5 changed files with 71 additions and 24 deletions
				
			
		|  | @ -554,11 +554,14 @@ enum class SearchQuality { | ||||||
|     Telecine, // TC |     Telecine, // TC | ||||||
|     HQ, |     HQ, | ||||||
|     HD, |     HD, | ||||||
|  |     HDR, // high dynamic range | ||||||
|     BlueRay, |     BlueRay, | ||||||
|     DVD, |     DVD, | ||||||
|     SD, |     SD, | ||||||
|     FourK, |     FourK, | ||||||
|     UHD, |     UHD, | ||||||
|  |     SDR, // standard dynamic range | ||||||
|  |     WebRip | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**Add anything to here if you find a site that uses some specific naming convention*/ | /**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) { |     return when(check) { | ||||||
|         "cam" -> SearchQuality.Cam |         "cam" -> SearchQuality.Cam | ||||||
|  |         "camrip" -> SearchQuality.CamRip | ||||||
|         "hdcam" -> SearchQuality.HdCam |         "hdcam" -> SearchQuality.HdCam | ||||||
|  |         "highquality" -> SearchQuality.HQ | ||||||
|         "hq" -> SearchQuality.HQ |         "hq" -> SearchQuality.HQ | ||||||
|  |         "highdefinition" -> SearchQuality.HD | ||||||
|         "hdrip" -> SearchQuality.HD |         "hdrip" -> SearchQuality.HD | ||||||
|         "hd" -> SearchQuality.HD |         "hd" -> SearchQuality.HD | ||||||
|         "camrip" -> SearchQuality.CamRip |  | ||||||
|         "rip" -> SearchQuality.CamRip |         "rip" -> SearchQuality.CamRip | ||||||
|  |         "telecine" -> SearchQuality.Telecine | ||||||
|         "tc" -> SearchQuality.Telecine |         "tc" -> SearchQuality.Telecine | ||||||
|  |         "telesync" -> SearchQuality.Telesync | ||||||
|         "ts" -> SearchQuality.Telesync |         "ts" -> SearchQuality.Telesync | ||||||
|         "dvd" -> SearchQuality.DVD |         "dvd" -> SearchQuality.DVD | ||||||
|         "blueray" ->  SearchQuality.BlueRay |         "blueray" ->  SearchQuality.BlueRay | ||||||
|  |         "bluray" -> SearchQuality.BlueRay | ||||||
|  |         "br" -> SearchQuality.BlueRay | ||||||
|  |         "standard" -> SearchQuality.SD | ||||||
|         "sd" -> SearchQuality.SD |         "sd" -> SearchQuality.SD | ||||||
|         "4k" -> SearchQuality.FourK |         "4k" -> SearchQuality.FourK | ||||||
|         "uhd" -> SearchQuality.UHD // may also be 4k or 8k |         "uhd" -> SearchQuality.UHD // may also be 4k or 8k | ||||||
|         "blue" -> SearchQuality.BlueRay |         "blue" -> SearchQuality.BlueRay | ||||||
|         "wp" -> SearchQuality.WorkPrint |         "wp" -> SearchQuality.WorkPrint | ||||||
|         "workprint" -> SearchQuality.WorkPrint |         "workprint" -> SearchQuality.WorkPrint | ||||||
|  |         "webrip" -> SearchQuality.WebRip | ||||||
|  |         "web" -> SearchQuality.WebRip | ||||||
|  |         "hdr" -> SearchQuality.HDR | ||||||
|  |         "sdr" -> SearchQuality.SDR | ||||||
|         else -> null |         else -> null | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,12 +1,13 @@ | ||||||
| package com.lagradost.cloudstream3.movieproviders | package com.lagradost.cloudstream3.movieproviders | ||||||
| 
 | 
 | ||||||
|  | import android.util.Log | ||||||
| import com.fasterxml.jackson.annotation.JsonProperty | import com.fasterxml.jackson.annotation.JsonProperty | ||||||
| import com.fasterxml.jackson.module.kotlin.readValue |  | ||||||
| import com.lagradost.cloudstream3.* | import com.lagradost.cloudstream3.* | ||||||
| import com.lagradost.cloudstream3.extractors.FEmbed | import com.lagradost.cloudstream3.extractors.FEmbed | ||||||
| import com.lagradost.cloudstream3.extractors.helper.VstreamhubHelper | import com.lagradost.cloudstream3.extractors.helper.VstreamhubHelper | ||||||
| import com.lagradost.cloudstream3.network.DdosGuardKiller | import com.lagradost.cloudstream3.network.DdosGuardKiller | ||||||
| import com.lagradost.cloudstream3.utils.AppUtils.toJson | 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.ExtractorLink | ||||||
| import com.lagradost.cloudstream3.utils.loadExtractor | import com.lagradost.cloudstream3.utils.loadExtractor | ||||||
| import org.jsoup.select.Elements | import org.jsoup.select.Elements | ||||||
|  | @ -55,6 +56,8 @@ class PinoyMoviesEsProvider : MainAPI() { | ||||||
|                     val rex = Regex("\\((\\d+)") |                     val rex = Regex("\\((\\d+)") | ||||||
|                     year = rex.find(name)?.value?.replace("(", "")?.toIntOrNull() |                     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( |                 MovieSearchResponse( | ||||||
|                     name = name, |                     name = name, | ||||||
|  | @ -62,7 +65,8 @@ class PinoyMoviesEsProvider : MainAPI() { | ||||||
|                     apiName = this.name, |                     apiName = this.name, | ||||||
|                     type = TvType.Movie, |                     type = TvType.Movie, | ||||||
|                     posterUrl = image, |                     posterUrl = image, | ||||||
|                     year = year |                     year = year, | ||||||
|  |                     quality = searchQual | ||||||
|                 ) |                 ) | ||||||
|             }?.distinctBy { c -> c.url } ?: listOf() |             }?.distinctBy { c -> c.url } ?: listOf() | ||||||
|             //Add to list of homepages |             //Add to list of homepages | ||||||
|  | @ -116,14 +120,16 @@ class PinoyMoviesEsProvider : MainAPI() { | ||||||
|             val title = urlTitle.text()?.trim() ?: "<No Title>" |             val title = urlTitle.text()?.trim() ?: "<No Title>" | ||||||
|             val year = urlTitle.select("span.year")?.text()?.toIntOrNull() |             val year = urlTitle.select("span.year")?.text()?.toIntOrNull() | ||||||
|             val image = it.select("div.poster > img")?.attr("src") |             val image = it.select("div.poster > img")?.attr("src") | ||||||
|  |             val searchQual = getQualityFromString(it.selectFirst("span.quality")?.text()) | ||||||
| 
 | 
 | ||||||
|             MovieSearchResponse( |             MovieSearchResponse( | ||||||
|                 title, |                 name = title, | ||||||
|                 link, |                 url = link, | ||||||
|                 this.name, |                 apiName = this.name, | ||||||
|                 TvType.Movie, |                 type = TvType.Movie, | ||||||
|                 image, |                 posterUrl = image, | ||||||
|                 year |                 year = year, | ||||||
|  |                 quality = searchQual | ||||||
|             ) |             ) | ||||||
|         }?.distinctBy { it.url } ?: listOf() |         }?.distinctBy { it.url } ?: listOf() | ||||||
|     } |     } | ||||||
|  | @ -177,10 +183,10 @@ class PinoyMoviesEsProvider : MainAPI() { | ||||||
|             ) |             ) | ||||||
|             val innerPage = app.post("https://pinoymovies.es/wp-admin/admin-ajax.php ", |             val innerPage = app.post("https://pinoymovies.es/wp-admin/admin-ajax.php ", | ||||||
|                 referer = url, data = content).document.select("body")?.text()?.trim() |                 referer = url, data = content).document.select("body")?.text()?.trim() | ||||||
|             if (!innerPage.isNullOrEmpty()) { |             if (!innerPage.isNullOrBlank()) { | ||||||
|                 val embedData = mapper.readValue<EmbedUrl>(innerPage) |                 tryParseJson<EmbedUrl>(innerPage)?.let { | ||||||
|                 //Log.i(this.name, "Result => (embed_url) ${embedData.embed_url}") |                     listOfLinks.add(it.embed_url) | ||||||
|                 listOfLinks.add(embedData.embed_url) |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         return MovieLoadResponse( |         return MovieLoadResponse( | ||||||
|  | @ -205,7 +211,7 @@ class PinoyMoviesEsProvider : MainAPI() { | ||||||
|     ): Boolean { |     ): Boolean { | ||||||
|         // parse movie servers |         // parse movie servers | ||||||
|         var count = 0 |         var count = 0 | ||||||
|         mapper.readValue<List<String>>(data).forEach { link -> |         tryParseJson<List<String>>(data)?.forEach { link -> | ||||||
|             //Log.i(this.name, "Result => (link) $link") |             //Log.i(this.name, "Result => (link) $link") | ||||||
|             if (link.startsWith("https://vstreamhub.com")) { |             if (link.startsWith("https://vstreamhub.com")) { | ||||||
|                 VstreamhubHelper.getUrls(link, callback) |                 VstreamhubHelper.getUrls(link, callback) | ||||||
|  | @ -225,4 +231,4 @@ class PinoyMoviesEsProvider : MainAPI() { | ||||||
|         } |         } | ||||||
|         return count > 0 |         return count > 0 | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -59,7 +59,7 @@ open class SflixProvider : MainAPI() { | ||||||
|         map.forEach { |         map.forEach { | ||||||
|             all.add(HomePageList( |             all.add(HomePageList( | ||||||
|                 it.key, |                 it.key, | ||||||
|                 document.select(it.value).select("div.film-poster").map { element -> |                 document.select(it.value).select("div.flw-item").map { element -> | ||||||
|                     element.toSearchResult() |                     element.toSearchResult() | ||||||
|                 } |                 } | ||||||
|             )) |             )) | ||||||
|  | @ -67,7 +67,7 @@ open class SflixProvider : MainAPI() { | ||||||
| 
 | 
 | ||||||
|         document.select("section.block_area.block_area_home.section-id-02").forEach { |         document.select("section.block_area.block_area_home.section-id-02").forEach { | ||||||
|             val title = it.select("h2.cat-heading").text().trim() |             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() |                 element.toSearchResult() | ||||||
|             } |             } | ||||||
|             all.add(HomePageList(title, elements)) |             all.add(HomePageList(title, elements)) | ||||||
|  | @ -500,19 +500,39 @@ open class SflixProvider : MainAPI() { | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private fun Element.toSearchResult(): SearchResponse { |     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 title = img.attr("title") | ||||||
|         val posterUrl = img.attr("data-src") |         val posterUrl = img.attr("data-src") ?: img.attr("src") | ||||||
|         val href = fixUrl(this.select("a").attr("href")) |         val href = fixUrl(inner.select("a").attr("href")) | ||||||
|         val isMovie = href.contains("/movie/") |         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) { |         return if (isMovie) { | ||||||
|             MovieSearchResponse( |             MovieSearchResponse( | ||||||
|                 title, |                 title, | ||||||
|                 href, |                 href, | ||||||
|                 this@SflixProvider.name, |                 this@SflixProvider.name, | ||||||
|                 TvType.Movie, |                 TvType.Movie, | ||||||
|                 posterUrl, |                 posterUrl = posterUrl, | ||||||
|                 null |                 year = year, | ||||||
|  |                 quality = quality | ||||||
|             ) |             ) | ||||||
|         } else { |         } else { | ||||||
|             TvSeriesSearchResponse( |             TvSeriesSearchResponse( | ||||||
|  | @ -521,8 +541,9 @@ open class SflixProvider : MainAPI() { | ||||||
|                 this@SflixProvider.name, |                 this@SflixProvider.name, | ||||||
|                 TvType.Movie, |                 TvType.Movie, | ||||||
|                 posterUrl, |                 posterUrl, | ||||||
|                 null, |                 year = null, | ||||||
|                 null |                 episodes = year, | ||||||
|  |                 quality = quality | ||||||
|             ) |             ) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -61,6 +61,9 @@ object SearchResultBuilder { | ||||||
|             SearchQuality.SD -> R.string.quality_sd |             SearchQuality.SD -> R.string.quality_sd | ||||||
|             SearchQuality.FourK -> R.string.quality_4k |             SearchQuality.FourK -> R.string.quality_4k | ||||||
|             SearchQuality.UHD -> R.string.quality_uhd |             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 |             else -> null | ||||||
|         }?.let { textRes -> |         }?.let { textRes -> | ||||||
|             textQuality?.setText(textRes) |             textQuality?.setText(textRes) | ||||||
|  |  | ||||||
|  | @ -447,6 +447,9 @@ | ||||||
|     <string name="quality_4k">4K</string> |     <string name="quality_4k">4K</string> | ||||||
|     <string name="quality_sd">SD</string> |     <string name="quality_sd">SD</string> | ||||||
|     <string name="quality_uhd">UHD</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> |     <string name="poster_image">Poster Image</string> | ||||||
| </resources> | </resources> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue