diff options
| author | Felix Kaaman <tmtu@tmtu.ee> | 2020-02-22 23:27:01 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-22 23:27:01 +0100 |
| commit | 763b8c6579f3ae571f7287c72b9fb4f8b6e89349 (patch) | |
| tree | bc55a0e79107a93bc3e605a0cae32926dc4c52fc /src/youtube_dl.rs | |
| parent | 2792ba9c8a7120a91b3bd2c6075e737690e73405 (diff) | |
| parent | 326cfa543c6263818aad7dec4a869bc8139ec14c (diff) | |
| download | pokebot-763b8c6579f3ae571f7287c72b9fb4f8b6e89349.tar.gz pokebot-763b8c6579f3ae571f7287c72b9fb4f8b6e89349.zip | |
Merge pull request #33 from Mavulp/webserver
Webserver
Diffstat (limited to 'src/youtube_dl.rs')
| -rw-r--r-- | src/youtube_dl.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/youtube_dl.rs b/src/youtube_dl.rs index c6012f0..89b1477 100644 --- a/src/youtube_dl.rs +++ b/src/youtube_dl.rs @@ -1,3 +1,5 @@ +use std::time::Duration; + use futures::compat::Future01CompatExt; use std::process::{Command, Stdio}; use tokio_process::CommandExt; @@ -9,7 +11,22 @@ use log::debug; #[derive(Serialize, Deserialize, Clone, Debug)] pub struct AudioMetadata { pub url: String, - pub title: Option<String>, + pub webpage_url: String, + pub title: String, + pub thumbnail: Option<String>, + #[serde(default, deserialize_with = "duration_deserialize")] + pub duration: Option<Duration>, + #[serde(skip)] + pub added_by: String, +} + +fn duration_deserialize<'de, D>(deserializer: D) -> Result<Option<Duration>, D::Error> +where + D: serde::Deserializer<'de>, +{ + let dur: Option<f64> = Deserialize::deserialize(deserializer)?; + + Ok(dur.map(|v| Duration::from_secs_f64(v))) } pub async fn get_audio_download_url(uri: String) -> Result<AudioMetadata, String> { |
