diff options
author | lassulus <lass@aidsballs.de> | 2015-05-21 22:55:34 +0200 |
---|---|---|
committer | lassulus <lass@aidsballs.de> | 2015-05-21 22:55:34 +0200 |
commit | fcb02ff487e84c1c2fc1e435277c19ce05315402 (patch) | |
tree | bb5d5a1dfe1ec0c10802aa1122bf41ad9f8244fe /timemachine/bin | |
parent | 5903072403be7f45434b728378949707ce092303 (diff) |
timemachine: add vimeo_random
Diffstat (limited to 'timemachine/bin')
-rwxr-xr-x | timemachine/bin/vimeo_random | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/timemachine/bin/vimeo_random b/timemachine/bin/vimeo_random new file mode 100755 index 00000000..3e0bdaeb --- /dev/null +++ b/timemachine/bin/vimeo_random @@ -0,0 +1,31 @@ +#!/bin/sh + +main() { + if [ ! $# -eq 0 ]; then + usage + else + until (check_vimeo_availabe $video); do + video="$(get_random_vimeo_url)" + done + echo $video + fi +} + +get_random_vimeo_url() { + curl -Ss http://randomvimeovideo.com/ \ + | sed -n 's|.*http\(://vimeo\.com/[0-9]*\).*|https\1|p' \ + | uniq +} + +check_vimeo_availabe() { + video_url=$1 + test $(echo $video_url | wc -c) -lt 18 && return 1 + curl -Ss -I "$video_url" | grep -q "HTTP/1\.1 200 OK" +} + +usage() { + echo 'get a random vimeo video via http://randomvimeovideo.com/' + echo 'example: mpv $(vimeo_random)' +} + +main "$@" |