From fcb02ff487e84c1c2fc1e435277c19ce05315402 Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 21 May 2015 22:55:34 +0200 Subject: timemachine: add vimeo_random --- timemachine/bin/vimeo_random | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 timemachine/bin/vimeo_random 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 "$@" -- cgit v1.2.3