Dotfiles/bin/.bin/dmenu/ippsec
Jonathan Hodgson 99736427be BIN: Deletes open-youtube and puts functionality in yt
The yt script now accepts a --url option which will take a url as an
option like

yt --url youtube.com/watch?v=blar
or
echo youtube.com/watch?v=blar | yt --url

It will also use rofi rather than fzf if not being run from a terminal
or the --rofi flag is given

I have updated the files that used to use open-youtube to reflect this
2021-07-30 13:14:50 +01:00

26 lines
770 B
Bash
Executable file

#!/usr/bin/env bash
buildURL(){
if [ -n "$1" ]; then
in="$1"
else
in="$(cat -)"
fi
id="$(echo "$in" | cut -d ' ' -f 1)"
mins="$(echo "$in" | cut -d ' ' -f 4)"
secs="$(echo "$in" | cut -d ' ' -f 5)"
seconds="$(( $mins * 60 + $secs ))"
echo -e "https://youtube.com/watch?v=$id&t=$seconds"
}
export -f buildURL
url="$(curl https://ippsec.rocks/dataset.json 2>/dev/null |\
jq -cM '[.[] | {machine:.machine,ID:.videoId,mins:.timestamp.minutes,secs:.timestamp.seconds,line:.line}]' |\
jq -r '(map(keys) | add | unique) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $cols, $rows[] | @tsv' |\
fzf -d ' ' --with-nth '3,2' --header-lines 1 --preview-window 'up:1' --preview 'bash -c '\''buildURL "$0"'\'' {}' |\
buildURL)"
echo "$url"
yt "$url"