chore: add support for Streamable in media struct

This commit is contained in:
Paul Makles
2023-01-27 16:17:47 +00:00
parent e8c233f60b
commit a406e5504d

View File

@@ -98,6 +98,8 @@ pub enum Special {
content_type: BandcampType,
id: String,
},
/// Streamable Video
Streamable { id: String },
}
/// Website metadata
@@ -175,7 +177,12 @@ pub enum Embed {
impl Embed {
/// Generate embeds from given content
pub async fn generate(content: String, host: &str, max_embeds: usize, semaphore: Arc<Semaphore>) -> Result<Vec<Embed>> {
pub async fn generate(
content: String,
host: &str,
max_embeds: usize,
semaphore: Arc<Semaphore>,
) -> Result<Vec<Embed>> {
lazy_static! {
static ref RE_CODE: Regex = Regex::new("```(?:.|\n)+?```|`(?:.|\n)+?`").unwrap();
static ref RE_IGNORED: Regex = Regex::new("(<http.+>)").unwrap();
@@ -239,12 +246,7 @@ impl Embed {
tasks.push(spawn(async move {
let guard = semaphore.acquire().await;
let response = client
.get(url)
.query(&[("url", link)])
.send()
.await
.ok()?;
let response = client.get(url).query(&[("url", link)]).send().await.ok()?;
drop(guard);