mirror of
https://github.com/recloudstream/cloudstream.git
synced 2025-05-17 19:25:55 +08:00
Fixed caption regex
This commit is contained in:
@ -89,7 +89,6 @@ class CustomDecoder(private val fallbackFormat: Format?) : SubtitleParser {
|
|||||||
RegexOption.IGNORE_CASE
|
RegexOption.IGNORE_CASE
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
val captionRegex = listOf(Regex("""(-\s?|)[\[({][\w\s]*?[])}]\s*"""))
|
|
||||||
|
|
||||||
//https://emptycharacter.com/
|
//https://emptycharacter.com/
|
||||||
//https://www.fileformat.info/info/unicode/char/200b/index.htm
|
//https://www.fileformat.info/info/unicode/char/200b/index.htm
|
||||||
@ -279,10 +278,6 @@ class CustomDecoder(private val fallbackFormat: Format?) : SubtitleParser {
|
|||||||
)
|
)
|
||||||
realDecoder?.let { decoder ->
|
realDecoder?.let { decoder ->
|
||||||
if (decoder !is SsaParser) {
|
if (decoder !is SsaParser) {
|
||||||
if (currentStyle.removeCaptions)
|
|
||||||
captionRegex.forEach { rgx ->
|
|
||||||
str = str.replace(rgx, "\n")
|
|
||||||
}
|
|
||||||
if (currentStyle.removeBloat)
|
if (currentStyle.removeBloat)
|
||||||
bloatRegex.forEach { rgx ->
|
bloatRegex.forEach { rgx ->
|
||||||
str = str.replace(rgx, "\n")
|
str = str.replace(rgx, "\n")
|
||||||
|
@ -88,6 +88,7 @@ const val DEF_SUBS_ELEVATION = 20
|
|||||||
class SubtitlesFragment : DialogFragment() {
|
class SubtitlesFragment : DialogFragment() {
|
||||||
companion object {
|
companion object {
|
||||||
val applyStyleEvent = Event<SaveCaptionStyle>()
|
val applyStyleEvent = Event<SaveCaptionStyle>()
|
||||||
|
private val captionRegex = Regex("""(-\s?|)[\[({][\S\s]*?[])}]\s*""")
|
||||||
|
|
||||||
fun setSubtitleViewStyle(view: SubtitleView?, data: SaveCaptionStyle) {
|
fun setSubtitleViewStyle(view: SubtitleView?, data: SaveCaptionStyle) {
|
||||||
if (view == null) return
|
if (view == null) return
|
||||||
@ -179,6 +180,12 @@ class SubtitlesFragment : DialogFragment() {
|
|||||||
setText(customSpan)
|
setText(customSpan)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 5. remove captions
|
||||||
|
text?.let { text ->
|
||||||
|
if (style.removeCaptions) {
|
||||||
|
setText(text.replace(captionRegex, ""))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user