forked from AlmightyHak/extensions-source
Initial commit
This commit is contained in:
commit
98ed7e8839
2263 changed files with 108711 additions and 0 deletions
9
lib/mp4upload-extractor/build.gradle.kts
Normal file
9
lib/mp4upload-extractor/build.gradle.kts
Normal file
|
@ -0,0 +1,9 @@
|
|||
plugins {
|
||||
id("lib-android")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("dev.datlag.jsunpacker:jsunpacker:1.0.1") {
|
||||
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk8")
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package eu.kanade.tachiyomi.lib.mp4uploadextractor
|
||||
|
||||
import dev.datlag.jsunpacker.JsUnpacker
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import okhttp3.Headers
|
||||
import okhttp3.OkHttpClient
|
||||
|
||||
class Mp4uploadExtractor(private val client: OkHttpClient) {
|
||||
fun videosFromUrl(url: String, headers: Headers, prefix: String = "", suffix: String = ""): List<Video> {
|
||||
val newHeaders = headers.newBuilder()
|
||||
.set("referer", REFERER)
|
||||
.build()
|
||||
|
||||
val doc = client.newCall(GET(url, newHeaders)).execute().asJsoup()
|
||||
|
||||
val script = doc.selectFirst("script:containsData(eval):containsData(p,a,c,k,e,d)")?.data()
|
||||
?.let(JsUnpacker::unpackAndCombine)
|
||||
?: doc.selectFirst("script:containsData(player.src)")?.data()
|
||||
?: return emptyList()
|
||||
|
||||
val videoUrl = script.substringAfter(".src(").substringBefore(")")
|
||||
.substringAfter("src:").substringAfter('"').substringBefore('"')
|
||||
|
||||
val resolution = QUALITY_REGEX.find(script)?.groupValues?.let { "${it[1]}p" } ?: "Unknown resolution"
|
||||
val quality = "${prefix}Mp4Upload - $resolution$suffix"
|
||||
|
||||
return listOf(Video(videoUrl, quality, videoUrl, newHeaders))
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val QUALITY_REGEX by lazy { """\WHEIGHT=(\d+)""".toRegex() }
|
||||
private const val REFERER = "https://mp4upload.com/"
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue