mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
fixed #717 and regex stuff
This commit is contained in:
parent
d7ffcbc996
commit
75472f5847
9 changed files with 17 additions and 20 deletions
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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()
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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]
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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
|
||||||
|
@ -218,7 +218,7 @@ class CS3IPlayer : IPlayer {
|
||||||
} ?: false
|
} ?: false
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentSubtitleOffset : Long = 0
|
var currentSubtitleOffset: Long = 0
|
||||||
|
|
||||||
override fun setSubtitleOffset(offset: Long) {
|
override fun setSubtitleOffset(offset: Long) {
|
||||||
currentSubtitleOffset = offset
|
currentSubtitleOffset = offset
|
||||||
|
@ -419,7 +419,7 @@ class CS3IPlayer : IPlayer {
|
||||||
currentWindow: Int,
|
currentWindow: Int,
|
||||||
playbackPosition: Long,
|
playbackPosition: Long,
|
||||||
playBackSpeed: Float,
|
playBackSpeed: Float,
|
||||||
subtitleOffset : Long,
|
subtitleOffset: Long,
|
||||||
playWhenReady: Boolean = true,
|
playWhenReady: Boolean = true,
|
||||||
cacheFactory: CacheDataSource.Factory? = null,
|
cacheFactory: CacheDataSource.Factory? = null,
|
||||||
trackSelector: TrackSelector? = null,
|
trackSelector: TrackSelector? = null,
|
||||||
|
@ -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() {
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue