mpd-current-json 2.0.0.1 → 2.1.0.0
raw patch · 3 files changed
+24/−7 lines, 3 files
Files
- CHANGELOG.md +3/−0
- lib/Network/MPD/Parse.hs +20/−6
- mpd-current-json.cabal +1/−1
CHANGELOG.md view
@@ -1,3 +1,6 @@+# v2.1+- Fix multi-value tag arrays being in reverse order.+ # v2.0.0.1 - Fix internal use of function unsupported in `base` version <4.19. - Add `-O2` compilation flag to cabal file that benefits from v2.0 refactor.
lib/Network/MPD/Parse.hs view
@@ -172,9 +172,15 @@ songToTagField tag song = tagSingleOrList (MPD.sgGetTag tag song) where tagSingleOrList :: Maybe [MPD.Value] -> TagField- tagSingleOrList val | fmap length val == Just 1 = SingleTagField $ singleValueToString $ listToMaybe (fromMaybe [] val)- | fmap length val > Just 1 = MultiTagField $ multiValueToString val- | otherwise = SingleTagField Nothing+ tagSingleOrList val+ | fmap length val == Just 1 =+ SingleTagField+ $ singleValueToString+ $ listToMaybe+ $ fromMaybe [] val+ | fmap length val > Just 1 =+ MultiTagField $ multiValueToString val+ | otherwise = SingleTagField Nothing {- | Convert 'Network.MPD.Value' to @String@ within a @Maybe@ context. @@ -186,10 +192,18 @@ singleValueToString (Just x) = Just (MPD.toString x) singleValueToString Nothing = Nothing --- | Same as 'singleValueToString' but converts all @Value@s in the--- multi-value-tag list to @String@ and returns the list.+{- | Same as 'singleValueToString' but converts all @Value@s in the+multi-value-tag list to @String@ and returns the list.++`reverse' is used here because multi-value tags are returned in+reverse order by [libmpd](Network.MPD), e.g. if a song has a+multi-value @artist@ tag that contains "Artist1; Artist2; Artist3",+the returned value of 'Network.MPD.Song.sgTags' from+`Network.MPD.playlistInfo' @-> [Song]@ (which is a way of fetching the+next song) would be @["Artist3", "Artist2", "Artist1"]@.+-} multiValueToString :: Maybe [MPD.Value] -> Maybe [String]-multiValueToString (Just x) = Just $ map MPD.toString x+multiValueToString (Just x) = Just $ reverse $ map MPD.toString x multiValueToString Nothing = Nothing {- | Get the current 'Network.MPD.Song' relative path with 'Network.MPD.sgFilePath'
mpd-current-json.cabal view
@@ -7,7 +7,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 2.0.0.1+version: 2.1.0.0 synopsis: Print current MPD song and status as JSON tested-with: GHC == { 9.10.1, 9.4.8 }