Skip to content

Commit

Permalink
Cleanup lyrics::get_song_id
Browse files Browse the repository at this point in the history
  • Loading branch information
Insprill committed May 7, 2023
1 parent e558704 commit 574ddb8
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/lyrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,15 @@ pub async fn lyrics(info: web::Query<LyricsQuery>) -> Result<impl Responder> {
}

fn get_song_id(document: &Html) -> crate::Result<u32> {
let meta = document
Ok(document
.select(&SONG_ID_SELECTOR)
.next()
.ok_or("Failed to find meta tag with song ID")?;
let id = meta
.ok_or("Failed to find meta tag with song ID")?
.value()
.attr("content")
.and_then(|content| content.strip_prefix("genius://songs/"))
.ok_or("Failed to find content attribute")?
.parse::<u32>()?;
Ok(id)
.parse::<u32>()?)
}

fn scrape_lyrics(document: &Html) -> Vec<Verse> {
Expand Down

0 comments on commit 574ddb8

Please sign in to comment.