Skip to content

Commit

Permalink
Better performance for iterating through closed captions elements. Cl…
Browse files Browse the repository at this point in the history
…oses Hexer10#251 .

Version bump
  • Loading branch information
Mattia committed Sep 12, 2023
1 parent 0919e84 commit dcedede
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.3
- Better performance for iterating through closed captions elements. #251


## 2.0.2
- Implement YT Handles.
- Deprecated ChannelLink icon's uri, they are no longer provided by YT.
Expand Down
20 changes: 11 additions & 9 deletions lib/src/videos/closed_captions/closed_caption_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,17 @@ class ClosedCaptionClient {
final response =
await re.ClosedCaptionClient.get(_httpClient, trackInfo.url);

final captions =
response.closedCaptions.where((e) => !e.text.isNullOrWhiteSpace).map(
(e) => ClosedCaption(
e.text,
e.offset,
e.duration,
e.parts.map((f) => ClosedCaptionPart(f.text, f.offset)),
),
);
final captions = [
for (final e in response.closedCaptions)
if (!e.text.isNullOrWhiteSpace)
ClosedCaption(
e.text,
e.offset,
e.duration,
e.parts.map((f) => ClosedCaptionPart(f.text, f.offset)),
),
];

return ClosedCaptionTrack(captions);
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: youtube_explode_dart
description: A port in dart of the youtube explode library. Supports several API functions without the need of Youtube API Key.
version: 2.0.2
version: 2.0.3
homepage: https://github.com/Hexer10/youtube_explode_dart

topics:
Expand Down

0 comments on commit dcedede

Please sign in to comment.