[skip ci] refactor(lib): Refactor some libraries (#2454)
This commit is contained in:
@ -6,13 +6,18 @@ import eu.kanade.tachiyomi.network.GET
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
class StreamHubExtractor(private val client: OkHttpClient) {
|
||||
private val playlistUtils by lazy { PlaylistUtils(client) }
|
||||
|
||||
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 id = REGEX_ID.find(document)?.groupValues?.get(1)
|
||||
val sub = REGEX_SUB.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})" })
|
||||
return playlistUtils.extractFromHls(masterUrl, videoNameGen = { "${prefix}StreamHub - (${it})" })
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val REGEX_ID = Regex("urlset\\|(.*?)\\|")
|
||||
private val REGEX_SUB = Regex("width\\|(.*?)\\|")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user