Convert VoeExtractor to shared lib (#955)
This commit is contained in:
parent
6ee7153b74
commit
8ffca9ddcc
25
lib/voe-extractor/build.gradle.kts
Normal file
25
lib/voe-extractor/build.gradle.kts
Normal file
@ -0,0 +1,25 @@
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
kotlin("android")
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = AndroidConfig.compileSdk
|
||||
|
||||
defaultConfig {
|
||||
minSdk = AndroidConfig.minSdk
|
||||
targetSdk = AndroidConfig.targetSdk
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.kotlin.stdlib)
|
||||
compileOnly(libs.okhttp)
|
||||
compileOnly(libs.aniyomi.lib)
|
||||
compileOnly(libs.jsoup)
|
||||
}
|
||||
// BUMPS: 0
|
2
lib/voe-extractor/src/main/AndroidManifest.xml
Normal file
2
lib/voe-extractor/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,2 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="eu.kanade.tachiyomi.lib.voeextractor" />
|
@ -0,0 +1,21 @@
|
||||
package eu.kanade.tachiyomi.lib.voeextractor
|
||||
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
class VoeExtractor(private val client: OkHttpClient) {
|
||||
|
||||
fun videoFromUrl(url: String, quality: String? = null): Video? {
|
||||
val document = client.newCall(GET(url)).execute().asJsoup()
|
||||
val script = document.selectFirst("script:containsData(const sources)")
|
||||
?.data()
|
||||
?: return null
|
||||
val videoUrl = script.substringAfter("hls\": \"").substringBefore("\"")
|
||||
val resolution = script.substringAfter("video_height\": ")
|
||||
.substringBefore(",")
|
||||
val qualityStr = quality ?: "VoeCDN(${resolution}p)"
|
||||
return Video(url, qualityStr, videoUrl)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user