diff --git a/Cargo.lock b/Cargo.lock index 94e9669..ed19c0c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -509,7 +509,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hlsclient" -version = "0.3.0" +version = "0.3.1" dependencies = [ "anyhow", "bytes", diff --git a/Cargo.toml b/Cargo.toml index cb57588..3ecaff0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hlsclient" -version = "0.3.0" +version = "0.3.1" edition = "2021" [dependencies] diff --git a/src/m3u8_download.rs b/src/m3u8_download.rs index dbd832b..b43cbe1 100644 --- a/src/m3u8_download.rs +++ b/src/m3u8_download.rs @@ -73,7 +73,9 @@ impl TsPart { } impl M3u8Download { - pub(super) async fn new(m3u8_data: Bytes, index_uri: Uri) -> anyhow::Result { + pub(super) async fn new( m3u8_data: Bytes + , index_uri: Uri + , time_wait: Duration ) -> anyhow::Result { let scheme = index_uri.scheme() . ok_or(anyhow!("Problem scheme in m3u8 uri"))? . to_owned(); @@ -87,7 +89,6 @@ impl M3u8Download { . to_string(); let mut ts_parts = vec![]; - let time_wait = Duration::from_secs(301); match m3u8_rs::parse_playlist(&m3u8_data) { Result::Err(e) => Err(anyhow!("m3u8 parse error: {}", e))?, diff --git a/src/main.rs b/src/main.rs index d88ac81..a21c932 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,6 +35,10 @@ struct Args { timeout: Option, #[arg(short = 'B', default_value_t = false, help = "use body timeout")] use_body_timeout: bool, + #[arg( short + , default_value_t = 301 + , help = "wait for temporary failure like 503" )] + wait: u64, #[arg(short, long)] origin: Option, #[arg(short, long)] @@ -74,6 +78,7 @@ async fn main() -> anyhow::Result<()> { let concurrency_limit = args.concurrency.unwrap_or(20); let timeout = args.timeout.unwrap_or(15); let timeout = Duration::from_secs(timeout); + let wait_time = Duration::from_secs(args.wait); let body_timeout = if args.use_body_timeout { Some(timeout) } else { @@ -104,7 +109,7 @@ async fn main() -> anyhow::Result<()> { let m3u8_data = actor.body_bytes(&m3u8_uri).await . ok_or(anyhow!("Unable to get body for: {}", m3u8_uri))?; - let mut download = M3u8Download::new(m3u8_data, m3u8_uri).await?; + let mut download = M3u8Download::new(m3u8_data, m3u8_uri, wait_time).await?; info!("Sending concurrent requests...");