Initial commit
This commit is contained in:
commit
98ed7e8839
2263 changed files with 108711 additions and 0 deletions
3
lib/streamtape-extractor/build.gradle.kts
Normal file
3
lib/streamtape-extractor/build.gradle.kts
Normal file
|
@ -0,0 +1,3 @@
|
|||
plugins {
|
||||
id("lib-android")
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package eu.kanade.tachiyomi.lib.streamtapeextractor
|
||||
|
||||
import eu.kanade.tachiyomi.animesource.model.Track
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
class StreamTapeExtractor(private val client: OkHttpClient) {
|
||||
fun videoFromUrl(url: String, quality: String = "Streamtape", subtitleList: List<Track> = emptyList()): Video? {
|
||||
val baseUrl = "https://streamtape.com/e/"
|
||||
val newUrl = if (!url.startsWith(baseUrl)) {
|
||||
// ["https", "", "<domain>", "<???>", "<id>", ...]
|
||||
val id = url.split("/").getOrNull(4) ?: return null
|
||||
baseUrl + id
|
||||
} else { url }
|
||||
|
||||
val document = client.newCall(GET(newUrl)).execute().asJsoup()
|
||||
val targetLine = "document.getElementById('robotlink')"
|
||||
val script = document.selectFirst("script:containsData($targetLine)")
|
||||
?.data()
|
||||
?.substringAfter("$targetLine.innerHTML = '")
|
||||
?: 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()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue