26 lines
563 B
Bash
26 lines
563 B
Bash
|
#!/bin/zsh
|
||
|
|
||
|
source ~/.config/twitch-subs
|
||
|
cachefile=~/.cache/twitch
|
||
|
LIST=()
|
||
|
|
||
|
if [[ "$1" == "fetch" ]]; then
|
||
|
for cur in $SUBSCRIPTIONS; do
|
||
|
<<< "Fetching twitch.tv/$cur" >&2
|
||
|
desc="$(youtube-dl --get-description "https://twitch.tv/$cur" 2>/dev/null)"
|
||
|
if [ -z "$desc" ]; then
|
||
|
<<< "$cur is offline." >&2
|
||
|
else
|
||
|
LIST+=("$cur | $desc")
|
||
|
fi
|
||
|
done
|
||
|
print -l $LIST > $cachefile
|
||
|
else
|
||
|
list="$(< $cachefile)"
|
||
|
[ -z "$cachefile" ] && return
|
||
|
res="$(dmenu -l 20 <<< $list)"
|
||
|
res="${res%% | *}"
|
||
|
[ -z "$res" ] && return
|
||
|
mpv --profile=v "https://twitch.tv/$res"
|
||
|
fi
|