Skip to content

Commit f67b7c9

Browse files
WIP
1 parent 99b042d commit f67b7c9

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
@@ -590,21 +590,21 @@ fn media_applies_to_variant(media: &AlternativeMedia, variant_stream: &VariantSt
590590
}
591591
}
592592

593-
struct RecordingFile {
593+
pub(crate) struct RecordingFile {
594594
recording: Recording,
595595
file: fs::File,
596596
}
597597

598598
impl RecordingFile {
599-
async fn new(path: &Path) -> io::Result<Self> {
599+
pub(crate) async fn new(path: &Path) -> io::Result<Self> {
600600
let file = fs::File::create(path).await?;
601601
Ok(Self {
602602
recording: Recording::new(),
603603
file,
604604
})
605605
}
606606

607-
async fn add_and_save(
607+
pub(crate) async fn add_and_save(
608608
&mut self,
609609
time: DateTime<Utc>,
610610
playlist_name: &str,
@@ -614,7 +614,7 @@ impl RecordingFile {
614614
self.save().await
615615
}
616616

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

0 commit comments

Comments
 (0)