[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

@ -14,7 +14,8 @@ class StreamTapeExtractor(private val client: OkHttpClient) {
val id = url.split("/").getOrNull(4) ?: return null
baseUrl + id
} else { url }
val document = client.newCall(GET(newUrl)).execute().asJsoup()
val document = client.newCall(GET(newUrl)).execute().use { it.asJsoup() }
val targetLine = "document.getElementById('robotlink')"
val script = document.selectFirst("script:containsData($targetLine)")
?.data()
@ -22,6 +23,11 @@ class StreamTapeExtractor(private val client: OkHttpClient) {
?: return null
val videoUrl = "https:" + script.substringBefore("'") +
script.substringAfter("+ ('xcd").substringBefore("'")
return Video(videoUrl, quality, videoUrl, subtitleTracks = subtitleList)
}
fun videosFromUrl(url: String, quality: String = "StreamTape", subtitleList: List<Track> = emptyList()): List<Video> {
return videoFromUrl(url, quality, subtitleList)?.let(::listOf).orEmpty()
}
}