diff options
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/.local/bin/mpv-clip | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/bin/.local/bin/mpv-clip b/bin/.local/bin/mpv-clip new file mode 100755 index 0000000..33a6495 --- /dev/null +++ b/bin/.local/bin/mpv-clip @@ -0,0 +1,30 @@ +#!/bin/bash + +# mpv wrapper script for clipboard links +# origin andrew@aeon.lan +# canon andrew@aeon.lan:/home/andrew/scripts/mpv +# deps mpv, wl-clipboard, libnotify, socat, iproute2 + +clip=$(wl-paste) + +if grep -q "/watch?v=" <<< "${clip}"; then + videoID=$(sed 's/.*v=//' <<< "${clip}") + toplay="ytdl://${videoID:0:11}" +# toplay="https://${INV}/api/manifest/dash/id/${videoID:0:11}?local=true" +elif grep -q "/playlist?list=" <<< "${clip}"; then + playlistID=$(sed 's/.*list=//' <<< "${clip}") + toplay="https://www.youtube.com/playlist?list=${playlistID:0:34}" +elif grep -q "/channel/" <<< "${clip}"; then + channelID=$(sed 's/.*channel\///' <<< "${clip}") + toplay="https://www.youtube.com/channel/${channelID:0:24}" +else + toplay="${clip}" +fi + +if pgrep mpv; then + notify-send "Appending ${toplay}" -t 2000 + socat - /run/user/1000/mpv.sock <<< '{ "command": ["loadfile", "'${toplay}'", "append-play"] }' +else + notify-send "Playing ${toplay}" -t 2000 + mpv "${toplay}" +fi |
