LookMovie provider done

This commit is contained in:
LagradOst 2021-06-25 01:20:49 +02:00
parent 5c3691ee2e
commit cea1839b5c

View file

@ -3,7 +3,10 @@ package com.lagradost.cloudstream3.movieproviders
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.module.kotlin.readValue
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.APIHolder.unixTime
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.Qualities
import com.lagradost.cloudstream3.utils.getQualityFromName
import org.jsoup.Jsoup
class LookMovieProvider : MainAPI() {
@ -26,6 +29,25 @@ class LookMovieProvider : MainAPI() {
// @JsonProperty("flag_quality") val flag_quality: Int?,
)
data class LookMovieTokenRoot(
@JsonProperty("data") val data: LookMovieTokenResult?,
@JsonProperty("success") val success: Boolean,
)
data class LookMovieTokenResult(
@JsonProperty("accessToken") val accessToken: String,
@JsonProperty("subtitles") val subtitles: List<LookMovieTokenSubtitle>?,
)
data class LookMovieTokenSubtitle(
@JsonProperty("language") val language: String,
//@JsonProperty("source") val source: String,
//@JsonProperty("source_id") val source_id: String,
//@JsonProperty("kind") val kind: String,
//@JsonProperty("id") val id: String,
@JsonProperty("file") val file: String,
)
data class LookMovieSearchResultRoot(
// @JsonProperty("per_page") val per_page: Int?,
// @JsonProperty("total") val total: Int?,
@ -115,7 +137,15 @@ class LookMovieProvider : MainAPI() {
}
override fun loadLinks(data: String, isCasting: Boolean, callback: (ExtractorLink) -> Unit): Boolean {
return super.loadLinks(data, isCasting, callback)
val response = khttp.get(data.replace("\$unixtime", unixTime.toString()))
"\"(.*?)\":\"(.*?)\"".toRegex().findAll(response.text).forEach {
var quality = it.groupValues[1].replace("auto", "Auto")
if (quality != "Auto") quality += "p"
val url = it.groupValues[2]
callback.invoke(ExtractorLink(this.name, "${this.name} - $quality", url, "", getQualityFromName(quality),true))
}
return true
}
override fun load(slug: String): LoadResponse? {
@ -123,26 +153,41 @@ class LookMovieProvider : MainAPI() {
val document = Jsoup.parse(response.text)
val isMovie = slug.contains("/movies/")
val watchHeader = document.selectFirst("div.watch-heading")
val nameHeader = watchHeader.selectFirst("> h1.bd-hd")
val year = nameHeader.selectFirst("> span")?.text()?.toIntOrNull()
val name = nameHeader.ownText()
val rating = parseRating(watchHeader.selectFirst("> div.movie-rate > div.rate > p > span").text())
val img = document.selectFirst("div.movie-img > p.movie__poster")?.attr("style")
val poster = if (img.isNullOrEmpty()) null else "url\\((.*?)\\)".toRegex().find(img)?.groupValues?.get(1)
val imgElement = document.selectFirst("div.movie-img > p.movie__poster")
val img = imgElement?.attr("style")
var poster = if (img.isNullOrEmpty()) null else "url\\((.*?)\\)".toRegex().find(img)?.groupValues?.get(1)
if (poster.isNullOrEmpty()) poster = imgElement?.attr("data-background-image")
val descript = document.selectFirst("p.description-short").text()
val id = "${if (isMovie) "id_movie" else "id_show"}:(.*?),".toRegex().find(response.text)?.groupValues?.get(1)?.replace(" ", "")
val id = "${if (isMovie) "id_movie" else "id_show"}:(.*?),".toRegex().find(response.text)?.groupValues?.get(1)
?.replace(" ", "")
?: return null
val realSlug = slug.replace("$mainUrl/${if (isMovie) "movies" else "shows"}/view/", "")
val realUrl =
"$mainUrl/api/v1/security/${if (isMovie) "movie" else "show"}-access?${if (isMovie) "id_movie=$id" else "slug=$realSlug"}&token=1&sk=&step=1"
println("URLLLL:::: " + realUrl)
val tokenResponse = khttp.get(realUrl)
val root = mapper.readValue<LookMovieTokenRoot>(tokenResponse.text)
val accessToken = root.data?.accessToken ?: return null
//https://lookmovie.io/api/v1/security/show-access?slug=9140554-loki-2021&token=&sk=null&step=1
//https://lookmovie.io/api/v1/security/movie-access?id_movie=11582&token=1&sk=&step=1
if (isMovie) {
return MovieLoadResponse(name, slug, this.name, TvType.Movie, id, poster, year, descript, null, rating)
return MovieLoadResponse(name,
slug,
this.name,
TvType.Movie,
"$mainUrl/manifests/movies/json/$id/\$unixtime/$accessToken/master.m3u8",
poster,
year,
descript,
null,
rating)
} else {
val window =
"window\\[\\'show_storage\\'\\] =((.|\\n)*?\\<)".toRegex().find(response.text)?.groupValues?.get(1)
@ -167,7 +212,10 @@ class LookMovieProvider : MainAPI() {
val realJson = "[" + json.substring(0, json.lastIndexOf(',')) + "]"
val episodes = mapper.readValue<List<LookMovieEpisode>>(realJson).map {
TvSeriesEpisode(it.title, it.season.toIntOrNull(), it.episode.toIntOrNull(), it.idEpisode.toString())
TvSeriesEpisode(it.title,
it.season.toIntOrNull(),
it.episode.toIntOrNull(),
"$mainUrl/manifests/shows/json/$accessToken/\$unixtime/${it.idEpisode}/master.m3u8")
}.toList()
return TvSeriesLoadResponse(name,