[skip ci] refactor(lib): Refactor some libraries (#2454)

This commit is contained in:
Claudemirovsky
2023-11-01 10:44:08 -03:00
committed by GitHub
parent e3afbe20eb
commit 9db910eca1
27 changed files with 152 additions and 329 deletions

View File

@ -6,12 +6,17 @@ import eu.kanade.tachiyomi.network.GET
import okhttp3.OkHttpClient
class VidoExtractor(private val client: OkHttpClient) {
companion object {
private const val VIDO_URL = "https://pink.vido.lol"
private val REGEX_ID = Regex("master\\|(.*?)\\|")
}
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("master\\|(.*?)\\|").find(document)?.groupValues?.get(1)
val masterUrl = "https://pink.vido.lol/hls/${id}/master.m3u8"
return PlaylistUtils(client).extractFromHls(masterUrl, videoNameGen = { "${prefix}Vido - (${it})" })
val id = REGEX_ID.find(document)?.groupValues?.get(1)
val masterUrl = "$VIDO_URL/hls/${id}/master.m3u8"
return playlistUtils.extractFromHls(masterUrl, videoNameGen = { "${prefix}Vido - (${it})" })
}
}