mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
fuck unicode
This commit is contained in:
parent
bb2ecce6bc
commit
038800d93a
1 changed files with 28 additions and 16 deletions
|
@ -43,26 +43,38 @@ class CustomDecoder : SubtitleDecoder {
|
||||||
data.get(arr)
|
data.get(arr)
|
||||||
data.position(pos)
|
data.position(pos)
|
||||||
|
|
||||||
val str = arr.decodeToString().trimStart()
|
//https://emptycharacter.com/
|
||||||
|
//https://www.fileformat.info/info/unicode/char/200b/index.htm
|
||||||
|
val str = arr.decodeToString().trimStart().trim('\uFEFF', '\u200B').replace(
|
||||||
|
Regex("[\u00A0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u205F]"),
|
||||||
|
" "
|
||||||
|
)
|
||||||
Log.i(TAG, "Got data from queueInputBuffer")
|
Log.i(TAG, "Got data from queueInputBuffer")
|
||||||
Log.i(TAG, "first string is $str")
|
Log.i(TAG, "first string is >>>$str<<<")
|
||||||
|
if (str.isNotEmpty()) {
|
||||||
//https://github.com/LagradOst/CloudStream-2/blob/ddd774ee66810137ff7bd65dae70bcf3ba2d2489/CloudStreamForms/CloudStreamForms/Script/MainChrome.cs#L388
|
//https://github.com/LagradOst/CloudStream-2/blob/ddd774ee66810137ff7bd65dae70bcf3ba2d2489/CloudStreamForms/CloudStreamForms/Script/MainChrome.cs#L388
|
||||||
realDecoder = when {
|
realDecoder = when {
|
||||||
str.startsWith("WEBVTT") -> WebvttDecoder()
|
str.startsWith("WEBVTT", ignoreCase = true) -> WebvttDecoder()
|
||||||
str.startsWith("<?xml version=\"") -> TtmlDecoder()
|
str.startsWith("<?xml version=\"", ignoreCase = true) -> TtmlDecoder()
|
||||||
str.startsWith("[Script Info]") || str.startsWith("Title:") -> SsaDecoder()
|
(str.startsWith(
|
||||||
str.startsWith("1") -> SubripDecoder()
|
"[Script Info]",
|
||||||
else -> null
|
ignoreCase = true
|
||||||
}
|
) || str.startsWith("Title:", ignoreCase = true)) -> SsaDecoder()
|
||||||
|
str.startsWith("1", ignoreCase = true) -> SubripDecoder()
|
||||||
realDecoder?.dequeueInputBuffer()?.let { buff ->
|
else -> null
|
||||||
buff.data = data
|
}
|
||||||
realDecoder?.queueInputBuffer(buff)
|
Log.i(
|
||||||
|
TAG,
|
||||||
|
"Decoder selected: $realDecoder"
|
||||||
|
)
|
||||||
|
realDecoder?.dequeueInputBuffer()?.let { buff ->
|
||||||
|
buff.data = data
|
||||||
|
realDecoder?.queueInputBuffer(buff)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
realDecoder?.dequeueInputBuffer()
|
realDecoder?.queueInputBuffer(inputBuffer)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
logError(e)
|
logError(e)
|
||||||
|
|
Loading…
Reference in a new issue