forked from jmug/stoatchat
chore: add support for Streamable in media struct
This commit is contained in:
@@ -98,6 +98,8 @@ pub enum Special {
|
|||||||
content_type: BandcampType,
|
content_type: BandcampType,
|
||||||
id: String,
|
id: String,
|
||||||
},
|
},
|
||||||
|
/// Streamable Video
|
||||||
|
Streamable { id: String },
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Website metadata
|
/// Website metadata
|
||||||
@@ -175,7 +177,12 @@ pub enum Embed {
|
|||||||
|
|
||||||
impl Embed {
|
impl Embed {
|
||||||
/// Generate embeds from given content
|
/// 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! {
|
lazy_static! {
|
||||||
static ref RE_CODE: Regex = Regex::new("```(?:.|\n)+?```|`(?:.|\n)+?`").unwrap();
|
static ref RE_CODE: Regex = Regex::new("```(?:.|\n)+?```|`(?:.|\n)+?`").unwrap();
|
||||||
static ref RE_IGNORED: Regex = Regex::new("(<http.+>)").unwrap();
|
static ref RE_IGNORED: Regex = Regex::new("(<http.+>)").unwrap();
|
||||||
@@ -239,12 +246,7 @@ impl Embed {
|
|||||||
tasks.push(spawn(async move {
|
tasks.push(spawn(async move {
|
||||||
let guard = semaphore.acquire().await;
|
let guard = semaphore.acquire().await;
|
||||||
|
|
||||||
let response = client
|
let response = client.get(url).query(&[("url", link)]).send().await.ok()?;
|
||||||
.get(url)
|
|
||||||
.query(&[("url", link)])
|
|
||||||
.send()
|
|
||||||
.await
|
|
||||||
.ok()?;
|
|
||||||
|
|
||||||
drop(guard);
|
drop(guard);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user