-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Removed `videoFromUrl` - Added `PlaylistUtil` dependency - Light fixes to all extensions using Voe - Added a second "layout"(?) which uses base64 encoded json
- Loading branch information
1 parent
8ffc211
commit 645eda7
Showing
41 changed files
with
84 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
plugins { | ||
id("lib-android") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":lib:playlist-utils")) | ||
} |
44 changes: 31 additions & 13 deletions
44
lib/voe-extractor/src/main/java/eu/kanade/tachiyomi/lib/voeextractor/VoeExtractor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" } | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.