Skip to content

Commit

Permalink
Allow empty yt music category
Browse files Browse the repository at this point in the history
  • Loading branch information
evanc577 committed Sep 15, 2023
1 parent 602f115 commit 2e7841a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/music/youtube/music.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl SearchType {
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
struct YTMusicSearchResult {
category: String,
category: Option<String>,
result_type: String,
video_id: Option<String>,
browse_id: Option<String>,
Expand Down Expand Up @@ -80,7 +80,13 @@ async fn search_id(query: String, search_type: SearchType) -> Result<String, Mus
// Choose the first result, giving top result priority
let result = search_results
.iter()
.filter(|r| r.category.to_lowercase() == "top result")
.filter(|r| {
if let Some(cat) = &r.category {
cat.to_lowercase() == "top result"
} else {
false
}
})
.filter_map(|r| check_results(r, &search_type))
.chain(
search_results
Expand Down

0 comments on commit 2e7841a

Please sign in to comment.