Skip to content

Add support for binary responses#146

Open
breitnw wants to merge 8 commits into
vimus:masterfrom
breitnw:binary-commands
Open

Add support for binary responses#146
breitnw wants to merge 8 commits into
vimus:masterfrom
breitnw:binary-commands

Conversation

@breitnw

@breitnw breitnw commented Jun 8, 2026

Copy link
Copy Markdown

Closes #98.

This PR adds a foundation for handling MPD's binary responses. The central change I made was introducing a union data structure (ResponseEntry) which represents a single entry in an MPD response (either a line of text or a block of binary data). [ResponseEntry] ends up replacing [ByteString] in many signatures, most notably those of Parser and mpdSend. I felt that introducing a new type to distinguish text from bytes was the right choice because binary entries must be parsed immediately (in mpdSend) to prevent them from being split across multiple lines.

I've implemented the albumart command (requested in #98), as well as the readpicture and binarylimit commands.

Since I'm new to the project, I'm very open to feedback if you think anything should be improved here! Specifically, I wasn't sure whether it was the right choice to expose the ByteString as a member of AlbumArtChunk, or if some other way of exposing the raw data would be preferred.

@breitnw
breitnw marked this pull request as draft June 8, 2026 15:36
@breitnw
breitnw marked this pull request as ready for review June 8, 2026 16:43
@breitnw breitnw changed the title Add support for binary commands Add support for binary responses Jun 10, 2026
@breitnw

breitnw commented Jun 24, 2026

Copy link
Copy Markdown
Author

The last two commits add support for the readpicture command, which reads embedded album art from the song's binary tags (as opposed to albumart, which reads album art from a file)

@breitnw

breitnw commented Jun 25, 2026

Copy link
Copy Markdown
Author

I changed readPicture to return Maybe AlbumArtChunk (Just <albumart> if a binary tag containing the album art is present, Nothing if no such tag exists). This contrasts with albumArt, which returns an AlbumArtChunk and throws a FileNotFound error if the artwork file is not present. This behavior is consistent with MPD's API, though it is a bit confusing/clunky. Open to suggestions if you think it should be changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

albumart support

1 participant