#![allow(clippy::large_enum_variant)]
use crate::error::LavalinkResult;
pub enum SearchEngines {
YouTube,
YouTubeMusic,
SoundCloud,
Spotify,
SpotifyRecommended(SpotifyRecommendedParameters),
AppleMusic,
Deezer,
DeezerISRC,
YandexMusic,
FloweryTTS(FloweryTTSParameters),
}
impl ToString for SearchEngines {
fn to_string(&self) -> String {
use SearchEngines::*;
match self {
YouTube => "ytsearch".to_string(),
YouTubeMusic => "ytmsearch".to_string(),
SoundCloud => "scsearch".to_string(),
Spotify => "spsearch".to_string(),
SpotifyRecommended(_) => "sprec".to_string(),
AppleMusic => "amsearch".to_string(),
Deezer => "dzsearch".to_string(),
DeezerISRC => "dzisrc".to_string(),
YandexMusic => "ymsearch".to_string(),
FloweryTTS(_) => "ftts://".to_string(),
}
}
}
impl SearchEngines {
pub fn to_query(&self, base_query: &str) -> LavalinkResult<String> {
use SearchEngines::*;
match self {
YouTube | YouTubeMusic | SoundCloud | Spotify | AppleMusic | Deezer | DeezerISRC
| YandexMusic => Ok(format!("{}:{}", self.to_string(), base_query)),
SpotifyRecommended(x) => {
let query = serde_qs::to_string(&x)?;
Ok(format!("{}{}?{}", self.to_string(), base_query, query))
}
FloweryTTS(x) => {
let query = serde_qs::to_string(&x)?;
Ok(format!("{}{}?{}", self.to_string(), base_query, query))
}
}
}
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[cfg_attr(feature = "python", pyo3::pyclass(get_all, set_all))]
pub struct SpotifyRecommendedParameters {
#[serde(skip_serializing_if = "Option::is_none")]
pub seed_artists: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub seed_genres: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub seed_tracks: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none")]
pub market: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub min_acousticness: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_acousticness: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub target_acousticness: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub min_danceability: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_danceability: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub target_danceability: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub min_duration_ms: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_duration_ms: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub target_duration_ms: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub min_energy: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_energy: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub target_energy: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub min_instrumentalness: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_instrumentalness: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub target_instrumentalness: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub min_key: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_key: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub target_key: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub min_liveness: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_liveness: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub target_liveness: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub min_loudness: Option<u16>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_loudness: Option<u16>,
#[serde(skip_serializing_if = "Option::is_none")]
pub target_loudness: Option<u16>,
#[serde(skip_serializing_if = "Option::is_none")]
pub min_mode: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_mode: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub target_mode: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub min_popularity: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_popularity: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none")]
pub target_popularity: Option<u8>,
#[serde(skip_serializing_if = "Option::is_none")]
pub min_speechiness: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_speechiness: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub target_speechiness: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub min_tempo: Option<u16>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_tempo: Option<u16>,
#[serde(skip_serializing_if = "Option::is_none")]
pub target_tempo: Option<u16>,
#[serde(skip_serializing_if = "Option::is_none")]
pub min_time_signature: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_time_signature: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub target_time_signature: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub min_valence: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_valence: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub target_valence: Option<f64>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[cfg_attr(feature = "python", pyo3::pyclass(get_all, set_all))]
pub struct FloweryTTSParameters {
#[serde(skip_serializing_if = "Option::is_none")]
pub voice: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub translate: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub silence: Option<u16>,
#[serde(skip_serializing_if = "Option::is_none")]
pub audio_format: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub speed: Option<f64>,
}