summaryrefslogtreecommitdiff
path: root/bookmark-pick-open.sh
blob: e66d65b4a26ea9cb089113b6f6b262841bb7bfd4 (plain)
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
40
41
42
43
44
45
46
47
#!/bin/sh
[ ! -f $HOME/bookmarks.txt ] && {
  notify-send "$HOME/bookmarks.txt not found"
  exit 0
}
BROWSERS="vimb --incognito\nvimb\nbadwolf\nlinks\nmpv\nlibrewolf\nfirefox\nwl-copy"
tmp=$(mktemp --suffix=_$(basename $0).tmp)
grep -REh '^url: http' $PASS $PASSWORD_STORE_DIR_PLAIN | cut -d' ' -f2 >> $tmp
grep -RhE '^URL' ~/addressbooks/home-xandikos/companies_banks | dos2unix |
  sed -En 's/.*(http.*$)/\1/p' >> $tmp
cat $HOME/bookmarks.txt >> $tmp
choice=$(cat $tmp | $PICKER)
rm $tmp
URI="${choice##* }"
[ -z "$URI" ] && exit 1
printf "%s\n" $URI
case "$URI" in
  https://vk.com/video-*|https://odysee.com/*livestream*|*.m3u8|https://youtube.com/*/live)
    mpv "$URI" &
    exit
    ;;
  https://t.me/s/*)
    foot sh -c "links -dump $URI | less"
    exit
    ;;
  https://rumble.com/c/*)
    BROWSERS=$BROWSERS"\nrumble-get-vids-of-channel.sh\n"
    ;;
  *)
    ;;
esac
BROWSER=$(printf "$BROWSERS" | $PICKER)
case $BROWSER in
  rumble-get-vids-of-channel.sh)
    u=$($BROWSER $URI | $PICKER | awk '{print $2}')
    fmt=$(yt-dlp --no-colors -Fq "$u" | awk 'NR>2 && !/^timeline.*/ && !/Timeline/' \
      | $PICKER | awk '{print $1}')
    mpv --ytdl-format=$fmt "$u" &
    ;;
  links)
    #printf "ff\n"
    foot links "$URI"
    ;;
  *)
    $BROWSER $URI
    ;;
esac