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