Browse Source

git wait time via cli

main
Georg Hopp 11 months ago
parent
commit
3590a69bd2
Signed by: ghopp GPG Key ID: 4C5D226768784538
  1. 2
      Cargo.lock
  2. 2
      Cargo.toml
  3. 5
      src/m3u8_download.rs
  4. 7
      src/main.rs

2
Cargo.lock

@ -509,7 +509,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "hlsclient"
version = "0.3.0"
version = "0.3.1"
dependencies = [
"anyhow",
"bytes",

2
Cargo.toml

@ -1,6 +1,6 @@
[package]
name = "hlsclient"
version = "0.3.0"
version = "0.3.1"
edition = "2021"
[dependencies]

5
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<Self> {
pub(super) async fn new( m3u8_data: Bytes
, index_uri: Uri
, time_wait: Duration ) -> anyhow::Result<Self> {
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))?,

7
src/main.rs

@ -35,6 +35,10 @@ struct Args {
timeout: Option<u64>,
#[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<String>,
#[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...");

Loading…
Cancel
Save