@@ -4,6 +4,7 @@ use futures::future::{BoxFuture, FutureExt};
44use futures:: stream:: { StreamExt , TryStreamExt , iter} ;
55use m3u8_rs:: * ;
66use reqwest:: Client ;
7+ use reqwest:: header:: HeaderMap ;
78use std:: io;
89use std:: path:: { Path , PathBuf } ;
910use std:: sync:: Arc ;
@@ -24,14 +25,15 @@ mod rewrite;
2425
2526const MAX_CONCURRENT_DOWNLOADS : usize = 4 ;
2627
27- #[ derive( Debug , Copy , Clone ) ]
28+ #[ derive( Debug , Clone ) ]
2829pub struct RecordOptions {
2930 pub variant_select : VariantSelectOptions ,
3031 pub audio : MediaSelect ,
3132 pub video : MediaSelect ,
3233 pub subtitle : MediaSelect ,
3334 pub start : Option < f32 > ,
3435 pub end : Option < f32 > ,
36+ pub headers : HeaderMap ,
3537}
3638
3739#[ derive( thiserror:: Error , Debug ) ]
@@ -58,6 +60,7 @@ pub async fn record(
5860 let recording = Arc :: new ( Mutex :: new ( recording) ) ;
5961 let client = Client :: builder ( )
6062 . cookie_store ( true )
63+ . default_headers ( options. headers . clone ( ) )
6164 . build ( )
6265 . map_err ( |_| RecordError :: Config ( "Error while building HTTP client" ) ) ?;
6366 // Download initial playlist
@@ -177,6 +180,7 @@ async fn record_master_playlist(
177180 QuotedOrUnquoted :: Quoted ( variant_url. as_str ( ) . to_string ( ) ) ,
178181 ) ;
179182 variant. uri = format ! ( "{variant_dir}index.m3u8" ) ;
183+ let options = options. clone ( ) ;
180184 let token = token. clone ( ) ;
181185 join_set. spawn ( async move {
182186 record_media_playlist (
@@ -208,6 +212,7 @@ async fn record_master_playlist(
208212 QuotedOrUnquoted :: Quoted ( media_url. as_str ( ) . to_string ( ) ) ,
209213 ) ;
210214 media. uri = Some ( format ! ( "{media_dir}index.m3u8" ) ) ;
215+ let options = options. clone ( ) ;
211216 let token = token. clone ( ) ;
212217 join_set. spawn ( async move {
213218 record_media_playlist (
0 commit comments