/
tal
executable file
·39 lines (30 loc) · 902 Bytes
/
tal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
# tal.sh
# Author: William Woodruff
# ------------------------
# Stream episodes of This American Life.
# Requires mpv and GNU bash 4.0.
# ------------------------
# This code is licensed by William Woodruff under the MIT License.
# http://opensource.org/licenses/MIT
player="mpv"
playeropts="--force-window=no --no-ytdl"
cmd="${1:-usage}"
function error {
>&2 echo "Fatal: ${*}. Exiting."
exit 2
}
function installed {
cmd=$(command -v "${1}")
[[ -n "${cmd}" ]] && [[ -f "${cmd}" ]]
return ${?}
}
function usage {
echo "Usage: $(basename "${0}") <episode #>"
exit
}
[[ "${BASH_VERSINFO[0]}" -lt 4 ]] && error "GNU bash 4.0 or later is required"
installed "${player}" || error "Missing dependency: '${player}'"
[[ -n "${1}" ]] || usage
episode="http://stream.thisamericanlife.org/${1}/stream/${1}_64k.m3u8"
eval "${player} ${playeropts} ${episode}"