Skip to content

Commit ff46594

Browse files
WIP
1 parent bec2be1 commit ff46594

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

src/import/mod.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ mod har;
22

33
use crate::shared::url_file_extension;
44
use har::Har;
5-
use std::io::Result;
5+
use std::io::{Error, Result};
66
use std::path::Path;
77
use tokio::fs;
88
use url::Url;
@@ -13,10 +13,18 @@ pub async fn import_har(har: Har, dest: &Path) -> Result<()> {
1313
let spec = har.log;
1414

1515
// Find the first .m3u8 request
16-
let first_playlist_request = spec.entries.iter().find(|entry| {
17-
let url = Url::parse(&entry.request.url).unwrap();
18-
matches!(url_file_extension(&url), Some("m3u8"))
19-
});
16+
let first_playlist_request = spec
17+
.entries
18+
.iter()
19+
.find(|entry| {
20+
let url = Url::parse(&entry.request.url).unwrap();
21+
matches!(url_file_extension(&url), Some("m3u8"))
22+
})
23+
.ok_or_else(|| Error::other("no playlist found"))?;
24+
25+
let first_playlist_response = first_playlist_request.response.content.as_bytes()?;
26+
27+
dbg!(&first_playlist_response);
2028

2129
Ok(())
2230
}

src/record/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -571,21 +571,21 @@ fn media_applies_to_variant(media: &AlternativeMedia, variant_stream: &VariantSt
571571
}
572572
}
573573

574-
struct RecordingFile {
574+
pub(crate) struct RecordingFile {
575575
recording: Recording,
576576
file: fs::File,
577577
}
578578

579579
impl RecordingFile {
580-
async fn new(path: &Path) -> io::Result<Self> {
580+
pub(crate) async fn new(path: &Path) -> io::Result<Self> {
581581
let file = fs::File::create(path).await?;
582582
Ok(Self {
583583
recording: Recording::new(),
584584
file,
585585
})
586586
}
587587

588-
async fn add_and_save(
588+
pub(crate) async fn add_and_save(
589589
&mut self,
590590
time: DateTime<Utc>,
591591
playlist_name: &str,
@@ -595,7 +595,7 @@ impl RecordingFile {
595595
self.save().await
596596
}
597597

598-
async fn save(&mut self) -> io::Result<()> {
598+
pub(crate) async fn save(&mut self) -> io::Result<()> {
599599
let recording_json = serde_json::to_string_pretty(&self.recording)?;
600600
let recording_bytes = recording_json.as_bytes();
601601
self.file.rewind().await?;

0 commit comments

Comments
 (0)