Skip to content

Commit

Permalink
fix: Voe extractor
Browse files Browse the repository at this point in the history
- Removed `videoFromUrl`
- Added `PlaylistUtil` dependency
- Light fixes to all extensions using Voe
- Added a second "layout"(?) which uses base64 encoded json
  • Loading branch information
hollowshiroyuki committed Feb 5, 2024
1 parent 8ffc211 commit 645eda7
Show file tree
Hide file tree
Showing 41 changed files with 84 additions and 185 deletions.
4 changes: 4 additions & 0 deletions lib/voe-extractor/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
plugins {
id("lib-android")
}

dependencies {
implementation(project(":lib:playlist-utils"))
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,44 @@
package eu.kanade.tachiyomi.lib.voeextractor

import android.util.Base64
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.OkHttpClient
import uy.kohesive.injekt.injectLazy

class VoeExtractor(private val client: OkHttpClient) {
fun videoFromUrl(url: String, quality: String? = null, prefix: String = ""): Video? {

private val json: Json by injectLazy()

private val playlistUtils by lazy { PlaylistUtils(client) }

@Serializable
data class VideoLinkDTO(val file: String)

fun videosFromUrl(url: String, prefix: String = ""): List<Video> {
val document = client.newCall(GET(url)).execute().asJsoup()
val script = document.selectFirst("script:containsData(const sources), script:containsData(var sources)")
val script = document.selectFirst("script:containsData(const sources), script:containsData(var sources), script:containsData(wc0)")
?.data()
?: return null
val videoUrl = script.substringAfter("hls': '").substringBefore("'")
val resolution = script.substringAfter("video_height': ").substringBefore(",")
val qualityStr = when {
prefix.isNotEmpty() -> "$prefix${resolution}p"
else -> quality ?: "VoeCDN(${resolution}p)"
?: return emptyList()
val playlistUrl = when {
// Layout 1
script.contains("sources") -> {
script.substringAfter("hls': '").substringBefore("'")
}
// Layout 2
script.contains("wc0") -> {
val base64 = Regex("'.*'").find(script)!!.value
val decoded = Base64.decode(base64, Base64.DEFAULT).let(::String)
json.decodeFromString<VideoLinkDTO>(decoded).file
}
else -> return emptyList()
}
return Video(url, qualityStr, videoUrl)
}

fun videosFromUrl(url: String, quality: String? = null, prefix: String = ""): List<Video> {
return videoFromUrl(url, quality, prefix)?.let(::listOf).orEmpty()
return playlistUtils.extractFromHls(playlistUrl,
videoNameGen = { quality -> "${prefix}Voe: $quality" }
)
}
}
2 changes: 1 addition & 1 deletion multisrc/overrides/datalifeengine/wiflix/src/Wiflix.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Wiflix : DataLifeEngine(
contains("streamvid.net") -> StreamHideVidExtractor(client).videosFromUrl(this)
contains("upstream.to") -> UpstreamExtractor(client).videosFromUrl(this)
contains("streamdav.com") -> StreamDavExtractor(client).videosFromUrl(this)
contains("voe.sx") -> listOfNotNull(VoeExtractor(client).videoFromUrl(this))
contains("voe.sx") -> VoeExtractor(client).videosFromUrl(this)
else -> emptyList()
}
}
Expand Down
2 changes: 1 addition & 1 deletion multisrc/overrides/dooplay/kinoking/src/Kinoking.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Kinoking : DooPlay(
doodExtractor.videosFromUrl(link, quality, redirect)
}
link.contains("https://voe.sx") && hosterSelection.contains("voe") -> {
voeExtractor.videosFromUrl(link, "Voe")
voeExtractor.videosFromUrl(link)
}
link.contains("filehosted") && hosterSelection.contains("filehosted") -> {
listOf(Video(link, "Filehosted", link))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -758,8 +758,7 @@ class AutoEmbedExtractor(private val client: OkHttpClient) {
MixDropExtractor(client).videoFromUrl(videoUrl, prefix = prefix)
}
videoUrl.contains("https://voe") -> {
VoeExtractor(client).videoFromUrl(videoUrl, server.name)
?.let(::listOf)
VoeExtractor(client).videosFromUrl(videoUrl)
}
videoUrl.contains("rabbitstream") -> {
RabbitStreamExtractor(client).videosFromUrl(videoUrl, headers = videoHeaders, prefix = prefix)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class Anime4Up : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
url.contains("ok.ru") -> okruExtractor.videosFromUrl(url)
url.contains("mp4upload") -> mp4uploadExtractor.videosFromUrl(url, headers)
url.contains("uqload") -> uqloadExtractor.videosFromUrl(url)
url.contains("voe") -> voeExtractor.videoFromUrl(url)?.let(::listOf)
url.contains("voe") -> voeExtractor.videosFromUrl(url)
url.contains("shared") -> sharedExtractor.videosFromUrl(url)?.let(::listOf)
DOOD_REGEX.containsMatchIn(url) -> doodExtractor.videosFromUrl(url, "Dood mirror")
VIDBOM_REGEX.containsMatchIn(url) -> vidbomExtractor.videosFromUrl(url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class ArabSeed : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
}
"dood" in url -> doodExtractor.videosFromUrl(url)
"fviplions" in url || "wish" in url -> streamwishExtractor.videosFromUrl(url)
"voe.sx" in url -> voeExtractor.videoFromUrl(url)?.let(::listOf)
"voe.sx" in url -> voeExtractor.videosFromUrl(url)
else -> null
} ?: emptyList()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ class Okanime : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
okruExtractor.videosFromUrl(url)
}
"voe.sx" in url && selection.contains("Voe") -> {
voeExtractor.videoFromUrl(url, "VoeSX ($quality)")
?.let(::listOf)
voeExtractor.videosFromUrl(url)
}
VID_BOM_DOMAINS.any(url::contains) && selection.contains("VidBom") -> {
vidBomExtractor.videosFromUrl(url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,7 @@ class Aniflix : ConfigurableAnimeSource, AnimeHttpSource() {
}
}
link.contains("https://voe.sx") && hosterSelection?.contains("voe") == true -> {
val video = VoeExtractor(client).videoFromUrl(link, quality)
if (video != null) {
videoList.add(video)
}
videoList.addAll(VoeExtractor(client).videosFromUrl(link, "(${stream.lang}) "))
}
link.contains("https://streamlare") && hosterSelection?.contains("slare") == true -> {
videoList.addAll(StreamlareExtractor(client).videosFromUrl(link, suffix = stream.lang ?: "Unknown language"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class AnimeBase : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val url = hosterSettings.get(hoster)!! + urlpart
return when (hoster) {
"Streamwish" -> streamWishExtractor.videosFromUrl(url)
"Voe.SX" -> voeExtractor.videoFromUrl(url)?.let(::listOf)
"Voe.SX" -> voeExtractor.videosFromUrl(url)
"VTube", "Lulustream" -> unpackerExtractor.videosFromUrl(url, hoster)
"VidGuard" -> vidguardExtractor.videosFromUrl(url)
else -> null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,7 @@ class AnimeLoads : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val link = client.newCall(GET(decode)).execute().request.url.toString()
when {
hoster.contains("voesx") && hosterSelection?.contains("voe") == true -> {
val quality = "Voe Deutsch Sub"
val video = try {
VoeExtractor(client).videoFromUrl(link, quality)
} catch (e: Exception) {
null
}
if (video != null) {
videoList.add(video)
}
videoList.addAll(VoeExtractor(client).videosFromUrl(link, "(Deutsch Sub) "))
}

hoster.contains("streamtapecom") && hosterSelection?.contains("stape") == true -> {
Expand Down Expand Up @@ -267,15 +259,7 @@ class AnimeLoads : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
} else {
when {
hoster.contains("voesx") && hosterSelection?.contains("voe") == true -> {
val quality = "Voe Deutsch Sub"
val video = try {
VoeExtractor(client).videoFromUrl(leaveurl, quality)
} catch (e: Exception) {
null
}
if (video != null) {
videoList.add(video)
}
videoList.addAll(VoeExtractor(client).videosFromUrl(leaveurl, "(Deutsch Sub) "))
}

hoster.contains("streamtapecom") && hosterSelection?.contains("stape") == true -> {
Expand Down Expand Up @@ -358,15 +342,7 @@ class AnimeLoads : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val link = client.newCall(GET(decode)).execute().request.url.toString()
when {
hoster.contains("voesx") && hosterSelection?.contains("voe") == true -> {
val quality = "Voe Deutsch Sub"
val video = try {
VoeExtractor(client).videoFromUrl(link, quality)
} catch (e: Exception) {
null
}
if (video != null) {
videoList.add(video)
}
videoList.addAll(VoeExtractor(client).videosFromUrl(link, "(Deutsch Sub) "))
}

hoster.contains("streamtapecom") && hosterSelection?.contains("stape") == true -> {
Expand Down Expand Up @@ -396,15 +372,7 @@ class AnimeLoads : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
} else {
when {
hoster.contains("voesx") && hosterSelection?.contains("voe") == true -> {
val quality = "Voe Deutsch Sub"
val video = try {
VoeExtractor(client).videoFromUrl(leaveurl, quality)
} catch (e: Exception) {
null
}
if (video != null) {
videoList.add(video)
}
videoList.addAll(VoeExtractor(client).videosFromUrl(leaveurl, "(Deutsch Sub) "))
}

hoster.contains("streamtapecom") && hosterSelection?.contains("stape") == true -> {
Expand Down Expand Up @@ -549,15 +517,7 @@ class AnimeLoads : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val link = client.newCall(GET(decode)).execute().request.url.toString()
when {
hoster.contains("voesx") && hosterSelection?.contains("voe") == true -> {
val quality = "Voe Deutsch Dub"
val video = try {
VoeExtractor(client).videoFromUrl(link, quality)
} catch (e: Exception) {
null
}
if (video != null) {
videoList.add(video)
}
videoList.addAll(VoeExtractor(client).videosFromUrl(link, "(Deutsch Dub) "))
}

hoster.contains("streamtapecom") && hosterSelection?.contains("stape") == true -> {
Expand Down Expand Up @@ -587,15 +547,7 @@ class AnimeLoads : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
} else {
when {
hoster.contains("voesx") && hosterSelection?.contains("voe") == true -> {
val quality = "Voe Deutsch Dub"
val video = try {
VoeExtractor(client).videoFromUrl(leaveurl, quality)
} catch (e: Exception) {
null
}
if (video != null) {
videoList.add(video)
}
videoList.addAll(VoeExtractor(client).videosFromUrl(leaveurl, "(Deutsch Dub) "))
}

hoster.contains("streamtapecom") && hosterSelection?.contains("stape") == true -> {
Expand Down Expand Up @@ -678,15 +630,7 @@ class AnimeLoads : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
val link = client.newCall(GET(decode)).execute().request.url.toString()
when {
hoster.contains("voesx") && hosterSelection?.contains("voe") == true -> {
val quality = "Voe Deutsch Dub"
val video = try {
VoeExtractor(client).videoFromUrl(link, quality)
} catch (e: Exception) {
null
}
if (video != null) {
videoList.add(video)
}
videoList.addAll(VoeExtractor(client).videosFromUrl(link, "(Deutsch Dub) "))
}

hoster.contains("streamtapecom") && hosterSelection?.contains("stape") == true -> {
Expand Down Expand Up @@ -716,15 +660,7 @@ class AnimeLoads : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
} else {
when {
hoster.contains("voesx") && hosterSelection?.contains("voe") == true -> {
val quality = "Voe Deutsch Dub"
val video = try {
VoeExtractor(client).videoFromUrl(leaveurl, quality)
} catch (e: Exception) {
null
}
if (video != null) {
videoList.add(video)
}
videoList.addAll(VoeExtractor(client).videosFromUrl(leaveurl, "(Deutsch Dub) "))
}

hoster.contains("streamtapecom") && hosterSelection?.contains("stape") == true -> {
Expand Down
Loading

0 comments on commit 645eda7

Please sign in to comment.