From 86bda792526ffbd675afd3e0841cce517187bde6 Mon Sep 17 00:00:00 2001 From: "Adam T. Carpenter" Date: Tue, 19 May 2020 16:55:44 -0400 Subject: added screencasting script, mail block, minor tweaks --- yt-player.sh | 69 +++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 17 deletions(-) (limited to 'yt-player.sh') 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 - -- cgit v1.2.3