Merge listing and fetching into one
This commit is contained in:
parent
7656235b00
commit
552ae9cfd0
|
@ -1,15 +0,0 @@
|
|||
#!/bin/zsh
|
||||
|
||||
source ~/.config/twitch-subs
|
||||
LIST=()
|
||||
|
||||
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 > ~/.cache/twitch
|
|
@ -0,0 +1,25 @@
|
|||
#!/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
|
Loading…
Reference in New Issue