Skip to content

Commit

Permalink
Add regex dependency and remove EXT-X-DATE_RANGE tags
Browse files Browse the repository at this point in the history
Added regex as a new dependency in Cargo.toml. Removed EXT-X-DATE-RANGE support and related tests from the codebase. Updated Playlist parsing to process lines more efficiently using regex.
  • Loading branch information
includeamin committed Nov 5, 2024
1 parent 71a10b8 commit 14f31c0
Show file tree
Hide file tree
Showing 8 changed files with 446 additions and 646 deletions.
47 changes: 47 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ repository = "https://github.com/includeamin/m3u8-parser"
readme = "README.md"

[dependencies]
regex = "1.11.1"
34 changes: 6 additions & 28 deletions src/m3u8/playlist/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,34 +110,6 @@ impl PlaylistBuilder {
self
}

/// Adds an `ExtXDateRange` tag.
#[allow(clippy::too_many_arguments)]
pub fn date_range(
self,
id: &str,
start_date: &str,
end_date: Option<&str>,
duration: Option<f32>,
planned_duration: Option<f32>,
scte35_cmd: Option<&str>,
scte35_out: Option<&str>,
scte35_in: Option<&str>,
end_on_next: Option<bool>,
) -> Self {
self.tags.borrow_mut().push(Tag::ExtXDateRange {
id: id.to_string(),
start_date: start_date.to_string(),
end_date: end_date.map(|s| s.to_string()),
duration,
planned_duration,
scte35_cmd: scte35_cmd.map(|s| s.to_string()),
scte35_out: scte35_out.map(|s| s.to_string()),
scte35_in: scte35_in.map(|s| s.to_string()),
end_on_next,
});
self
}

/// Adds an `ExtXGap` tag.
pub fn gap(self) -> Self {
self.tags.borrow_mut().push(Tag::ExtXGap);
Expand Down Expand Up @@ -172,6 +144,9 @@ impl PlaylistBuilder {
autoplay: Option<bool>,
characteristics: Option<&str>,
language: Option<&str>,
forced: Option<bool>,
language_codec: Option<&str>,
instream_id: Option<&str>,
) -> Self {
self.tags.borrow_mut().push(Tag::ExtXMedia {
type_: type_.to_string(),
Expand All @@ -182,6 +157,9 @@ impl PlaylistBuilder {
autoplay,
characteristics: characteristics.map(|s| s.to_string()),
language: language.map(|s| s.to_string()),
instream_id: instream_id.map(|s| s.to_string()),
language_codec: language_codec.map(|s| s.to_string()),
forced,
});
self
}
Expand Down
Loading

0 comments on commit 14f31c0

Please sign in to comment.