mirror of
				https://github.com/recloudstream/cloudstream.git
				synced 2024-08-15 01:53:11 +00:00 
			
		
		
		
	mainApi changes
This commit is contained in:
		
							parent
							
								
									641025fa2d
								
							
						
					
					
						commit
						f4d160f997
					
				
					 13 changed files with 94 additions and 65 deletions
				
			
		|  | @ -698,25 +698,25 @@ data class TvSeriesSearchResponse( | ||||||
| ) : SearchResponse | ) : SearchResponse | ||||||
| 
 | 
 | ||||||
| interface LoadResponse { | interface LoadResponse { | ||||||
|     val name: String |     var name: String | ||||||
|     val url: String |     var url: String | ||||||
|     val apiName: String |     var apiName: String | ||||||
|     val type: TvType |     var type: TvType | ||||||
|     var posterUrl: String? |     var posterUrl: String? | ||||||
|     val year: Int? |     var year: Int? | ||||||
|     var plot: String? |     var plot: String? | ||||||
|     var rating: Int? // 1-1000 |     var rating: Int? // 1-1000 | ||||||
|     var tags: List<String>? |     var tags: List<String>? | ||||||
|     var duration: Int? // in minutes |     var duration: Int? // in minutes | ||||||
|     var trailerUrl: String? |     var trailers: List<String>? | ||||||
|     var recommendations: List<SearchResponse>? |     var recommendations: List<SearchResponse>? | ||||||
|     var actors: List<ActorData>? |     var actors: List<ActorData>? | ||||||
|     var comingSoon: Boolean |     var comingSoon: Boolean | ||||||
|     var syncData: MutableMap<String, String> |     var syncData: MutableMap<String, String> | ||||||
| 
 | 
 | ||||||
|     companion object { |     companion object { | ||||||
|         val malIdPrefix = malApi.idPrefix |         private val malIdPrefix = malApi.idPrefix | ||||||
|         val aniListIdPrefix = aniListApi.idPrefix |         private val aniListIdPrefix = aniListApi.idPrefix | ||||||
| 
 | 
 | ||||||
|         @JvmName("addActorNames") |         @JvmName("addActorNames") | ||||||
|         fun LoadResponse.addActors(actors: List<String>?) { |         fun LoadResponse.addActors(actors: List<String>?) { | ||||||
|  | @ -750,6 +750,18 @@ interface LoadResponse { | ||||||
|             addImdbId(imdbUrlToIdNullable(url)) |             addImdbId(imdbUrlToIdNullable(url)) | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         /**better to set trailers directly instead of calling this multiple times*/ | ||||||
|  |         fun LoadResponse.addTrailer(trailerUrl: String?) { | ||||||
|  |             if (trailerUrl == null) return | ||||||
|  |             if (this.trailers == null) { | ||||||
|  |                 this.trailers = listOf(trailerUrl) | ||||||
|  |             } else { | ||||||
|  |                 val update = this.trailers?.toMutableList() | ||||||
|  |                 update?.add(trailerUrl) | ||||||
|  |                 this.trailers = update | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         fun LoadResponse.addImdbId(id: String?) { |         fun LoadResponse.addImdbId(id: String?) { | ||||||
|             // TODO add imdb sync |             // TODO add imdb sync | ||||||
|         } |         } | ||||||
|  | @ -763,10 +775,21 @@ interface LoadResponse { | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         fun LoadResponse.addTMDbId(id: String?) { |         fun LoadResponse.addTMDbId(id: String?) { | ||||||
| 
 |             // TODO add TMDb sync | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         fun LoadResponse.setDuration(input: String?) { |         fun LoadResponse.addRating(text: String?) { | ||||||
|  |             addRating(text.toRatingInt()) | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         fun LoadResponse.addRating(value: Int?) { | ||||||
|  |             if (value ?: return < 0 || value > 1000) { | ||||||
|  |                 return | ||||||
|  |             } | ||||||
|  |             this.rating = value | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         fun LoadResponse.addDuration(input: String?) { | ||||||
|             val cleanInput = input?.trim()?.replace(" ", "") ?: return |             val cleanInput = input?.trim()?.replace(" ", "") ?: return | ||||||
|             Regex("([0-9]*)h.*?([0-9]*)m").find(cleanInput)?.groupValues?.let { values -> |             Regex("([0-9]*)h.*?([0-9]*)m").find(cleanInput)?.groupValues?.let { values -> | ||||||
|                 if (values.size == 3) { |                 if (values.size == 3) { | ||||||
|  | @ -816,7 +839,7 @@ data class TorrentLoadResponse( | ||||||
|     override var rating: Int? = null, |     override var rating: Int? = null, | ||||||
|     override var tags: List<String>? = null, |     override var tags: List<String>? = null, | ||||||
|     override var duration: Int? = null, |     override var duration: Int? = null, | ||||||
|     override var trailerUrl: String? = null, |     override var trailers: List<String>? = null, | ||||||
|     override var recommendations: List<SearchResponse>? = null, |     override var recommendations: List<SearchResponse>? = null, | ||||||
|     override var actors: List<ActorData>? = null, |     override var actors: List<ActorData>? = null, | ||||||
|     override var comingSoon: Boolean = false, |     override var comingSoon: Boolean = false, | ||||||
|  | @ -843,7 +866,7 @@ data class AnimeLoadResponse( | ||||||
| 
 | 
 | ||||||
|     override var rating: Int? = null, |     override var rating: Int? = null, | ||||||
|     override var duration: Int? = null, |     override var duration: Int? = null, | ||||||
|     override var trailerUrl: String? = null, |     override var trailers: List<String>? = null, | ||||||
|     override var recommendations: List<SearchResponse>? = null, |     override var recommendations: List<SearchResponse>? = null, | ||||||
|     override var actors: List<ActorData>? = null, |     override var actors: List<ActorData>? = null, | ||||||
|     override var comingSoon: Boolean = false, |     override var comingSoon: Boolean = false, | ||||||
|  | @ -898,7 +921,7 @@ data class MovieLoadResponse( | ||||||
|     override var rating: Int? = null, |     override var rating: Int? = null, | ||||||
|     override var tags: List<String>? = null, |     override var tags: List<String>? = null, | ||||||
|     override var duration: Int? = null, |     override var duration: Int? = null, | ||||||
|     override var trailerUrl: String? = null, |     override var trailers: List<String>? = null, | ||||||
|     override var recommendations: List<SearchResponse>? = null, |     override var recommendations: List<SearchResponse>? = null, | ||||||
|     override var actors: List<ActorData>? = null, |     override var actors: List<ActorData>? = null, | ||||||
|     override var comingSoon: Boolean = false, |     override var comingSoon: Boolean = false, | ||||||
|  | @ -912,6 +935,14 @@ fun <T> MainAPI.newMovieLoadResponse( | ||||||
|     data: T?, |     data: T?, | ||||||
|     initializer: MovieLoadResponse.() -> Unit = { } |     initializer: MovieLoadResponse.() -> Unit = { } | ||||||
| ): MovieLoadResponse { | ): MovieLoadResponse { | ||||||
|  |     // just in case | ||||||
|  |     if (data is String) return newMovieLoadResponse( | ||||||
|  |         name, | ||||||
|  |         url, | ||||||
|  |         type, | ||||||
|  |         dataUrl = data, | ||||||
|  |         initializer = initializer | ||||||
|  |     ) | ||||||
|     val dataUrl = data?.toJson() ?: "" |     val dataUrl = data?.toJson() ?: "" | ||||||
|     val builder = MovieLoadResponse( |     val builder = MovieLoadResponse( | ||||||
|         name = name, |         name = name, | ||||||
|  | @ -955,9 +986,9 @@ data class Episode( | ||||||
|     var date: Long? = null, |     var date: Long? = null, | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| fun Episode.addDate(date: String?, fomat: String = "yyyy-MM-dd") { | fun Episode.addDate(date: String?, format: String = "yyyy-MM-dd") { | ||||||
|     try { |     try { | ||||||
|         this.date = SimpleDateFormat(fomat)?.parse(date ?: return)?.time |         this.date = SimpleDateFormat(format)?.parse(date ?: return)?.time | ||||||
|     } catch (e: Exception) { |     } catch (e: Exception) { | ||||||
|         logError(e) |         logError(e) | ||||||
|     } |     } | ||||||
|  | @ -967,7 +998,7 @@ fun Episode.addDate(date: Date?) { | ||||||
|     this.date = date?.time |     this.date = date?.time | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| fun <T> MainAPI.newEpisode( | fun MainAPI.newEpisode( | ||||||
|     url: String, |     url: String, | ||||||
|     initializer: Episode.() -> Unit = { }, |     initializer: Episode.() -> Unit = { }, | ||||||
|     fix: Boolean = true, |     fix: Boolean = true, | ||||||
|  | @ -983,6 +1014,11 @@ fun <T> MainAPI.newEpisode( | ||||||
|     data: T, |     data: T, | ||||||
|     initializer: Episode.() -> Unit = { } |     initializer: Episode.() -> Unit = { } | ||||||
| ): Episode { | ): Episode { | ||||||
|  |     if (data is String) return newEpisode( | ||||||
|  |         url = data, | ||||||
|  |         initializer = initializer | ||||||
|  |     ) // just in case java is wack | ||||||
|  | 
 | ||||||
|     val builder = Episode( |     val builder = Episode( | ||||||
|         data = data?.toJson() ?: throw ErrorLoadingException("invalid newEpisode") |         data = data?.toJson() ?: throw ErrorLoadingException("invalid newEpisode") | ||||||
|     ) |     ) | ||||||
|  | @ -1005,7 +1041,7 @@ data class TvSeriesLoadResponse( | ||||||
|     override var rating: Int? = null, |     override var rating: Int? = null, | ||||||
|     override var tags: List<String>? = null, |     override var tags: List<String>? = null, | ||||||
|     override var duration: Int? = null, |     override var duration: Int? = null, | ||||||
|     override var trailerUrl: String? = null, |     override var trailers: List<String>? = null, | ||||||
|     override var recommendations: List<SearchResponse>? = null, |     override var recommendations: List<SearchResponse>? = null, | ||||||
|     override var actors: List<ActorData>? = null, |     override var actors: List<ActorData>? = null, | ||||||
|     override var comingSoon: Boolean = false, |     override var comingSoon: Boolean = false, | ||||||
|  | @ -1041,4 +1077,4 @@ fun fetchUrls(text: String?): List<String> { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| fun String?.toRatingInt(): Int? = | fun String?.toRatingInt(): Int? = | ||||||
|     this?.trim()?.toDoubleOrNull()?.absoluteValue?.times(1000f)?.toInt() |     this?.replace(" ", "")?.trim()?.toDoubleOrNull()?.absoluteValue?.times(1000f)?.toInt() | ||||||
|  |  | ||||||
|  | @ -5,6 +5,7 @@ import com.fasterxml.jackson.module.kotlin.readValue | ||||||
| import com.lagradost.cloudstream3.* | import com.lagradost.cloudstream3.* | ||||||
| import com.lagradost.cloudstream3.LoadResponse.Companion.addAniListId | import com.lagradost.cloudstream3.LoadResponse.Companion.addAniListId | ||||||
| import com.lagradost.cloudstream3.LoadResponse.Companion.addMalId | import com.lagradost.cloudstream3.LoadResponse.Companion.addMalId | ||||||
|  | import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer | ||||||
| import com.lagradost.cloudstream3.mvvm.suspendSafeApiCall | import com.lagradost.cloudstream3.mvvm.suspendSafeApiCall | ||||||
| import com.lagradost.cloudstream3.network.AppResponse | import com.lagradost.cloudstream3.network.AppResponse | ||||||
| import com.lagradost.cloudstream3.utils.ExtractorLink | import com.lagradost.cloudstream3.utils.ExtractorLink | ||||||
|  | @ -306,7 +307,7 @@ class AnimePaheProvider : MainAPI() { | ||||||
| 
 | 
 | ||||||
|                 addMalId(malId) |                 addMalId(malId) | ||||||
|                 addAniListId(anilistId) |                 addAniListId(anilistId) | ||||||
|                 this.trailerUrl = trailer |                 addTrailer(trailer) | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -3,6 +3,8 @@ package com.lagradost.cloudstream3.animeproviders | ||||||
| import com.lagradost.cloudstream3.* | import com.lagradost.cloudstream3.* | ||||||
| import com.lagradost.cloudstream3.LoadResponse.Companion.addAniListId | import com.lagradost.cloudstream3.LoadResponse.Companion.addAniListId | ||||||
| import com.lagradost.cloudstream3.LoadResponse.Companion.addMalId | import com.lagradost.cloudstream3.LoadResponse.Companion.addMalId | ||||||
|  | import com.lagradost.cloudstream3.LoadResponse.Companion.addRating | ||||||
|  | import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer | ||||||
| import com.lagradost.cloudstream3.utils.ExtractorLink | import com.lagradost.cloudstream3.utils.ExtractorLink | ||||||
| import com.lagradost.cloudstream3.utils.Qualities | import com.lagradost.cloudstream3.utils.Qualities | ||||||
| import org.json.JSONObject | import org.json.JSONObject | ||||||
|  | @ -123,7 +125,7 @@ class AnimeWorldProvider : MainAPI() { | ||||||
| 
 | 
 | ||||||
|         val type: TvType = getType(widget.select("dd").first()?.text()) |         val type: TvType = getType(widget.select("dd").first()?.text()) | ||||||
|         val genres = widget.select(".meta").select("a[href*=\"/genre/\"]").map { it.text() } |         val genres = widget.select(".meta").select("a[href*=\"/genre/\"]").map { it.text() } | ||||||
|         val rating: Int? = widget.select("#average-vote").text().toFloatOrNull()?.times(1000)?.toInt() |         val rating = widget.select("#average-vote")?.text() | ||||||
| 
 | 
 | ||||||
|         val trailerUrl = document.select(".trailer[data-url]").attr("data-url") |         val trailerUrl = document.select(".trailer[data-url]").attr("data-url") | ||||||
|         val malId = document.select("#mal-button").attr("href") |         val malId = document.select("#mal-button").attr("href") | ||||||
|  | @ -174,9 +176,9 @@ class AnimeWorldProvider : MainAPI() { | ||||||
|             tags = genres |             tags = genres | ||||||
|             addMalId(malId) |             addMalId(malId) | ||||||
|             addAniListId(anlId) |             addAniListId(anlId) | ||||||
|             this.rating = rating |             addRating(rating) | ||||||
|             this.duration = duration |             this.duration = duration | ||||||
|             this.trailerUrl = trailerUrl |             addTrailer(trailerUrl) | ||||||
|             this.recommendations = recommendations |             this.recommendations = recommendations | ||||||
|             this.comingSoon = comingSoon |             this.comingSoon = comingSoon | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ package com.lagradost.cloudstream3.metaproviders | ||||||
| 
 | 
 | ||||||
| import com.lagradost.cloudstream3.* | import com.lagradost.cloudstream3.* | ||||||
| import com.lagradost.cloudstream3.LoadResponse.Companion.addAniListId | import com.lagradost.cloudstream3.LoadResponse.Companion.addAniListId | ||||||
|  | import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer | ||||||
| import com.lagradost.cloudstream3.syncproviders.OAuth2API | import com.lagradost.cloudstream3.syncproviders.OAuth2API | ||||||
| 
 | 
 | ||||||
| class MultiAnimeProvider : MainAPI() { | class MultiAnimeProvider : MainAPI() { | ||||||
|  | @ -36,7 +37,7 @@ class MultiAnimeProvider : MainAPI() { | ||||||
|                 plot = res.synopsis |                 plot = res.synopsis | ||||||
|                 tags = res.genres |                 tags = res.genres | ||||||
|                 rating = res.publicScore |                 rating = res.publicScore | ||||||
|                 trailerUrl = res.trailerUrl |                 addTrailer(res.trailerUrl) | ||||||
|                 addAniListId(res.id.toIntOrNull()) |                 addAniListId(res.id.toIntOrNull()) | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | @ -97,9 +97,7 @@ class AkwamProvider : MainAPI() { | ||||||
| 
 | 
 | ||||||
|         val synopsis = doc.select("div.widget-body p:first-child").text() |         val synopsis = doc.select("div.widget-body p:first-child").text() | ||||||
| 
 | 
 | ||||||
|         val rating = doc.select("span.mx-2").text().split("/").lastOrNull()?.replace(" ", "") |         val rating = doc.select("span.mx-2").text().split("/").lastOrNull()?.toRatingInt() | ||||||
|             ?.toDoubleOrNull() |  | ||||||
|             ?.times(1000)?.toInt() |  | ||||||
| 
 | 
 | ||||||
|         val tags = doc.select("div.font-size-16.d-flex.align-items-center.mt-3 > a").map { |         val tags = doc.select("div.font-size-16.d-flex.align-items-center.mt-3 > a").map { | ||||||
|             it.text() |             it.text() | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| package com.lagradost.cloudstream3.movieproviders | package com.lagradost.cloudstream3.movieproviders | ||||||
| 
 | 
 | ||||||
| import com.lagradost.cloudstream3.* | import com.lagradost.cloudstream3.* | ||||||
| import com.lagradost.cloudstream3.LoadResponse.Companion.setDuration | import com.lagradost.cloudstream3.LoadResponse.Companion.addDuration | ||||||
| import com.lagradost.cloudstream3.mvvm.logError | import com.lagradost.cloudstream3.mvvm.logError | ||||||
| import com.lagradost.cloudstream3.utils.ExtractorLink | import com.lagradost.cloudstream3.utils.ExtractorLink | ||||||
| import com.lagradost.cloudstream3.utils.loadExtractor | import com.lagradost.cloudstream3.utils.loadExtractor | ||||||
|  | @ -111,8 +111,7 @@ class AllMoviesForYouProvider : MainAPI() { | ||||||
|         val title = document.selectFirst("h1.Title").text() |         val title = document.selectFirst("h1.Title").text() | ||||||
|         val descipt = document.selectFirst("div.Description > p").text() |         val descipt = document.selectFirst("div.Description > p").text() | ||||||
|         val rating = |         val rating = | ||||||
|             document.selectFirst("div.Vote > div.post-ratings > span")?.text()?.toFloatOrNull() |             document.selectFirst("div.Vote > div.post-ratings > span")?.text()?.toRatingInt() | ||||||
|                 ?.times(1000)?.toInt() |  | ||||||
|         val year = document.selectFirst("span.Date")?.text() |         val year = document.selectFirst("span.Date")?.text() | ||||||
|         val duration = document.selectFirst("span.Time").text() |         val duration = document.selectFirst("span.Time").text() | ||||||
|         val backgroundPoster = |         val backgroundPoster = | ||||||
|  | @ -180,7 +179,7 @@ class AllMoviesForYouProvider : MainAPI() { | ||||||
|                 this.year = year?.toIntOrNull() |                 this.year = year?.toIntOrNull() | ||||||
|                 this.plot = descipt |                 this.plot = descipt | ||||||
|                 this.rating = rating |                 this.rating = rating | ||||||
|                 setDuration(duration) |                 addDuration(duration) | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -265,8 +265,7 @@ open class BflixProvider() : MainAPI() { | ||||||
|                         year = null |                         year = null | ||||||
|                     ) |                     ) | ||||||
|                 } |                 } | ||||||
|         val rating = soup.selectFirst(".info span.imdb").text().toFloatOrNull() |         val rating = soup.selectFirst(".info span.imdb")?.text()?.toRatingInt() | ||||||
|             ?.times(1000)?.toInt() |  | ||||||
|         val durationdoc = soup.selectFirst("div.info div.meta").toString() |         val durationdoc = soup.selectFirst("div.info div.meta").toString() | ||||||
|         val durationregex = Regex("((\\d+) min)") |         val durationregex = Regex("((\\d+) min)") | ||||||
|         val yearegex = Regex("<span>(\\d+)<\\/span>") |         val yearegex = Regex("<span>(\\d+)<\\/span>") | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| package com.lagradost.cloudstream3.movieproviders | package com.lagradost.cloudstream3.movieproviders | ||||||
| 
 | 
 | ||||||
| import com.lagradost.cloudstream3.* | import com.lagradost.cloudstream3.* | ||||||
| import com.lagradost.cloudstream3.LoadResponse.Companion.setDuration | import com.lagradost.cloudstream3.LoadResponse.Companion.addDuration | ||||||
| import com.lagradost.cloudstream3.mvvm.logError | import com.lagradost.cloudstream3.mvvm.logError | ||||||
| import com.lagradost.cloudstream3.utils.ExtractorLink | import com.lagradost.cloudstream3.utils.ExtractorLink | ||||||
| import com.lagradost.cloudstream3.utils.loadExtractor | import com.lagradost.cloudstream3.utils.loadExtractor | ||||||
|  | @ -175,7 +175,7 @@ class PelisflixProvider : MainAPI() { | ||||||
|                 this.year = year?.toIntOrNull() |                 this.year = year?.toIntOrNull() | ||||||
|                 this.plot = descipt |                 this.plot = descipt | ||||||
|                 this.rating = rating |                 this.rating = rating | ||||||
|                 setDuration(duration) |                 addDuration(duration) | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| package com.lagradost.cloudstream3.movieproviders | package com.lagradost.cloudstream3.movieproviders | ||||||
| 
 | 
 | ||||||
| import com.lagradost.cloudstream3.* | import com.lagradost.cloudstream3.* | ||||||
| import com.lagradost.cloudstream3.LoadResponse.Companion.setDuration | import com.lagradost.cloudstream3.LoadResponse.Companion.addDuration | ||||||
| import com.lagradost.cloudstream3.mvvm.logError | import com.lagradost.cloudstream3.mvvm.logError | ||||||
| import com.lagradost.cloudstream3.utils.ExtractorLink | import com.lagradost.cloudstream3.utils.ExtractorLink | ||||||
| import com.lagradost.cloudstream3.utils.loadExtractor | import com.lagradost.cloudstream3.utils.loadExtractor | ||||||
|  | @ -92,8 +92,7 @@ class SeriesflixProvider : MainAPI() { | ||||||
|         val descRegex = Regex("(Recuerda.*Seriesflix.)") |         val descRegex = Regex("(Recuerda.*Seriesflix.)") | ||||||
|         val descipt = document.selectFirst("div.Description > p").text().replace(descRegex, "") |         val descipt = document.selectFirst("div.Description > p").text().replace(descRegex, "") | ||||||
|         val rating = |         val rating = | ||||||
|             document.selectFirst("div.Vote > div.post-ratings > span")?.text()?.toFloatOrNull() |             document.selectFirst("div.Vote > div.post-ratings > span")?.text()?.toRatingInt() | ||||||
|                 ?.times(1000)?.toInt() |  | ||||||
|         val year = document.selectFirst("span.Date")?.text() |         val year = document.selectFirst("span.Date")?.text() | ||||||
|         // ?: does not work |         // ?: does not work | ||||||
|         val duration = try { |         val duration = try { | ||||||
|  | @ -172,7 +171,7 @@ class SeriesflixProvider : MainAPI() { | ||||||
|                 this.year = year?.toIntOrNull() |                 this.year = year?.toIntOrNull() | ||||||
|                 this.plot = descipt |                 this.plot = descipt | ||||||
|                 this.rating = rating |                 this.rating = rating | ||||||
|                 setDuration(duration) |                 addDuration(duration) | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -6,7 +6,8 @@ import com.lagradost.cloudstream3.* | ||||||
| import com.lagradost.cloudstream3.APIHolder.getCaptchaToken | import com.lagradost.cloudstream3.APIHolder.getCaptchaToken | ||||||
| import com.lagradost.cloudstream3.APIHolder.unixTimeMS | import com.lagradost.cloudstream3.APIHolder.unixTimeMS | ||||||
| import com.lagradost.cloudstream3.LoadResponse.Companion.addActors | import com.lagradost.cloudstream3.LoadResponse.Companion.addActors | ||||||
| import com.lagradost.cloudstream3.LoadResponse.Companion.setDuration | import com.lagradost.cloudstream3.LoadResponse.Companion.addDuration | ||||||
|  | import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer | ||||||
| import com.lagradost.cloudstream3.animeproviders.ZoroProvider | import com.lagradost.cloudstream3.animeproviders.ZoroProvider | ||||||
| import com.lagradost.cloudstream3.mvvm.suspendSafeApiCall | import com.lagradost.cloudstream3.mvvm.suspendSafeApiCall | ||||||
| import com.lagradost.cloudstream3.network.AppResponse | import com.lagradost.cloudstream3.network.AppResponse | ||||||
|  | @ -217,12 +218,12 @@ open class SflixProvider : MainAPI() { | ||||||
|                 this.year = year |                 this.year = year | ||||||
|                 this.posterUrl = posterUrl |                 this.posterUrl = posterUrl | ||||||
|                 this.plot = plot |                 this.plot = plot | ||||||
|                 setDuration(duration) |                 addDuration(duration) | ||||||
|                 addActors(cast) |                 addActors(cast) | ||||||
|                 this.tags = tags |                 this.tags = tags | ||||||
|                 this.recommendations = recommendations |                 this.recommendations = recommendations | ||||||
|                 this.comingSoon = comingSoon |                 this.comingSoon = comingSoon | ||||||
|                 this.trailerUrl = youtubeTrailer |                 addTrailer(youtubeTrailer) | ||||||
|                 this.rating = rating |                 this.rating = rating | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|  | @ -273,11 +274,11 @@ open class SflixProvider : MainAPI() { | ||||||
|                 this.posterUrl = posterUrl |                 this.posterUrl = posterUrl | ||||||
|                 this.year = year |                 this.year = year | ||||||
|                 this.plot = plot |                 this.plot = plot | ||||||
|                 setDuration(duration) |                 addDuration(duration) | ||||||
|                 addActors(cast) |                 addActors(cast) | ||||||
|                 this.tags = tags |                 this.tags = tags | ||||||
|                 this.recommendations = recommendations |                 this.recommendations = recommendations | ||||||
|                 this.trailerUrl = youtubeTrailer |                 addTrailer(youtubeTrailer) | ||||||
|                 this.rating = rating |                 this.rating = rating | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | @ -1,6 +1,8 @@ | ||||||
| package com.lagradost.cloudstream3.movieproviders | package com.lagradost.cloudstream3.movieproviders | ||||||
| 
 | 
 | ||||||
| import com.lagradost.cloudstream3.* | import com.lagradost.cloudstream3.* | ||||||
|  | import com.lagradost.cloudstream3.LoadResponse.Companion.addRating | ||||||
|  | import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer | ||||||
| import com.lagradost.cloudstream3.utils.ExtractorLink | import com.lagradost.cloudstream3.utils.ExtractorLink | ||||||
| import com.lagradost.cloudstream3.utils.extractorApis | import com.lagradost.cloudstream3.utils.extractorApis | ||||||
| 
 | 
 | ||||||
|  | @ -61,33 +63,24 @@ class FrenchStreamProvider : MainAPI() { | ||||||
|         val listEpisode = soup.select("div.elink") |         val listEpisode = soup.select("div.elink") | ||||||
| 
 | 
 | ||||||
|         if (isMovie) { |         if (isMovie) { | ||||||
|             val trailer = soup.selectFirst("div.fleft > span > a")?.attr("href") |  | ||||||
|             val date = soup.select("ul.flist-col > li")?.getOrNull(2)?.text()?.toIntOrNull() |  | ||||||
|             val ratingAverage = soup.select("div.fr-count > div")?.text()?.toIntOrNull() |  | ||||||
|             val tags = soup.select("ul.flist-col > li")?.getOrNull(1) |             val tags = soup.select("ul.flist-col > li")?.getOrNull(1) | ||||||
|             val tagsList = tags?.select("a") |             val tagsList = tags?.select("a") | ||||||
|                 ?.mapNotNull {   // all the tags like action, thriller ...; unused variable |                 ?.mapNotNull {   // all the tags like action, thriller ...; unused variable | ||||||
|                     it?.text() |                     it?.text() | ||||||
|                 } |                 } | ||||||
|             return MovieLoadResponse( |             return newMovieLoadResponse(title,url,TvType.Movie,url) { | ||||||
|                 title, |                 this.posterUrl = poster | ||||||
|                 url, |                 addRating(soup.select("div.fr-count > div")?.text()) | ||||||
|                 this.name, |                 this.year = soup.select("ul.flist-col > li")?.getOrNull(2)?.text()?.toIntOrNull() | ||||||
|                 TvType.Movie, |                 this.tags = tagsList | ||||||
|                 url, |                 this.plot = description | ||||||
|                 poster, |                 addTrailer(soup.selectFirst("div.fleft > span > a")?.attr("href")) | ||||||
|                 date, |             } | ||||||
|                 description, |  | ||||||
|                 ratingAverage, |  | ||||||
|                 tagsList, |  | ||||||
|                 null, |  | ||||||
|                 trailer |  | ||||||
|             ) |  | ||||||
|         } else  // a tv serie |         } else  // a tv serie | ||||||
|         { |         { | ||||||
|             //println(listEpisode) |             //println(listEpisode) | ||||||
|             //println("listeEpisode:") |             //println("listeEpisode:") | ||||||
|             val episode_list = if ("<a" !in (listEpisode[0]).toString()) {  // check if VF is empty |             val episodeList = if ("<a" !in (listEpisode[0]).toString()) {  // check if VF is empty | ||||||
|                 listEpisode[1]  // no vf, return vostfr |                 listEpisode[1]  // no vf, return vostfr | ||||||
|             } |             } | ||||||
|             else { |             else { | ||||||
|  | @ -96,7 +89,7 @@ class FrenchStreamProvider : MainAPI() { | ||||||
| 
 | 
 | ||||||
|             //println(url) |             //println(url) | ||||||
| 
 | 
 | ||||||
|             val episodes = episode_list.select("a").map { a -> |             val episodes = episodeList.select("a").map { a -> | ||||||
|                 val epNum = a.text().split("Episode")[1].trim().toIntOrNull() |                 val epNum = a.text().split("Episode")[1].trim().toIntOrNull() | ||||||
|                 val epTitle = if (a.text()?.toString() != null) |                 val epTitle = if (a.text()?.toString() != null) | ||||||
|                     if (a.text().contains("Episode")) { |                     if (a.text().contains("Episode")) { | ||||||
|  | @ -131,8 +124,6 @@ class FrenchStreamProvider : MainAPI() { | ||||||
|                 null, |                 null, | ||||||
|                 description, |                 description, | ||||||
|                 ShowStatus.Ongoing, |                 ShowStatus.Ongoing, | ||||||
|                 null, |  | ||||||
|                 null |  | ||||||
|             ) |             ) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -10,6 +10,7 @@ import com.lagradost.cloudstream3.APIHolder.getApiFromNameNull | ||||||
| import com.lagradost.cloudstream3.APIHolder.getApiFromUrlNull | import com.lagradost.cloudstream3.APIHolder.getApiFromUrlNull | ||||||
| import com.lagradost.cloudstream3.APIHolder.getId | import com.lagradost.cloudstream3.APIHolder.getId | ||||||
| import com.lagradost.cloudstream3.AcraApplication.Companion.setKey | import com.lagradost.cloudstream3.AcraApplication.Companion.setKey | ||||||
|  | import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer | ||||||
| import com.lagradost.cloudstream3.mvvm.Resource | import com.lagradost.cloudstream3.mvvm.Resource | ||||||
| import com.lagradost.cloudstream3.mvvm.safeApiCall | import com.lagradost.cloudstream3.mvvm.safeApiCall | ||||||
| import com.lagradost.cloudstream3.syncproviders.SyncAPI | import com.lagradost.cloudstream3.syncproviders.SyncAPI | ||||||
|  | @ -123,7 +124,7 @@ class ResultViewModel : ViewModel() { | ||||||
|             rating = rating ?: meta.publicScore |             rating = rating ?: meta.publicScore | ||||||
|             tags = tags ?: meta.genres |             tags = tags ?: meta.genres | ||||||
|             plot = if (plot.isNullOrBlank()) meta.synopsis else plot |             plot = if (plot.isNullOrBlank()) meta.synopsis else plot | ||||||
|             trailerUrl = trailerUrl ?: meta.trailerUrl |             addTrailer(meta.trailerUrl) | ||||||
|             posterUrl = posterUrl ?: meta.posterUrl ?: meta.backgroundPosterUrl |             posterUrl = posterUrl ?: meta.posterUrl ?: meta.backgroundPosterUrl | ||||||
|             actors = actors ?: meta.actors |             actors = actors ?: meta.actors | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | @ -222,6 +222,7 @@ object AppUtils { | ||||||
| 
 | 
 | ||||||
|     /** Any object as json string */ |     /** Any object as json string */ | ||||||
|     fun Any.toJson(): String { |     fun Any.toJson(): String { | ||||||
|  |         if(this is String) return this | ||||||
|         return mapper.writeValueAsString(this) |         return mapper.writeValueAsString(this) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue