Skip to content

Commit

Permalink
fix crash on starup when a song doesn't have tags (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
mamantoha authored Aug 6, 2020
1 parent 3bc63b0 commit 018d314
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/mpd.cr
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,15 @@ struct Peridot::MPD::Library

private def get_song(song : LibMpdClient::MpdSong*) : Peridot::MPD::Library::Song
uri = String.new(LibMpdClient.mpd_song_get_uri(song))
title = String.new(LibMpdClient.mpd_song_get_tag(song, LibMpdClient::MpdTagType::MPD_TAG_TITLE, 0))
album = String.new(LibMpdClient.mpd_song_get_tag(song, LibMpdClient::MpdTagType::MPD_TAG_ALBUM, 0))
artist = String.new(LibMpdClient.mpd_song_get_tag(song, LibMpdClient::MpdTagType::MPD_TAG_ARTIST, 0))

title = LibMpdClient.mpd_song_get_tag(song, LibMpdClient::MpdTagType::MPD_TAG_TITLE, 0)
album = LibMpdClient.mpd_song_get_tag(song, LibMpdClient::MpdTagType::MPD_TAG_ALBUM, 0)
artist = LibMpdClient.mpd_song_get_tag(song, LibMpdClient::MpdTagType::MPD_TAG_ARTIST, 0)

title = (title.null?) ? "-" : String.new(title)
album = (album.null?) ? "" : String.new(album)
artist = (artist.null?) ? "" : String.new(artist)

Peridot::MPD::Library::Song.new(uri, title, album, artist)
end

Expand Down

0 comments on commit 018d314

Please sign in to comment.