pub struct Genius { /* private fields */ }
Expand description
The main hub for interacting with the Genius API
Implementations§
Source§impl Genius
impl Genius
Sourcepub fn new(token: String) -> Self
pub fn new(token: String) -> Self
Create an API Client at https://genius.com/developers and get the token to get basic Genius API access. The token will be level client.
Sourcepub async fn search(&self, q: &str) -> Result<Vec<Hit>, GeniusError>
pub async fn search(&self, q: &str) -> Result<Vec<Hit>, GeniusError>
Search for a song in Genius the result will be search::Hit
§Errors
Will return GeniusError::RequestError
if the request fails.
Will return GeniusError::Unauthorized
if the token is invalid.
Will return GeniusError::ParseError
if the response is not valid JSON if this occurs you should contact the developer.
Will return GeniusError::NotFound
if the field hits
is empty in the response if this occurs you should contact the developer.
Sourcepub async fn get_lyrics(&self, id: u32) -> Result<Vec<String>, GeniusError>
pub async fn get_lyrics(&self, id: u32) -> Result<Vec<String>, GeniusError>
Get lyrics with an url of genius song like: https://genius.com/Sia-chandelier-lyrics
§Errors
Will return GeniusError::RequestError
if the request fails.
Will return GeniusError::ParseError
if the response is not valid JSON if this occurs you should contact the developer.
Will return GeniusError::NotFound
if the field hits
is empty in the response if this occurs you should contact the developer.
Sourcepub async fn get_song(
&self,
id: u32,
text_format: &str,
) -> Result<Song, GeniusError>
pub async fn get_song( &self, id: u32, text_format: &str, ) -> Result<Song, GeniusError>
Get deeper information from a song by it’s id, text_format
is the field for the format of text bodies related to the document. Available text formats are plain
and html
§Errors
Will return GeniusError::RequestError
if the request fails.
Will return GeniusError::Unauthorized
if the token is invalid.
Will return GeniusError::ParseError
if the response is not valid JSON if this occurs you should contact the developer.
Will return GeniusError::NotFound
if the field hits
is empty in the response if this occurs you should contact the developer.
Sourcepub async fn get_album(
&self,
id: u32,
text_format: &str,
) -> Result<Album, GeniusError>
pub async fn get_album( &self, id: u32, text_format: &str, ) -> Result<Album, GeniusError>
Get deeper information from a album by it’s id, text_format
is the field for the format of text bodies related to the document. Available text formats are plain
and html
§Errors
Will return GeniusError::RequestError
if the request fails.
Will return GeniusError::Unauthorized
if the token is invalid.
Will return GeniusError::ParseError
if the response is not valid JSON if this occurs you should contact the developer.
Will return GeniusError::NotFound
if the field hits
is empty in the response if this occurs you should contact the developer.