feat(input): Support HLS streams (#242)

This patch adds support for yt-dl streams with the protocol m3u8_native which includes sites like Soundcloud.

Closes: #241
This commit is contained in:
Erk
2024-07-07 19:37:25 +02:00
committed by GitHub
parent 2e683380fa
commit 8e92c49b2b
8 changed files with 187 additions and 18 deletions

View File

@@ -16,6 +16,8 @@ use std::{error::Error, io::ErrorKind};
use symphonia_core::io::MediaSource;
use tokio::process::Command;
use super::HlsRequest;
const YOUTUBE_DL_COMMAND: &str = "yt-dlp";
#[derive(Clone, Debug)]
@@ -194,14 +196,23 @@ impl Compose for YoutubeDl {
}));
}
let mut req = HttpRequest {
client: self.client.clone(),
request: result.url,
headers,
content_length: result.filesize,
};
req.create_async().await
#[allow(clippy::single_match_else)]
match result.protocol.as_deref() {
Some("m3u8_native") => {
let mut req =
HlsRequest::new_with_headers(self.client.clone(), result.url, headers);
req.create()
},
_ => {
let mut req = HttpRequest {
client: self.client.clone(),
request: result.url,
headers,
content_length: result.filesize,
};
req.create_async().await
},
}
}
fn should_create_async(&self) -> bool {