summaryrefslogtreecommitdiffstats
path: root/timemachine/bin/youtube_random
blob: 30ee87f81222e6d5ad24f0d2870ac67f0034cc34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh
set -euf

main() {
  if [ ! $# -eq 0 ]; then
    usage
  fi

  get_random_video
}

get_random_video() {
  curl -Ss http://randomyoutube.net/watch | sed -n 's|.*\(http://www\.youtube.com/watch?v=.\{11\}\).*|\1|p'
}

usage() {
  echo 'returns a random youtube video.'
  echo 'scrapes http://randomyoutube.net/'
  echo 'example: mpv $(youtube_random)'
}

main