summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2009-08-01 14:19:00 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2009-08-01 14:19:00 -0700
commit06d341e4590766ca2cd0770590758d49dde7f7ba (patch)
tree5ec8de82d74f4cc327c2877dd3436ad1f8efed46
parent4759ff3b3c5fe12b880d03effdbba3426f21aab1 (diff)
downloadruby-libmpd-06d341e4590766ca2cd0770590758d49dde7f7ba.tar.gz
ruby-libmpd-06d341e4590766ca2cd0770590758d49dde7f7ba.tar.xz
New addid method.
-rw-r--r--libmpd/playlist.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/libmpd/playlist.rb b/libmpd/playlist.rb
index 000f9c9..2b40ce4 100644
--- a/libmpd/playlist.rb
+++ b/libmpd/playlist.rb
@@ -17,6 +17,15 @@ module MPDPlaylist
return send_request('add "%s"' % uri)
end
+ # Adds the specified file to the playlist and returns the song id.
+ # An optional playlist position can be specified.
+ def addid(uri, position=nil)
+ command = 'addid "%s"' % uri
+ command << ' %s' % position if position
+
+ return send_request(command).scan(/(?!Id: )\d+/).first.to_i
+ end
+
# Deletes a song from the playlist.
def delete(songpos)
return send_request('delete %s' % songpos)