Akwam stuff

This commit is contained in:
LagradOst 2022-02-06 23:38:53 +01:00
parent f14f6e47f0
commit ae6dfe6a49
2 changed files with 38 additions and 17 deletions

View file

@ -478,7 +478,7 @@ data class MovieSearchResponse(
override val type: TvType, override val type: TvType,
override val posterUrl: String?, override val posterUrl: String?,
val year: Int?, val year: Int? = null,
override val id: Int? = null, override val id: Int? = null,
) : SearchResponse ) : SearchResponse
@ -525,6 +525,11 @@ interface LoadResponse {
this.actors = actors?.map { (actor, role) -> ActorData(actor, role = role) } this.actors = actors?.map { (actor, role) -> ActorData(actor, role = role) }
} }
@JvmName("addActorsOnly")
fun LoadResponse.addActors(actors: List<Actor>?) {
this.actors = actors?.map { actor -> ActorData(actor) }
}
fun LoadResponse.setDuration(input: String?) { fun LoadResponse.setDuration(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 ->

View file

@ -1,6 +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.addActors
import com.lagradost.cloudstream3.network.AppResponse import com.lagradost.cloudstream3.network.AppResponse
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.Qualities import com.lagradost.cloudstream3.utils.Qualities
@ -16,7 +17,7 @@ class AkwamProvider : MainAPI() {
private fun Element.toSearchResponse(): SearchResponse? { private fun Element.toSearchResponse(): SearchResponse? {
val url = select("a.box")?.attr("href") ?: return null val url = select("a.box")?.attr("href") ?: return null
if(url.contains("/games/") || url.contains("/programs/")) return null if (url.contains("/games/") || url.contains("/programs/")) return null
val poster = select("picture > img") val poster = select("picture > img")
val title = poster.attr("alt") val title = poster.attr("alt")
val posterUrl = poster.attr("data-src") val posterUrl = poster.attr("data-src")
@ -107,26 +108,39 @@ class AkwamProvider : MainAPI() {
it.text() it.text()
} }
// Commented out as no use yet val actors = doc.select("div.widget-body > div > div.entry-box > a")?.mapNotNull {
// val recommendations = doc.select("div.entry-image").map { val name = it?.selectFirst("div > .entry-title")?.text() ?: return@mapNotNull null
// it.toSearchResponse() val image = it.selectFirst("div > img")?.attr("src") ?: return@mapNotNull null
// } Actor(name, image)
}
val recommendations =
doc.select("div > div.widget-body > div.row > div > div.entry-box")?.mapNotNull {
val recTitle = it?.selectFirst("div.entry-body > .entry-title > .text-white")
?: return@mapNotNull null
val href = recTitle.attr("href") ?: return@mapNotNull null
val name = recTitle.text() ?: return@mapNotNull null
val poster = it.selectFirst(".entry-image > a > picture > img")?.attr("data-src")
?: return@mapNotNull null
MovieSearchResponse(name, href, this.name, TvType.Movie, fixUrl(poster))
}
return if (isMovie) { return if (isMovie) {
MovieLoadResponse( newMovieLoadResponse(
title, title,
url, url,
this@AkwamProvider.name,
TvType.Movie, TvType.Movie,
url, url
posterUrl, ) {
year, this.posterUrl = posterUrl
synopsis, this.year = year
null, // Possible this.plot = synopsis
rating, this.rating = rating
tags, this.tags = tags
duration, this.duration = duration
) this.recommendations = recommendations
addActors(actors)
}
} else { } else {
val episodes = doc.select("div.bg-primary2.p-4.col-lg-4.col-md-6.col-12").map { val episodes = doc.select("div.bg-primary2.p-4.col-lg-4.col-md-6.col-12").map {
it.toTvSeriesEpisode() it.toTvSeriesEpisode()
@ -144,6 +158,8 @@ class AkwamProvider : MainAPI() {
this.rating = rating this.rating = rating
this.year = year this.year = year
this.plot = synopsis this.plot = synopsis
this.recommendations = recommendations
addActors(actors)
} }
} }
} }