From a1be864feaf4ea478a569045f62aeb2fbbefb1fb Mon Sep 17 00:00:00 2001 From: Yuriy Liskov Date: Mon, 4 Aug 2025 00:03:56 +0300 Subject: [PATCH] ttml subtitles: repeated lines fix --- .../common/exoplayer/other/SubtitleManager.java | 10 +++++++--- smarttubetv/build.gradle | 4 ++-- smarttubetv/multidex-keep.pro | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/exoplayer/other/SubtitleManager.java b/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/exoplayer/other/SubtitleManager.java index 5961cff73..7b0c1b8e7 100644 --- a/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/exoplayer/other/SubtitleManager.java +++ b/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/exoplayer/other/SubtitleManager.java @@ -101,11 +101,15 @@ public class SubtitleManager implements TextOutput, OnDataChange { for (Cue cue : cues) { // Autogenerated subs repeated lines fix - // if (cue.text.toString().endsWith("\n")) { - if (Helpers.endsWithAny(cue.text.toString(), "\n", " ")) { + String textStr = cue.text.toString(); + if (Helpers.endsWithAny(textStr, "\n", " ")) { // vtt subs format subsBuffer = cue.text; + } else if (textStr.contains("\n")) { // ttml subs format + String[] split = textStr.split("\n"); + CharSequence text = split.length == 2 ? split[1] : cue.text; + result.add(new Cue(text)); // sub centered by default } else { - CharSequence text = subsBuffer != null ? cue.text.toString().replace(subsBuffer, "") : cue.text; + CharSequence text = subsBuffer != null ? textStr.replace(subsBuffer, "") : cue.text; result.add(new Cue(text)); // sub centered by default subsBuffer = null; } diff --git a/smarttubetv/build.gradle b/smarttubetv/build.gradle index 2e7d480a5..1957fa471 100644 --- a/smarttubetv/build.gradle +++ b/smarttubetv/build.gradle @@ -60,8 +60,8 @@ android { applicationId "com.liskovsoft.smarttubetv" minSdkVersion project.properties.minSdkVersion targetSdkVersion project.properties.targetSdkVersion - versionCode 2088 - versionName "28.98" + versionCode 2089 + versionName "28.99" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" buildConfigField "long", "TIMESTAMP", System.currentTimeMillis() + "L" diff --git a/smarttubetv/multidex-keep.pro b/smarttubetv/multidex-keep.pro index 73b11ffbc..a7d034239 100644 --- a/smarttubetv/multidex-keep.pro +++ b/smarttubetv/multidex-keep.pro @@ -1,5 +1,5 @@ --keep class com.liskovsoft.smartyoutubetv2.common.app.models.playback.controllers.VideoStateController --keep class com.liskovsoft.smartyoutubetv2.tv.ui.browse.BrowseSectionFragmentFactory +-keepnames class com.liskovsoft.smartyoutubetv2.common.app.models.playback.controllers.VideoStateController +-keepnames class com.liskovsoft.smartyoutubetv2.tv.ui.browse.BrowseSectionFragmentFactory -keepclassmembers class androidx.room.RoomDatabase { androidx.sqlite.db.SupportSQLiteDatabase mDatabase; (...);