fixed tenshi.moe

This commit is contained in:
Arjix 2021-09-24 00:01:30 +03:00 committed by GitHub
parent f394469787
commit 565f51aaff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -290,17 +290,41 @@ class TenshiProvider : MainAPI() {
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
): Boolean { ): Boolean {
val response = khttp.get(data) val response = khttp.get(data)
val src = Jsoup.parse(response.text).selectFirst(".embed-responsive > iframe").attr("src") val soup = Jsoup.parse(response.text)
val mp4moe = Jsoup.parse(khttp.get(src, headers = mapOf("Referer" to data)).text).selectFirst("video#player")
val sources = mp4moe.select("source").map { data class Quality(
@JsonProperty("src") val src: String,
@JsonProperty("size") val size: Int
)
val sources = ArrayList<ExtractorLink>()
for (source in soup.select("""[aria-labelledby="mirror-dropdown"] > li > a.dropdown-item""")) {
val release = source.text().replace("/", "").trim()
val sourceHTML = khttp.get(
"https://tenshi.moe/embed?v=${source.attr("href").split("v=")[1].split("&")[0]}",
headers=mapOf("Referer" to data)
).text
val match = Regex("""sources: (\[(?:.|\s)+?type: ['\"]video\/.*?['\"](?:.|\s)+?\])""").find(sourceHTML)
if (match != null) {
val qualities = mapper.readValue<List<Quality>>(
match.destructured.component1()
.replace("'", "\"")
.replace(Regex("""(\w+): """), "\"\$1\": ")
.replace(Regex("""\s+"""), "")
.replace(",}", "}")
.replace(",]", "]")
)
sources.addAll(qualities.map {
ExtractorLink( ExtractorLink(
this.name, this.name,
"${this.name} - ${it.attr("title")}" + if (it.attr("title").endsWith('p')) "" else 'p', "${this.name} $release - " + it.size + "p",
fixUrl(it.attr("src")), fixUrl(it.src),
this.mainUrl, this.mainUrl,
getQualityFromName(it.attr("title")) getQualityFromName("${it.size}")
) )
})
}
} }
for (source in sources) { for (source in sources) {
@ -309,3 +333,4 @@ class TenshiProvider : MainAPI() {
return true return true
} }
} }
}