diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-09-20 07:01:33 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-09-22 22:06:33 +0000 |
commit | 09724ca3f1eb1d0d726ba0f6288b44bdc073994e (patch) | |
tree | 105d8fd9f1d4015a2971fc40abd2d82fb8e7612b | |
parent | 44b612807de3caa14e2cae6dcba7061091fed4ca (diff) | |
download | dtas-09724ca3f1eb1d0d726ba0f6288b44bdc073994e.tar.gz |
This behaves like "goto", but takes a regular expression instead of a track_id
-rw-r--r-- | Documentation/dtas-tl.txt | 2 | ||||
-rwxr-xr-x | bin/dtas-tl | 20 |
2 files changed, 22 insertions, 0 deletions
diff --git a/Documentation/dtas-tl.txt b/Documentation/dtas-tl.txt index 7c54f10..f7a3a1a 100644 --- a/Documentation/dtas-tl.txt +++ b/Documentation/dtas-tl.txt @@ -28,6 +28,8 @@ client). * goto TRACKID [POS] - play TRACKID immediately, optionally seek to POS TRACKID may be looked up via cat, and POS should be a timestamp in HH:MM:SS.FRAC format. +* reto REGEXP [POS] - play first track with path matching REGEXP immediately, +optionally seek to POS. POS should be a timestamp in HH:MM:SS.FRAC format. * next - play the next track in the tracklist * previous - play the previous track in the tracklist * repeat 1 - repeat the current track diff --git a/bin/dtas-tl b/bin/dtas-tl index f34a83c..7793f23 100755 --- a/bin/dtas-tl +++ b/bin/dtas-tl @@ -47,6 +47,26 @@ when "addtail" puts "#{path} #{res}" last_id = res if res =~ /\A\d+\z/ end +when "reto" + fixed = ARGV.delete("-F") + ignorecase = ARGV.delete("-i") + re = ARGV[1] + time = ARGV[2] + re = Regexp.quote(re) if fixed + re = ignorecase ? %r{#{re}}i : %r{#{re}} + get_track_ids(c).each do |track_id| + res = c.req("tl get #{track_id}") + res.sub!(/\A1 /, '') + if re =~ res + req = %W(tl goto #{track_id}) + req << time if time + res = c.req(req) + puts res + exit(res == "OK") + end + end + warn "#{re.inspect} not found" + exit 1 else # act like dtas-ctl for now... puts c.req([ "tl", *ARGV ]) |