refactor: Move some extractor to libraries for datalife engine multisrc (#2246)
This commit is contained in:
18
lib/streamhub-extractor/build.gradle.kts
Normal file
18
lib/streamhub-extractor/build.gradle.kts
Normal file
@ -0,0 +1,18 @@
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
kotlin("android")
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = AndroidConfig.compileSdk
|
||||
namespace = "eu.kanade.tachiyomi.lib.streamhubextractor"
|
||||
|
||||
defaultConfig {
|
||||
minSdk = AndroidConfig.minSdk
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":lib-playlist-utils"))
|
||||
compileOnly(libs.bundles.common)
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package eu.kanade.tachiyomi.lib.streamhubextractor
|
||||
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.lib.playlistutils.PlaylistUtils
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
class StreamHubExtractor(private val client: OkHttpClient) {
|
||||
|
||||
fun videosFromUrl(url: String, prefix: String = ""): List<Video> {
|
||||
val document = client.newCall(GET(url)).execute().use { it.body.string() }
|
||||
val id = Regex("urlset\\|(.*?)\\|").find(document)?.groupValues?.get(1)
|
||||
val sub = Regex("width\\|(.*?)\\|").find(document)?.groupValues?.get(1)
|
||||
val masterUrl = "https://${sub}.streamhub.ink/hls/,${id},.urlset/master.m3u8"
|
||||
return PlaylistUtils(client).extractFromHls(masterUrl, videoNameGen = { "${prefix}StreamHub - (${it})" })
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user