Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Bilingual subtitles cannot be parsed #91

Open
SX-Code opened this issue Aug 17, 2024 · 0 comments
Open

fix: Bilingual subtitles cannot be parsed #91

SX-Code opened this issue Aug 17, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@SX-Code
Copy link

SX-Code commented Aug 17, 2024

Description
The following situations cannot be parsed correctly.

1

00:00:01,650 --> 00:00:02,450

贝蒂

Betty?



2

00:00:03,150 --> 00:00:04,830

现在是不是

Isn't it time for...

Solution
add parse lines *(\r\n|\r|\n)(?:.*).

regExp = RegExp(
  r'((\d{2}):(\d{2}):(\d{2})\,(\d+)) +--> +((\d{2}):(\d{2}):(\d{2})\,(\d{3})).*[\r\n]+\s*((?:(?!\r?\n\r?).)*(\r\n|\r|\n)(?:.*)*(\r\n|\r|\n)(?:.*))',
  caseSensitive: false,
  multiLine: true,
);

String _removeEmptyLines(String content) {
  List<String> lines = content.split("\r");
  lines.removeWhere((line) => line.trim().isEmpty);
  return lines.join('\r');
}

final text = _removeEmptyLines(removeAllHtmlTags(regExpMatch.group(11)!));

use.
lib/data/repository/subtitle_repository.dart.getSubtitlesData()

regExp = RegExp(
  r'((\d{2}):(\d{2}):(\d{2})\,(\d+)) +--> +((\d{2}):(\d{2}):(\d{2})\,(\d{3})).*[\r\n]+\s*((?:(?!\r?\n\r?).)*(\r\n|\r|\n)(?:.*)*(\r\n|\r|\n)(?:.*))',
  caseSensitive: false,
  multiLine: true,
);

final text = _removeEmptyLines(removeAllHtmlTags(regExpMatch.group(11)!));
@SX-Code SX-Code added the bug Something isn't working label Aug 17, 2024
@SX-Code SX-Code changed the title fix: Remove blank lines before parsing the subtitle file fix: Remove blank lines before parsing the remote subtitle file Aug 17, 2024
@SX-Code SX-Code changed the title fix: Remove blank lines before parsing the remote subtitle file fix: Bilingual subtitles cannot be parsed Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant