summaryrefslogtreecommitdiff
path: root/yt-player.sh
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@53hor.net>2020-05-19 16:55:44 -0400
committerAdam T. Carpenter <atc@53hor.net>2020-05-19 16:55:44 -0400
commit86bda792526ffbd675afd3e0841cce517187bde6 (patch)
treeb99117826b702daed7d1b32ac0eac2bc3cc78779 /yt-player.sh
parent0ce7301d8799ba91a0d57ab208e2d80d20935a83 (diff)
downloadscripts-86bda792526ffbd675afd3e0841cce517187bde6.tar.xz
scripts-86bda792526ffbd675afd3e0841cce517187bde6.zip
added screencasting script, mail block, minor tweaks
Diffstat (limited to 'yt-player.sh')
-rwxr-xr-xyt-player.sh69
1 files changed, 52 insertions, 17 deletions
diff --git a/yt-player.sh b/yt-player.sh
index cde337f..a5f21b8 100755
--- a/yt-player.sh
+++ b/yt-player.sh
@@ -1,21 +1,57 @@
#!/bin/sh
-# Do things with a YouTube URL.
-
-read url
-printf "$url"
-test -z $url && exit
-title="$(youtube-dl -e "$url")"
-
-choice=$(dmenu -i -p "$title" << EOF
-Watch
-Listen
-Download video
-Download audio
-EOF
-)
-
-case $choice in
+## Do things with a YouTube URL.
+
+## Config
+terminal=alacritty
+
+
+## Notify the title and description of the URL
+notify_info() {
+ url="$1"
+ info=$(youtube-dl --get-title --get-description --get-duration "$url")
+ title=$(echo "$info" | head -n 1)
+ description=$(echo "$info" | sed '1d;$d')
+ duration=$(echo "$info" | tail -n 1)
+ notify-send "$title : $duration" "$description"
+}
+
+
+## Main
+notify_info "$1" && exit
+option="$1"
+case $option in
+ '-c')
+ url="$(xclip -o -selection clipboard)"
+ [ -z "$url" ] && exit $NO_URL_IN_CLIPBOARD
+ ;;
+ '-p')
+ url="$(xclip -o)"
+ [ -z "$url" ] && exit $NO_URL_IN_PRIMARY
+ ;;
+ '-u')
+ url="$2"
+ [ -z "$url" ] && exit $NO_URL_IN_SECOND_ARG
+ ;;
+ '-a')
+ $terminal -e mpv --no-video "$url"
+ ;;
+ '-da')
+ youtube-dl -x --audio-format flac --audio-quality 0 "$url"
+ ;;
+ '-v')
+ mpv --no-terminal "$url"
+ ;;
+ '-dv')
+ youtube-dl --add-metadata "$url"
+ ;;
+ *)
+ exit
+ ;;
+esac
+
+
+case $choice in
"Watch")
mpv "$url" --no-terminal &
;;
@@ -31,4 +67,3 @@ case $choice in
*)
exit
esac
-