add readpicture
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b2f47c9..cae0d04 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,8 @@
* Tested with Ruby 3.1
* Add `albumart` command
+* Add `readpicture` command
+
## 0.1.0
* Rename `MPDClient` to `MPD::Client`
diff --git a/README.md b/README.md
index 2ff751e..497a285 100644
--- a/README.md
+++ b/README.md
@@ -77,9 +77,9 @@ client = MPD::Client.new
client.connect('localhost', 6600)
if (current_song = client.currentsong)
- data, io = client.albumart(current_song['file'])
+ data, io = client.readpicture(current_song['file'])
io # StringIO
- data # => {"size"=>"322860", "binary"=>"3372"}
+ data # => {"size"=>"322860", "type"=>"image/jpeg", "binary"=>"3372"}
File.write('cover.jpg', io.string)
end
```
diff --git a/examples/albumart.rb b/examples/albumart.rb
index 5090ca5..6e81635 100644
--- a/examples/albumart.rb
+++ b/examples/albumart.rb
@@ -12,7 +12,7 @@ client = MPD::Client.new
client.connect('localhost', 6600)
if (current_song = client.currentsong)
- data, io = client.albumart(current_song['file'])
+ data, io = client.readpicture(current_song['file'])
puts data
File.write('cover.jpg', io.string)
end
diff --git a/lib/mpd_client.rb b/lib/mpd_client.rb
index c57b9dc..b38076e 100644
--- a/lib/mpd_client.rb
+++ b/lib/mpd_client.rb
@@ -249,6 +249,10 @@ module MPD
fetch_binary(StringIO.new, 0, 'albumart', uri)
end
+ def readpicture(uri)
+ fetch_binary(StringIO.new, 0, 'readpicture', uri)
+ end
+
private
def ensure_connected