Skip to content

Commit

Permalink
Improve SRT parser to prevent double spaces between words.
Browse files Browse the repository at this point in the history
  • Loading branch information
amugofjava committed Jan 12, 2024
1 parent f865abd commit eec379c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.6.6

- Minor bug fixes to the SRT parser.

## 0.6.5

- Add support for PC2.0 `<podcast:block>` tag.
Expand Down
4 changes: 1 addition & 3 deletions lib/src/model/podcast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,7 @@ class Podcast {

if (rssFeed.podcastIndex!.block != null) {
for (var b in rssFeed.podcastIndex!.block!) {
block.add(
Block(block: b?.block ?? false, id: b?.id)
);
block.add(Block(block: b?.block ?? false, id: b?.id));
}
}

Expand Down
18 changes: 9 additions & 9 deletions lib/src/utils/srt_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ class SrtParser {
// Some SRT can contains trailing and leading spaces; some do not!
if (textLines != null) {
for (var line in textLines) {
if (text == "") {
text = line;
} else if (text.endsWith(' ') || line.startsWith(' ')) {
text += line;
} else {
text += ' $line';
}
if (text.isEmpty) {
text = line;
} else if (text.endsWith(' ') || line.startsWith(' ')) {
text += line;
} else {
text += ' $line';
}
}
}

Expand All @@ -68,8 +68,8 @@ class SrtParser {
milliseconds: endTimeMilliseconds,
);

var subtitle = Subtitle(
index: index, start: startTime, end: endTime, data: text);
var subtitle =
Subtitle(index: index, start: startTime, end: endTime, data: text);

subtitles.add(subtitle);
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: podcast_search
description: A library for searching for podcasts and parsing podcast RSS feeds. Supports iTunes and PodcastIndex directories, and newer features such as chapters and transcripts.

version: 0.6.5
version: 0.6.6
homepage: https://github.com/amugofjava/podcast_search

environment:
Expand Down

0 comments on commit eec379c

Please sign in to comment.