From 9d439f417d8c6b5eaefa4e8cee1c98ea88ecf0a0 Mon Sep 17 00:00:00 2001 From: hexated Date: Sat, 21 Jan 2023 05:06:45 +0700 Subject: [PATCH] fixed HDrezka --- HDrezkaProvider/build.gradle.kts | 2 +- .../kotlin/com/hexated/HDrezkaProvider.kt | 100 ++++++++---------- .../main/kotlin/com/hexated/SoraExtractor.kt | 12 +-- .../src/main/kotlin/com/hexated/SoraUtils.kt | 9 +- 4 files changed, 59 insertions(+), 64 deletions(-) diff --git a/HDrezkaProvider/build.gradle.kts b/HDrezkaProvider/build.gradle.kts index 4f6da247..2fc9aa63 100644 --- a/HDrezkaProvider/build.gradle.kts +++ b/HDrezkaProvider/build.gradle.kts @@ -1,5 +1,5 @@ // use an integer for version numbers -version = 2 +version = 3 cloudstream { diff --git a/HDrezkaProvider/src/main/kotlin/com/hexated/HDrezkaProvider.kt b/HDrezkaProvider/src/main/kotlin/com/hexated/HDrezkaProvider.kt index f3570c5e..9c119902 100644 --- a/HDrezkaProvider/src/main/kotlin/com/hexated/HDrezkaProvider.kt +++ b/HDrezkaProvider/src/main/kotlin/com/hexated/HDrezkaProvider.kt @@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.LoadResponse.Companion.addActors import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer -import com.lagradost.cloudstream3.mvvm.suspendSafeApiCall import com.lagradost.cloudstream3.utils.AppUtils.toJson import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson import com.lagradost.cloudstream3.utils.ExtractorLink @@ -91,7 +90,7 @@ class HDrezkaProvider : MainAPI() { ?: document.selectFirst("div.b-post__title h1")?.text()?.trim()).toString() val poster = fixUrlNull(document.selectFirst("div.b-sidecover img")?.attr("src")) val tags = - document.select("table.b-post__info > tbody > tr:nth-child(5) span[itemprop=genre]") + document.select("table.b-post__info > tbody > tr:contains(Жанр) span[itemprop=genre]") .map { it.text() } val year = document.select("div.film-info > div:nth-child(2) a").text().toIntOrNull() val tvType = if (document.select("div#simple-episodes-tabs") @@ -108,12 +107,13 @@ class HDrezkaProvider : MainAPI() { val rating = document.selectFirst("table.b-post__info > tbody > tr:nth-child(1) span.bold")?.text() .toRatingInt() - val actors = document.select("table.b-post__info > tbody > tr:last-child span.item").map { - Actor( - it.selectFirst("span[itemprop=name]")?.text().toString(), - it.selectFirst("span[itemprop=actor]")?.attr("data-photo") - ) - } + val actors = + document.select("table.b-post__info > tbody > tr:last-child span.item").mapNotNull { + Actor( + it.selectFirst("span[itemprop=name]")?.text() ?: return@mapNotNull null, + it.selectFirst("span[itemprop=actor]")?.attr("data-photo") + ) + } val recommendations = document.select("div.b-sidelist div.b-content__inline_item").map { it.toSearchResult() @@ -273,35 +273,25 @@ class HDrezkaProvider : MainAPI() { ) { decryptStreamUrl(url).split(",").map { links -> val quality = - Regex("\\[([0-9]*p.*?)]").find(links)?.groupValues?.getOrNull(1) - .toString().trim() - links.replace("[$quality]", "").split("or").map { it.trim() } - .map { link -> - - if (link.endsWith(".m3u8")) { - cleanCallback( - "$source (Main)", - link, - quality, - true, - sourceCallback, - ) - } else { - cleanCallback( - "$source (Backup)", - link, - quality, - false, - sourceCallback, - ) - } + Regex("\\[([0-9]{3,4}p\\s?\\w*?)]").find(links)?.groupValues?.getOrNull(1) + ?.trim() ?: return@map null + links.replace("[$quality]", "").split(" or ") + .map { + val link = it.trim() + val type = if(link.contains(".m3u8")) "(Main)" else "(Backup)" + cleanCallback( + "$source $type", + link, + quality, + link.contains(".m3u8"), + sourceCallback, + ) } } subtitle.split(",").map { sub -> val language = - Regex("\\[(.*)]").find(sub)?.groupValues?.getOrNull(1) - .toString() + Regex("\\[(.*)]").find(sub)?.groupValues?.getOrNull(1) ?: return@map null val link = sub.replace("[$language]", "").trim() subCallback.invoke( SubtitleFile( @@ -339,30 +329,28 @@ class HDrezkaProvider : MainAPI() { } } else { res.server?.apmap { server -> - suspendSafeApiCall { - app.post( - url = "$mainUrl/ajax/get_cdn_series/?t=${Date().time}", - data = mapOf( - "id" to res.id, - "translator_id" to server.translator_id, - "favs" to res.favs, - "is_camrip" to server.camrip, - "is_ads" to server.ads, - "is_director" to server.director, - "season" to res.season, - "episode" to res.episode, - "action" to res.action, - ).filterValues { it != null }.mapValues { it.value as String }, - referer = res.ref - ).parsedSafe()?.let { source -> - invokeSources( - server.translator_name.toString(), - source.url, - source.subtitle.toString(), - subtitleCallback, - callback - ) - } + app.post( + url = "$mainUrl/ajax/get_cdn_series/?t=${Date().time}", + data = mapOf( + "id" to res.id, + "translator_id" to server.translator_id, + "favs" to res.favs, + "is_camrip" to server.camrip, + "is_ads" to server.ads, + "is_director" to server.director, + "season" to res.season, + "episode" to res.episode, + "action" to res.action, + ).filterValues { it != null }.mapValues { it.value as String }, + referer = res.ref + ).parsedSafe()?.let { source -> + invokeSources( + server.translator_name.toString(), + source.url, + source.subtitle.toString(), + subtitleCallback, + callback + ) } } } diff --git a/SoraStream/src/main/kotlin/com/hexated/SoraExtractor.kt b/SoraStream/src/main/kotlin/com/hexated/SoraExtractor.kt index 5620661b..98411b82 100644 --- a/SoraStream/src/main/kotlin/com/hexated/SoraExtractor.kt +++ b/SoraStream/src/main/kotlin/com/hexated/SoraExtractor.kt @@ -166,21 +166,21 @@ object SoraExtractor : SoraStream() { app.get("https://voidboost.net/serial/$token/iframe?s=$season&e=$episode&h=dbgo.fun").document.select( "script" ).find { it.data().contains("CDNplayerConfig =") }?.data() - } + } ?: return val source = - Regex("['|\"]file['|\"]:\\s['|\"](#\\S+?)['|\"]").find(script.toString())?.groupValues?.get( + Regex("['|\"]file['|\"]:\\s['|\"](#\\S+?)['|\"]").find(script)?.groupValues?.get( 1 ) ?: return val subtitle = - Regex("['|\"]subtitle['|\"]:\\s['|\"](\\S+?)['|\"]").find(script.toString())?.groupValues?.get( + Regex("['|\"]subtitle['|\"]:\\s['|\"](\\S+?)['|\"]").find(script)?.groupValues?.get( 1 ) val ref = getBaseUrl(iframeDbgo) decryptStreamUrl(source).split(",").map { links -> val quality = - Regex("\\[([0-9]*p.*?)]").find(links)?.groupValues?.getOrNull(1).toString().trim() + Regex("\\[([0-9]*p.*?)]").find(links)?.groupValues?.getOrNull(1)?.trim() ?: return@map null links.replace("[$quality]", "").split(" or ").map { it.trim() }.map { link -> val name = if (link.contains(".m3u8")) "Dbgo (Main)" else "Dbgo (Backup)" callback.invoke( @@ -200,11 +200,11 @@ object SoraExtractor : SoraStream() { } subtitle?.split(",")?.map { sub -> - val language = Regex("\\[(.*)]").find(sub)?.groupValues?.getOrNull(1).toString() + val language = Regex("\\[(.*)]").find(sub)?.groupValues?.getOrNull(1) ?: return@map null val link = sub.replace("[$language]", "").trim() subtitleCallback.invoke( SubtitleFile( - language, link + getDbgoLanguage(language), link ) ) } diff --git a/SoraStream/src/main/kotlin/com/hexated/SoraUtils.kt b/SoraStream/src/main/kotlin/com/hexated/SoraUtils.kt index ae8cf713..fa34422a 100644 --- a/SoraStream/src/main/kotlin/com/hexated/SoraUtils.kt +++ b/SoraStream/src/main/kotlin/com/hexated/SoraUtils.kt @@ -5,7 +5,6 @@ import com.hexated.SoraStream.Companion.filmxyAPI import com.hexated.SoraStream.Companion.gdbot import com.hexated.SoraStream.Companion.kamyrollAPI import com.hexated.SoraStream.Companion.tvMoviesAPI -import com.lagradost.cloudstream3.APIHolder import com.lagradost.cloudstream3.APIHolder.getCaptchaToken import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.base64Decode @@ -603,6 +602,14 @@ fun getVipLanguage(str: String): String { } } +fun getDbgoLanguage(str: String): String { + return when (str) { + "Русский" -> "Russian" + "Українська" -> "Ukrainian" + else -> str + } +} + fun getBaseUrl(url: String): String { return URI(url).let { "${it.scheme}://${it.host}"