From 4f250b537536ca3037fb133f5683c276d0d28c74 Mon Sep 17 00:00:00 2001 From: trivernis Date: Tue, 20 Apr 2021 22:16:38 +0200 Subject: [PATCH] Fix database loaded songs not having a thumbnail Signed-off-by: trivernis --- src/commands/music/mod.rs | 10 ++++++---- src/providers/music/queue.rs | 10 +++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/commands/music/mod.rs b/src/commands/music/mod.rs index 3ff6b3e..1e011c2 100644 --- a/src/commands/music/mod.rs +++ b/src/commands/music/mod.rs @@ -289,16 +289,18 @@ async fn get_youtube_song_for_track(database: &Database, track: Track) -> BotRes if let Some(id) = track.id { let entry = database.get_song(&id).await?; - if let Some(song) = &entry { + if let Some(song) = entry { // check if the video is still available - if get_video_information(&song.url).await.is_err() { + log::trace!("Found entry is {:?}", song); + if let Ok(info) = get_video_information(&song.url).await { + return Ok(Some(info.into())); + } else { log::debug!("Video '{}' is not available. Deleting entry", song.url); database.delete_song(song.id).await?; return Ok(None); } } - log::trace!("Found entry is {:?}", entry); - Ok(entry.map(Song::from)) + Ok(None) } else { log::debug!("Track has no ID"); Ok(None) diff --git a/src/providers/music/queue.rs b/src/providers/music/queue.rs index cd9f375..d4cee95 100644 --- a/src/providers/music/queue.rs +++ b/src/providers/music/queue.rs @@ -85,11 +85,11 @@ pub enum SongSource { #[derive(Clone, Debug)] pub struct Song { - url: Option, - title: String, - author: String, - thumbnail: Option, - source: SongSource, + pub(crate) url: Option, + pub(crate) title: String, + pub(crate) author: String, + pub(crate) thumbnail: Option, + pub(crate) source: SongSource, } impl Song {