fix #580, fix #575, solved #566

This commit is contained in:
Olivia 2024-02-08 17:33:52 +07:00
parent c57f60275d
commit b03368e13a
5 changed files with 94 additions and 57 deletions

View file

@ -1,5 +1,5 @@
// use an integer for version numbers // use an integer for version numbers
version = 1 version = 2
cloudstream { cloudstream {

View file

@ -3,10 +3,10 @@ package com.hexated
import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.LoadResponse.Companion.addActors import com.lagradost.cloudstream3.LoadResponse.Companion.addActors
import com.lagradost.cloudstream3.utils.*
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.M3u8Helper
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import java.net.URLDecoder
class DubokuProvider : MainAPI() { class DubokuProvider : MainAPI() {
override var mainUrl = "https://www.duboku.tv" override var mainUrl = "https://www.duboku.tv"
@ -110,21 +110,29 @@ class DubokuProvider : MainAPI() {
if (script.data().contains("var player_data={")) { if (script.data().contains("var player_data={")) {
val dataJson = val dataJson =
script.data().substringAfter("var player_data={").substringBefore("}") script.data().substringAfter("var player_data={").substringBefore("}")
tryParseJson<Sources>("{$dataJson}")?.let { source -> val source = tryParseJson<Sources>("{$dataJson}")
M3u8Helper.generateM3u8( callback.invoke(
ExtractorLink(
this.name, this.name,
source.url ?: return@map, this.name,
referer = "https://w.duboku.io/", decode(base64Decode(source?.url ?: return@map)),
headers = mapOf("Origin" to "https://w.duboku.io") "https://w.duboku.io/",
).forEach(callback) Qualities.Unknown.value,
INFER_TYPE,
headers = mapOf(
"Accept-Language" to "en-US,en;q=0.5",
"Origin" to "https://w.duboku.io"
),
)
)
} }
} }
}
return true return true
} }
private fun decode(input: String): String = URLDecoder.decode(input, "utf-8")
data class Sources( data class Sources(
@JsonProperty("url") val url: String?, @JsonProperty("url") val url: String?,
) )

View file

@ -1,5 +1,5 @@
// use an integer for version numbers // use an integer for version numbers
version = 2 version = 3
cloudstream { cloudstream {

View file

@ -2,6 +2,7 @@ package com.hexated
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.extractors.Chillx import com.lagradost.cloudstream3.extractors.Chillx
import com.lagradost.cloudstream3.network.CloudflareKiller
import com.lagradost.cloudstream3.utils.AppUtils import com.lagradost.cloudstream3.utils.AppUtils
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.ExtractorLinkType import com.lagradost.cloudstream3.utils.ExtractorLinkType
@ -11,7 +12,7 @@ import org.jsoup.nodes.Element
class Kinoger : MainAPI() { class Kinoger : MainAPI() {
override var name = "Kinoger" override var name = "Kinoger"
override var mainUrl = "https://kinoger.com" override var mainUrl = "https://kinoger.to"
override var lang = "de" override var lang = "de"
override val hasMainPage = true override val hasMainPage = true
override val supportedTypes = setOf(TvType.TvSeries, TvType.Movie) override val supportedTypes = setOf(TvType.TvSeries, TvType.Movie)

View file

@ -4,7 +4,10 @@ import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.LoadResponse.Companion.addActors import com.lagradost.cloudstream3.LoadResponse.Companion.addActors
import com.lagradost.cloudstream3.utils.* import com.lagradost.cloudstream3.utils.*
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
import com.lagradost.cloudstream3.utils.AppUtils.toJson
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import org.jsoup.select.Elements
class Raveeflix : MainAPI() { class Raveeflix : MainAPI() {
override var mainUrl = "https://raveeflix.my.id" override var mainUrl = "https://raveeflix.my.id"
@ -21,6 +24,7 @@ class Raveeflix : MainAPI() {
override val mainPage = override val mainPage =
mainPageOf( mainPageOf(
"categories/trending" to "Trending", "categories/trending" to "Trending",
"movies" to "Movies",
"tv" to "Tv-Shows", "tv" to "Tv-Shows",
"drakor" to "Drakor", "drakor" to "Drakor",
"categories/anime" to "Anime", "categories/anime" to "Anime",
@ -45,34 +49,41 @@ class Raveeflix : MainAPI() {
val href = fixUrl(this.attr("href")) val href = fixUrl(this.attr("href"))
val posterUrl = this.selectFirst("div.thumbnail_card")?.attr("style")?.getPoster() val posterUrl = this.selectFirst("div.thumbnail_card")?.attr("style")?.getPoster()
return newMovieSearchResponse(title, href, TvType.Movie) { return newMovieSearchResponse(title, Media(href, posterUrl).toJson(), TvType.Movie) {
this.posterUrl = posterUrl this.posterUrl = posterUrl
} }
} }
override suspend fun search(query: String): List<SearchResponse>? { override suspend fun search(query: String): List<SearchResponse>? {
val res = app.get("$mainUrl/index.json").text.let { AppUtils.tryParseJson<ArrayList<Index>>(it) } val res =
app.get("$mainUrl/index.json").text.let { AppUtils.tryParseJson<ArrayList<Index>>(it) }
return res?.filter { return res?.filter {
it.title?.contains( it.title?.contains(
query, query,
true true
) == true && !it.section.equals("Categories", true) && !it.section.equals("Tags", true) && it.permalink?.contains("/episode") == false ) == true && !it.section.equals("Categories", true) && !it.section.equals(
"Tags",
true
) && it.permalink?.contains("/episode") == false
}?.mapNotNull { }?.mapNotNull {
newMovieSearchResponse( newMovieSearchResponse(
it.title ?: return@mapNotNull null, it.title ?: return@mapNotNull null,
Media(
fixUrl( fixUrl(
it.permalink?.substringBefore("episode")?.substringBefore("season") it.permalink?.substringBefore("episode")?.substringBefore("season")
?: return@mapNotNull null, ?: return@mapNotNull null
), )
).toJson(),
TvType.Movie, TvType.Movie,
) )
} }
} }
override suspend fun load(url: String): LoadResponse { override suspend fun load(url: String): LoadResponse {
val document = app.get(url).document val media = parseJson<Media>(url)
val document = app.get(media.url).document
val title = document.selectFirst("h1.text-4xl")?.text() ?: "No Title" val title = document.selectFirst("h1.text-4xl")?.text() ?: "No Title"
val poster = document.selectFirst("div.thumbnail_card, div.w-full.thumbnail_card_related") val poster = media.poster ?: document.selectFirst("div.thumbnail_card, div.w-full.thumbnail_card_related")
?.attr("style")?.getPoster() ?.attr("style")?.getPoster()
val type = val type =
if (document.select("mux-player").isNullOrEmpty()) TvType.TvSeries else TvType.Movie if (document.select("mux-player").isNullOrEmpty()) TvType.TvSeries else TvType.Movie
@ -103,42 +114,24 @@ class Raveeflix : MainAPI() {
document.select("section.w-full a.min-w-full").mapNotNull { it.toSearchResult() } document.select("section.w-full a.min-w-full").mapNotNull { it.toSearchResult() }
return if (type == TvType.TvSeries) { return if (type == TvType.TvSeries) {
val section = document.select("div.relative > section.w-full a.min-w-full") val sectionSelector = "div.relative > section.w-full a.min-w-full"
val section = document.select(sectionSelector)
val hasMultipleSeason = section.any { it.attr("href").contains("/season-") } val hasMultipleSeason = section.any { it.attr("href").contains("/season-") }
val episodes = val episodes = if (hasMultipleSeason) {
if (hasMultipleSeason) {
section.apmap { ss -> section.apmap { ss ->
val season = ss.selectFirst("div.text-xl")?.text()?.filter { it.isDigit() } fetchEpisodesFromPages(
ss.attr("href"),
5,
sectionSelector,
true,
ss.selectFirst("div.text-xl")?.text()?.filter { it.isDigit() }
?.toIntOrNull() ?.toIntOrNull()
app.get(fixUrl(ss.attr("href"))).document.select("div.relative > section.w-full a.min-w-full")
.mapNotNull { eps ->
val name = eps.selectFirst("div.text-xl")?.text()
?: return@mapNotNull null
val href = fixUrl(eps.attr("href"))
val posterUrl = eps.selectFirst("div.thumbnail_card")?.attr("style")
?.getPoster()
Episode(
href,
name,
posterUrl = posterUrl,
season = season
) )
} }.toMutableList().flatten()
}.flatten()
} else { } else {
section.mapNotNull { eps -> fetchEpisodesFromPages(media.url, 5, sectionSelector, false)
val name = eps.selectFirst("div.text-xl")?.text() ?: return@mapNotNull null
val href = fixUrl(eps.attr("href"))
val posterUrl =
eps.selectFirst("div.thumbnail_card")?.attr("style")?.getPoster()
Episode(
href,
name,
posterUrl = posterUrl,
)
} }
} newTvSeriesLoadResponse(title, media.url, TvType.TvSeries, episodes.reversed()) {
newTvSeriesLoadResponse(title, url, TvType.TvSeries, episodes.reversed()) {
this.posterUrl = poster this.posterUrl = poster
this.year = year this.year = year
this.seasonNames this.seasonNames
@ -149,7 +142,7 @@ class Raveeflix : MainAPI() {
this.recommendations = recommendations this.recommendations = recommendations
} }
} else { } else {
newMovieLoadResponse(title, url, TvType.Movie, url) { newMovieLoadResponse(title, media.url, TvType.Movie, media.url) {
this.posterUrl = poster this.posterUrl = poster
this.year = year this.year = year
this.plot = description this.plot = description
@ -183,6 +176,39 @@ class Raveeflix : MainAPI() {
return true return true
} }
private suspend fun fetchEpisodesFromPages(
baseUrl: String,
maxPages: Int,
sectionSelector: String,
hasMultipleSeasons: Boolean,
season: Int? = null
): MutableList<Episode> {
val epsData = mutableListOf<Episode>()
for (index in 1..maxPages) {
val pageUrl = if (index == 1) baseUrl else "${baseUrl.removeSuffix("/")}/page/$index/"
val episodeVo = app.get(fixUrl(pageUrl)).document.select(sectionSelector)
.getEpisodes(if (hasMultipleSeasons) season else null)
if (episodeVo.isEmpty()) break
epsData.addAll(episodeVo)
}
return epsData
}
private fun Elements.getEpisodes(season: Int? = 1): List<Episode> {
return this.mapNotNull { eps ->
val name = eps.selectFirst("div.text-xl")?.text() ?: return@mapNotNull null
val href = fixUrl(eps.attr("href"))
val posterUrl =
eps.selectFirst("div.thumbnail_card")?.attr("style")?.getPoster()
Episode(
href,
name,
posterUrl = posterUrl,
season = season
)
}
}
private fun String.getPoster(): String? { private fun String.getPoster(): String? {
return fixUrlNull( return fixUrlNull(
this.substringAfter("(") this.substringAfter("(")
@ -190,6 +216,8 @@ class Raveeflix : MainAPI() {
) )
} }
data class Media(val url: String, val poster: String? = null)
data class Index( data class Index(
@JsonProperty("title") val title: String? = null, @JsonProperty("title") val title: String? = null,
@JsonProperty("permalink") val permalink: String? = null, @JsonProperty("permalink") val permalink: String? = null,