summaryrefslogtreecommitdiff
path: root/yt-player.sh
diff options
context:
space:
mode:
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
-