From b8a2d87f8e7be05a0c4a5d8e5edd02ca2c2f0c2b Mon Sep 17 00:00:00 2001 From: Dark25 Date: Sun, 15 Sep 2024 08:59:49 +0200 Subject: [PATCH 1/8] feat(lib/src/es/de): refactor, implement and fixed extensions/libs --- lib/streamsilk-extractor/build.gradle.kts | 7 + .../lib/streamsilkextractor/JsHunter.kt | 86 ++++++++ .../StreamSilkExtractor.kt | 62 ++++++ lib/vidguard-extractor/build.gradle.kts | 8 + .../vidguardextractor/VidGuardExtractor.kt | 104 +++++++++ .../tachiyomi/lib/vkextractor/VkExtractor.kt | 9 +- src/de/animebase/build.gradle | 5 +- .../animeextension/de/animebase/AnimeBase.kt | 2 +- .../animebase/extractors/VidGuardExtractor.kt | 124 ----------- src/de/moflixstream/build.gradle | 5 +- .../de/moflixstream/MoflixStream.kt | 2 +- .../extractors/VidGuardExtractor.kt | 124 ----------- src/es/animefenix/build.gradle | 2 +- .../es/animefenix/AnimeFenixFilters.kt | 161 ++++++++++++++ .../es/animefenix/Animefenix.kt | 139 +----------- src/es/animeflv/build.gradle | 2 +- .../animeextension/es/animeflv/AnimeFlv.kt | 111 +--------- .../es/animeflv/AnimeFlvFilters.kt | 148 +++++++++++++ src/es/asialiveaction/build.gradle | 18 +- .../res/mipmap-hdpi/ic_launcher.png | Bin 6481 -> 3596 bytes .../res/mipmap-mdpi/ic_launcher.png | Bin 3492 -> 1872 bytes .../res/mipmap-xhdpi/ic_launcher.png | Bin 10041 -> 4763 bytes .../res/mipmap-xxhdpi/ic_launcher.png | Bin 18825 -> 8221 bytes .../res/mipmap-xxxhdpi/ic_launcher.png | Bin 29034 -> 12922 bytes .../es/asialiveaction/AsiaLiveAction.kt | 187 ++++++---------- .../extractors/VidGuardExtractor.kt | 124 ----------- src/es/cine24h/build.gradle | 3 +- .../animeextension/es/cine24h/Cine24h.kt | 11 +- src/es/hackstore/build.gradle | 2 +- .../animeextension/es/hackstore/Hackstore.kt | 21 ++ src/es/pelisplushd/build.gradle | 4 +- .../es/pelisplushd/Pelisplushd.kt | 93 +++++--- .../es/pelisplushd/Pelisplusph.kt | 54 ----- .../es/pelisplushd/Pelisplusto.kt | 74 +------ src/es/tioanimeh/build.gradle | 4 +- .../tioanimeh/res/mipmap-hdpi/ic_launcher.jpg | Bin 43584 -> 0 bytes .../tioanimeh/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 3144 bytes .../tioanimeh/res/mipmap-mdpi/ic_launcher.jpg | Bin 43584 -> 0 bytes .../tioanimeh/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 1663 bytes .../res/mipmap-xhdpi/ic_launcher.jpg | Bin 43584 -> 0 bytes .../res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4417 bytes .../res/mipmap-xxhdpi/ic_launcher.jpg | Bin 43584 -> 0 bytes .../res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 9282 bytes .../res/mipmap-xxxhdpi/ic_launcher.jpg | Bin 43584 -> 0 bytes .../res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 13098 bytes .../es/tioanimeh/TioAnimeHFilters.kt | 208 ++++++++++++++++++ .../animeextension/es/tioanimeh/TioanimeH.kt | 129 +++++------ .../es/tioanimeh/TioanimeHFactory.kt | 59 +---- src/es/veranimes/build.gradle | 3 +- .../animeextension/es/veranimes/VerAnimes.kt | 104 +++------ .../es/veranimes/VerAnimesFilters.kt | 146 ++++++++++++ .../veranimes/extractors/VidGuardExtractor.kt | 124 ----------- 52 files changed, 1202 insertions(+), 1267 deletions(-) create mode 100644 lib/streamsilk-extractor/build.gradle.kts create mode 100644 lib/streamsilk-extractor/src/main/java/eu/kanade/tachiyomi/lib/streamsilkextractor/JsHunter.kt create mode 100644 lib/streamsilk-extractor/src/main/java/eu/kanade/tachiyomi/lib/streamsilkextractor/StreamSilkExtractor.kt create mode 100644 lib/vidguard-extractor/build.gradle.kts create mode 100644 lib/vidguard-extractor/src/main/java/eu/kanade/tachiyomi/lib/vidguardextractor/VidGuardExtractor.kt delete mode 100644 src/de/animebase/src/eu/kanade/tachiyomi/animeextension/de/animebase/extractors/VidGuardExtractor.kt delete mode 100644 src/de/moflixstream/src/eu/kanade/tachiyomi/animeextension/de/moflixstream/extractors/VidGuardExtractor.kt create mode 100644 src/es/animefenix/src/eu/kanade/tachiyomi/animeextension/es/animefenix/AnimeFenixFilters.kt create mode 100644 src/es/animeflv/src/eu/kanade/tachiyomi/animeextension/es/animeflv/AnimeFlvFilters.kt delete mode 100644 src/es/asialiveaction/src/eu/kanade/tachiyomi/animeextension/es/asialiveaction/extractors/VidGuardExtractor.kt delete mode 100644 src/es/tioanimeh/res/mipmap-hdpi/ic_launcher.jpg create mode 100644 src/es/tioanimeh/res/mipmap-hdpi/ic_launcher.png delete mode 100644 src/es/tioanimeh/res/mipmap-mdpi/ic_launcher.jpg create mode 100644 src/es/tioanimeh/res/mipmap-mdpi/ic_launcher.png delete mode 100644 src/es/tioanimeh/res/mipmap-xhdpi/ic_launcher.jpg create mode 100644 src/es/tioanimeh/res/mipmap-xhdpi/ic_launcher.png delete mode 100644 src/es/tioanimeh/res/mipmap-xxhdpi/ic_launcher.jpg create mode 100644 src/es/tioanimeh/res/mipmap-xxhdpi/ic_launcher.png delete mode 100644 src/es/tioanimeh/res/mipmap-xxxhdpi/ic_launcher.jpg create mode 100644 src/es/tioanimeh/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 src/es/tioanimeh/src/eu/kanade/tachiyomi/animeextension/es/tioanimeh/TioAnimeHFilters.kt create mode 100644 src/es/veranimes/src/eu/kanade/tachiyomi/animeextension/es/veranimes/VerAnimesFilters.kt delete mode 100644 src/es/veranimes/src/eu/kanade/tachiyomi/animeextension/es/veranimes/extractors/VidGuardExtractor.kt diff --git a/lib/streamsilk-extractor/build.gradle.kts b/lib/streamsilk-extractor/build.gradle.kts new file mode 100644 index 0000000000..d31dd9ff6d --- /dev/null +++ b/lib/streamsilk-extractor/build.gradle.kts @@ -0,0 +1,7 @@ +plugins { + id("lib-android") +} + +dependencies { + implementation(project(":lib:playlist-utils")) +} diff --git a/lib/streamsilk-extractor/src/main/java/eu/kanade/tachiyomi/lib/streamsilkextractor/JsHunter.kt b/lib/streamsilk-extractor/src/main/java/eu/kanade/tachiyomi/lib/streamsilkextractor/JsHunter.kt new file mode 100644 index 0000000000..8fff8ef098 --- /dev/null +++ b/lib/streamsilk-extractor/src/main/java/eu/kanade/tachiyomi/lib/streamsilkextractor/JsHunter.kt @@ -0,0 +1,86 @@ +package eu.kanade.tachiyomi.lib.streamsilkextractor + +import java.util.regex.Matcher +import java.util.regex.Pattern +import kotlin.math.pow + +class JsHunter(private val hunterJS: String) { + + /** + * Detects whether the javascript is H.U.N.T.E.R coded. + * + * @return true if it's H.U.N.T.E.R coded. + */ + fun detect(): Boolean { + val p = Pattern.compile("eval\\(function\\(h,u,n,t,e,r\\)") + val searchResults = p.matcher(hunterJS) + return searchResults.find() + } + + /** + * Unpack the javascript + * + * @return the javascript unhunt or null. + */ + + fun dehunt(): String? { + try { + val p: Pattern = + Pattern.compile( + """\}\("([^"]+)",[^,]+,\s*"([^"]+)",\s*(\d+),\s*(\d+)""", + Pattern.DOTALL + ) + val searchResults: Matcher = p.matcher(hunterJS) + if (searchResults.find() && searchResults.groupCount() == 4) { + val h = searchResults.group(1)!!.toString() + val n = searchResults.group(2)!!.toString() + val t = searchResults.group(3)!!.toInt() + val e = searchResults.group(4)!!.toInt() + return hunter(h, n, t, e) + } + } catch (e: Exception) { + return null + } + return null + } + + private fun duf(d: String, e: Int, f: Int = 10): Int { + val str = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/" + val g = str.toList() + val h = g.take(e) + val i = g.take(f) + val dList = d.reversed().toList() + var j = 0.0 + for ((c, b) in dList.withIndex()) { + if (b in h) { + j += h.indexOf(b) * e.toDouble().pow(c) + } + } + var k = "" + while (j > 0) { + k = i[(j % f).toInt()] + k + j = (j - j % f) / f + } + return k.toIntOrNull() ?: 0 + } + + private fun hunter(h: String, n: String, t: Int, e: Int): String { + var result = "" + var i = 0 + while (i < h.length) { + var j = 0 + var s = "" + while (h[i] != n[e]) { + s += h[i] + i++ + } + while (j < n.length) { + s = s.replace(n[j], j.digitToChar()) + j++ + } + result += (duf(s, e) - t).toChar() + i++ + } + return result + } +} diff --git a/lib/streamsilk-extractor/src/main/java/eu/kanade/tachiyomi/lib/streamsilkextractor/StreamSilkExtractor.kt b/lib/streamsilk-extractor/src/main/java/eu/kanade/tachiyomi/lib/streamsilkextractor/StreamSilkExtractor.kt new file mode 100644 index 0000000000..2c80ab483c --- /dev/null +++ b/lib/streamsilk-extractor/src/main/java/eu/kanade/tachiyomi/lib/streamsilkextractor/StreamSilkExtractor.kt @@ -0,0 +1,62 @@ +package eu.kanade.tachiyomi.lib.streamsilkextractor + +import eu.kanade.tachiyomi.animesource.model.Track +import eu.kanade.tachiyomi.animesource.model.Video +import eu.kanade.tachiyomi.lib.playlistutils.PlaylistUtils +import eu.kanade.tachiyomi.network.GET +import eu.kanade.tachiyomi.util.asJsoup +import kotlinx.serialization.Serializable +import kotlinx.serialization.json.Json +import okhttp3.Headers +import okhttp3.OkHttpClient +import okhttp3.internal.commonEmptyHeaders +import uy.kohesive.injekt.injectLazy + +class StreamSilkExtractor(private val client: OkHttpClient, private val headers: Headers = commonEmptyHeaders) { + + private val srcRegex = Regex("var urlPlay =\\s*\"(.*?m3u8.*?)\"") + + private val subsRegex = Regex("jsonUrl = `([^`]*)`") + + private val videoHeaders by lazy { + headers.newBuilder() + .set("Referer", "$STREAM_SILK_URL/") + .set("Origin", STREAM_SILK_URL) + .build() + } + + private val json: Json by injectLazy() + + private val playlistUtils by lazy { PlaylistUtils(client, videoHeaders) } + + fun videosFromUrl(url: String, prefix: String) = videosFromUrl(url) { "${prefix}StreamSilk:$it" } + + fun videosFromUrl(url: String, videoNameGen: (String) -> String = { quality -> "StreamSilk:$quality" }): List