-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jacherr
committed
Jun 25, 2024
1 parent
4e85999
commit 2d66dc6
Showing
4 changed files
with
89 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,50 @@ | ||
use std::time::Duration; | ||
|
||
use anyhow::Context; | ||
use assyst_proc_macro::command; | ||
|
||
use crate::command::{Availability, Category}; | ||
use crate::rest::audio_identification::identify_song_notsoidentify; | ||
|
||
use super::arguments::ImageUrl; | ||
use super::CommandCtxt; | ||
|
||
pub mod colour; | ||
pub mod translation; | ||
|
||
#[command( | ||
description = "Find a song in a video", | ||
cooldown = Duration::from_secs(2), | ||
access = Availability::Public, | ||
category = Category::Fun, | ||
usage = "[video]", | ||
examples = ["https://link.to.my/video.mp4"], | ||
send_processing = true | ||
)] | ||
pub async fn findsong(ctxt: CommandCtxt<'_>, input: ImageUrl) -> anyhow::Result<()> { | ||
let result = identify_song_notsoidentify(ctxt.assyst().clone(), input.0) | ||
.await | ||
.context("Failed to identify song")?; | ||
|
||
if result.len() > 0 { | ||
let formatted = format!( | ||
"**Title:** {}\n**Artist(s):** {}\n**YouTube Link:** <{}>", | ||
result[0].title.clone(), | ||
result[0] | ||
.artists | ||
.iter() | ||
.map(|x| x.name.clone()) | ||
.collect::<Vec<_>>() | ||
.join(", "), | ||
match &result[0].platforms.youtube { | ||
Some(x) => x.url.clone(), | ||
None => "Unknown".to_owned(), | ||
} | ||
); | ||
ctxt.reply(formatted).await?; | ||
} else { | ||
ctxt.reply("No results found").await?; | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters