File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33use crate :: shared:: url_file_extension;
44use har:: Har ;
5- use std:: io:: Result ;
5+ use std:: io:: { Error , Result } ;
66use std:: path:: Path ;
77use tokio:: fs;
88use 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}
Original file line number Diff line number Diff 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
579579impl 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 ?;
You can’t perform that action at this time.
0 commit comments