Adds ippsec fzf script
This commit is contained in:
parent
180d8cd21b
commit
4ede5bf7bd
2 changed files with 33 additions and 4 deletions
24
bin/.bin/dmenu/ippsec
Executable file
24
bin/.bin/dmenu/ippsec
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/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)"
|
||||
|
||||
open-youtube "$url"
|
||||
|
|
@ -1,14 +1,19 @@
|
|||
#!/bin/bash
|
||||
|
||||
isxclient=$( readlink /dev/fd/2 | grep -q 'tty' && [[ -n $DISPLAY ]] ; echo $? )
|
||||
if [[ ! -t 2 || $isxclient == "0" ]]; then
|
||||
DMENU="rofi -dmenu -p"
|
||||
else
|
||||
DMENU="fzf --prompt"
|
||||
fi
|
||||
|
||||
url="$1"
|
||||
|
||||
notify-send "Opening Video" "$url"
|
||||
|
||||
if [ -z "$url" ]; then
|
||||
url=$(rofi -dmenu -p 'URL')
|
||||
url=$($DMENU 'URL')
|
||||
fi
|
||||
|
||||
code=$(youtube-dl "$url" -F | sed -n '/format code/,$ p' | tail -n +2 | rofi -dmenu -p Quality | awk '{print $1}')
|
||||
code=$(youtube-dl "$url" -F | sed -n '/format code/,$ p' | tail -n +2 | $DMENU Quality | awk '{print $1}')
|
||||
|
||||
mpv "$url" --ytdl-format="$code"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue