diff options
Diffstat (limited to '')
-rw-r--r-- | yt/src/description/mod.rs | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/yt/src/description/mod.rs b/yt/src/description/mod.rs index 527fa8e..10f0e0c 100644 --- a/yt/src/description/mod.rs +++ b/yt/src/description/mod.rs @@ -22,26 +22,27 @@ use anyhow::{bail, Result}; use yt_dlp::wrapper::info_json::InfoJson; pub async fn description(app: &App) -> Result<()> { - let description = { - let currently_playing_video: Video = - if let Some(video) = get_currently_playing_video(app).await? { - video - } else { - bail!("Could not find a currently playing video!"); - }; + let description = get(app).await?; + display_fmt_and_less(description).await?; - let info_json: InfoJson = get_video_info_json(¤tly_playing_video) - .await? - .unreachable( - "A currently *playing* must be cached. And thus the info.json should be available", - ); + Ok(()) +} - info_json - .description - .unwrap_or("<No description>".to_owned()) - }; +pub async fn get(app: &App) -> Result<String> { + let currently_playing_video: Video = + if let Some(video) = get_currently_playing_video(app).await? { + video + } else { + bail!("Could not find a currently playing video!"); + }; - display_fmt_and_less(description).await?; + let info_json: InfoJson = get_video_info_json(¤tly_playing_video) + .await? + .unreachable( + "A currently *playing* must be cached. And thus the info.json should be available", + ); - Ok(()) + Ok(info_json + .description + .unwrap_or("<No description>".to_owned())) } |