diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-09-09 09:07:55 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-09-09 09:07:55 +0000 |
commit | 49f1b62e2f85c8e2470d5162a0206d8a5327e7ce (patch) | |
tree | 162ce6ed84afb96e755fc9516a513fe115c4fad3 /bin/dtas-tl | |
parent | 9948975066981b6d9dfbbb18adc7013341a26634 (diff) | |
download | dtas-49f1b62e2f85c8e2470d5162a0206d8a5327e7ce.tar.gz |
This is implemented in client space, as the MPRIS 2.0 spec does not say this needs to be implemented at all...
Diffstat (limited to 'bin/dtas-tl')
-rwxr-xr-x | bin/dtas-tl | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/bin/dtas-tl b/bin/dtas-tl index 1cd2acc..8e00b50 100755 --- a/bin/dtas-tl +++ b/bin/dtas-tl @@ -1,17 +1,32 @@ #!/usr/bin/env ruby # Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +# +# WARNING: totally unstable API, use dtas-ctl for scripting (but the protocol +# itself is also unstable, but better than this one probably). require 'dtas/unix_client' require 'yaml' require 'shellwords' +def get_track_ids(c) + track_ids = c.req("tl tracks") + # we could get more, but SEQPACKET limits size... + track_ids = track_ids.split(/ /) + track_ids.shift + track_ids +end + c = DTAS::UNIXClient.new case cmd = ARGV[0] when "cat" - track_ids = c.req("tl tracks") - # we could get more, but SEQPACKET limits size... - track_ids.split(/ /).each do |track_id| - puts c.req("tl get #{track_id}") + get_track_ids(c).each do |track_id| + res = c.req("tl get #{track_id}") + res.sub!(/\A1 /, '') + puts res + end +when "clear" + get_track_ids(c).each do |track_id| + puts "#{track_id} " << c.req("tl remove #{track_id}") end when "add-all" ARGV.shift @@ -22,8 +37,7 @@ when "add-all" end when "add-tail" ARGV.shift - track_ids = c.req("tl tracks") - track_ids = track_ids.split(/ /) + track_ids = get_track_ids(c) last_id = track_ids.pop ARGV.each do |path| path = File.expand_path(path.b) |