fixed #717 and regex stuff

This commit is contained in:
LagradOst 2022-02-27 02:03:01 +01:00
parent d7ffcbc996
commit 75472f5847
9 changed files with 17 additions and 20 deletions

View file

@ -35,7 +35,7 @@ class AnimePaheProvider : MainAPI() {
} }
} }
val YTSM = "ysmm = '([^']+)".toRegex() val YTSM = Regex("ysmm = '([^']+)")
val KWIK_PARAMS_RE = Regex("""\("(\w+)",\d+,"(\w+)",(\d+),(\d+),\d+\)""") val KWIK_PARAMS_RE = Regex("""\("(\w+)",\d+,"(\w+)",(\d+),(\d+),\d+\)""")
val KWIK_D_URL = Regex("action=\"([^\"]+)\"") val KWIK_D_URL = Regex("action=\"([^\"]+)\"")
@ -264,11 +264,11 @@ class AnimePaheProvider : MainAPI() {
} }
val episodes = generateListOfEpisodes(url) val episodes = generateListOfEpisodes(url)
val year = """<strong>Aired:</strong>[^,]*, (\d+)""".toRegex() val year = Regex("""<strong>Aired:</strong>[^,]*, (\d+)""")
.find(html)!!.destructured.component1() .find(html)!!.destructured.component1()
.toIntOrNull() .toIntOrNull()
val status = val status =
when ("""<strong>Status:</strong>[^a]*a href=["']/anime/(.*?)["']""".toRegex() when (Regex("""<strong>Status:</strong>[^a]*a href=["']/anime/(.*?)["']""")
.find(html)!!.destructured.component1()) { .find(html)!!.destructured.component1()) {
"airing" -> ShowStatus.Ongoing "airing" -> ShowStatus.Ongoing
"completed" -> ShowStatus.Completed "completed" -> ShowStatus.Completed

View file

@ -125,9 +125,9 @@ class NineAnimeProvider : MainAPI() {
private fun ze(input: String): String { private fun ze(input: String): String {
val t = if (input.replace("""[\t\n\f\r]""".toRegex(), "").length % 4 == 0) { val t = if (input.replace("""[\t\n\f\r]""".toRegex(), "").length % 4 == 0) {
input.replace("""/==?$/""".toRegex(), "") input.replace(Regex("""/==?$/"""), "")
} else input } else input
if (t.length % 4 == 1 || t.contains("""[^+/0-9A-Za-z]""".toRegex())) throw Exception("bad input") if (t.length % 4 == 1 || t.contains(Regex("""[^+/0-9A-Za-z]"""))) throw Exception("bad input")
var i: Int var i: Int
var r = "" var r = ""
var e = 0 var e = 0

View file

@ -284,7 +284,7 @@ class TenshiProvider : MainAPI() {
document.selectFirst("span.value > span[title=\"Japanese\"]")?.parent()?.text() document.selectFirst("span.value > span[title=\"Japanese\"]")?.parent()?.text()
?.trim() ?.trim()
val pattern = "(\\d{4})".toRegex() val pattern = Regex("(\\d{4})")
val yearText = document.selectFirst("li.release-date .value").text() val yearText = document.selectFirst("li.release-date .value").text()
year = pattern.find(yearText)?.groupValues?.get(1)?.toIntOrNull() year = pattern.find(yearText)?.groupValues?.get(1)?.toIntOrNull()

View file

@ -54,7 +54,7 @@ class WcoProvider : MainAPI() {
val title = nameHeader.text().replace(" (Dub)", "") val title = nameHeader.text().replace(" (Dub)", "")
val href = val href =
nameHeader.attr("href").replace("/watch/", "/anime/") nameHeader.attr("href").replace("/watch/", "/anime/")
.replace("-episode-.*".toRegex(), "/") .replace(Regex("-episode-.*"), "/")
val isDub = val isDub =
filmPoster.selectFirst("> div.film-poster-quality")?.text()?.contains("DUB") filmPoster.selectFirst("> div.film-poster-quality")?.text()?.contains("DUB")
?: false ?: false

View file

@ -5,7 +5,7 @@ object M3u8Manifest {
// URL = first, QUALITY = second // URL = first, QUALITY = second
fun extractLinks(m3u8Data: String): ArrayList<Pair<String, String>> { fun extractLinks(m3u8Data: String): ArrayList<Pair<String, String>> {
val data: ArrayList<Pair<String, String>> = ArrayList() val data: ArrayList<Pair<String, String>> = ArrayList()
"\"(.*?)\":\"(.*?)\"".toRegex().findAll(m3u8Data).forEach { Regex("\"(.*?)\":\"(.*?)\"").findAll(m3u8Data).forEach {
var quality = it.groupValues[1].replace("auto", "Auto") var quality = it.groupValues[1].replace("auto", "Auto")
if (quality != "Auto" && !quality.endsWith('p')) quality += "p" if (quality != "Auto" && !quality.endsWith('p')) quality += "p"
val url = it.groupValues[2] val url = it.groupValues[2]

View file

@ -20,8 +20,8 @@ open class WcoStream : ExtractorApi() {
val baseUrl = url.split("/e/")[0] val baseUrl = url.split("/e/")[0]
val html = app.get(url, headers = mapOf("Referer" to "https://wcostream.cc/")).text val html = app.get(url, headers = mapOf("Referer" to "https://wcostream.cc/")).text
val (Id) = ("/e/(.*?)?domain".toRegex().find(url)?.destructured ?: Regex("""/e/(.*)""").find(url)?.destructured) ?: return emptyList() val (Id) = (Regex("/e/(.*?)?domain").find(url)?.destructured ?: Regex("""/e/(.*)""").find(url)?.destructured) ?: return emptyList()
val (skey) = """skey\s=\s['"](.*?)['"];""".toRegex().find(html)?.destructured ?: return emptyList() val (skey) = Regex("""skey\s=\s['"](.*?)['"];""").find(html)?.destructured ?: return emptyList()
val apiLink = "$baseUrl/info/$Id?domain=wcostream.cc&skey=$skey" val apiLink = "$baseUrl/info/$Id?domain=wcostream.cc&skey=$skey"
val referrer = "$baseUrl/e/$Id?domain=wcostream.cc" val referrer = "$baseUrl/e/$Id?domain=wcostream.cc"

View file

@ -39,9 +39,9 @@ class HDMProvider : MainAPI() {
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
): Boolean { ): Boolean {
if (data == "") return false if (data == "") return false
val slug = ".*/(.*?)\\.mp4".toRegex().find(data)?.groupValues?.get(1) ?: return false val slug = Regex(".*/(.*?)\\.mp4").find(data)?.groupValues?.get(1) ?: return false
val response = app.get(data).text val response = app.get(data).text
val key = "playlist\\.m3u8(.*?)\"".toRegex().find(response)?.groupValues?.get(1) ?: return false val key = Regex("playlist\\.m3u8(.*?)\"").find(response)?.groupValues?.get(1) ?: return false
callback.invoke( callback.invoke(
ExtractorLink( ExtractorLink(
this.name, this.name,

View file

@ -102,7 +102,7 @@ class CS3IPlayer : IPlayer {
playerPositionChanged: ((Pair<Long, Long>) -> Unit)?, playerPositionChanged: ((Pair<Long, Long>) -> Unit)?,
nextEpisode: (() -> Unit)?, nextEpisode: (() -> Unit)?,
prevEpisode: (() -> Unit)?, prevEpisode: (() -> Unit)?,
subtitlesUpdates: (() -> Unit)? subtitlesUpdates: (() -> Unit)?,
) { ) {
this.playerUpdated = playerUpdated this.playerUpdated = playerUpdated
this.updateIsPlaying = updateIsPlaying this.updateIsPlaying = updateIsPlaying
@ -617,10 +617,7 @@ class CS3IPlayer : IPlayer {
} }
//override fun onCues(cues: MutableList<Cue>) { //override fun onCues(cues: MutableList<Cue>) {
// cues.firstOrNull()?.text?.let { // super.onCues(cues.map { cue -> cue.buildUpon().setText("Hello world").setSize(Cue.DIMEN_UNSET).build() })
// println("CUE: $it")
// }
// super.onCues(cues)
//} //}
override fun onRenderedFirstFrame() { override fun onRenderedFirstFrame() {

View file

@ -308,7 +308,7 @@ open class NonFinalTextRenderer @JvmOverloads constructor(
} }
private fun invokeUpdateOutputInternal(cues: List<Cue>) { private fun invokeUpdateOutputInternal(cues: List<Cue>) {
output.onCues(cues) output.onCues(cues.map { cue -> cue.buildUpon().setSize(Cue.DIMEN_UNSET).build() }) // this fixes https://github.com/LagradOst/CloudStream-3/issues/717
} }
/** /**