Skip to content

Commit eec379c

Browse files
committed
Improve SRT parser to prevent double spaces between words.
1 parent f865abd commit eec379c

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.6.6
2+
3+
- Minor bug fixes to the SRT parser.
4+
15
## 0.6.5
26

37
- Add support for PC2.0 `<podcast:block>` tag.

lib/src/model/podcast.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,7 @@ class Podcast {
203203

204204
if (rssFeed.podcastIndex!.block != null) {
205205
for (var b in rssFeed.podcastIndex!.block!) {
206-
block.add(
207-
Block(block: b?.block ?? false, id: b?.id)
208-
);
206+
block.add(Block(block: b?.block ?? false, id: b?.id));
209207
}
210208
}
211209

lib/src/utils/srt_parser.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ class SrtParser {
4444
// Some SRT can contains trailing and leading spaces; some do not!
4545
if (textLines != null) {
4646
for (var line in textLines) {
47-
if (text == "") {
48-
text = line;
49-
} else if (text.endsWith(' ') || line.startsWith(' ')) {
50-
text += line;
51-
} else {
52-
text += ' $line';
53-
}
47+
if (text.isEmpty) {
48+
text = line;
49+
} else if (text.endsWith(' ') || line.startsWith(' ')) {
50+
text += line;
51+
} else {
52+
text += ' $line';
53+
}
5454
}
5555
}
5656

@@ -68,8 +68,8 @@ class SrtParser {
6868
milliseconds: endTimeMilliseconds,
6969
);
7070

71-
var subtitle = Subtitle(
72-
index: index, start: startTime, end: endTime, data: text);
71+
var subtitle =
72+
Subtitle(index: index, start: startTime, end: endTime, data: text);
7373

7474
subtitles.add(subtitle);
7575
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: podcast_search
22
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.
33

4-
version: 0.6.5
4+
version: 0.6.6
55
homepage: https://github.com/amugofjava/podcast_search
66

77
environment:

0 commit comments

Comments
 (0)