diff --git a/README.md b/README.md index e649ad0..463a7c2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,11 @@ # multiple_scripts Multiple scripts that are useful but don't deserve their own repository. +## ytube.sh + +A wrapper for youtube-dl to make easier (and automate) some things. + + ## briefing.sh Used along with Podfox to create a daily briefing without involving diff --git a/mu-search.sh b/mu-search.sh new file mode 100755 index 0000000..60566ee --- /dev/null +++ b/mu-search.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +echo "Search for? (subject: to: from: body: cc: bcc:)" +read search +# In case I forget and put commas, or put a space after the colon +search=$(echo "$search" | sed 's/: /:/' | sed 's/,/ /') +# There are no quotes around the variable here ON PURPOSE +mu find --clearlinks --skip-dups --include-related --threads --format=links --linksdir=~/.mu/results $search +echo "Searching..... press F9 to move to that mailbox" diff --git a/topcpu.sh b/topcpu.sh old mode 100644 new mode 100755 diff --git a/topmem.sh b/topmem.sh old mode 100644 new mode 100755 diff --git a/ytube b/ytube new file mode 100755 index 0000000..f91a537 --- /dev/null +++ b/ytube @@ -0,0 +1,104 @@ +#!/bin/bash + +ACTION="" +GUI="" + +############################################################################## +# Show help on cli +############################################################################## + +display_help() { + echo "usage: thuit.sh [-h][-n][-e][-b][-x][-c]" + echo " " + echo "optional arguments:" + echo " -h show this help message and exit" + echo " -u Video URL" + echo " -c Get URL from clipboard" + echo " -v Download video" + echo " -a Download audio" + echo " -p Play video natively" + echo " -g GUI feedback" + exit +} + +#TODO - make listen option as well +#TODO - if error, try updating youtube-dl first, lol + +while [ $# -gt 0 ]; do +option="$1" + case $option + in + http*) + URL="$1" + shift + ;; + -h) display_help + shift + ;; + -c) + URL=$(xclip -o) + shift + ;; + -u) shift + URL="$1" + shift + ;; + -g) GUI=TRUE + shift + ;; + -v) #download video=1 + ACTION="VIDEO" + shift + ;; + -a) #download audio + ACTION="AUDIO" + shift + ;; + -p) #play video + ACTION="PLAY" + shift + ;; + esac +done + +#TODO - ADD IN DOWNLOAD PLAYLIST OPTION +#TODO - re-implement batch file list input +#TODO - MAKE SO TUI is default +if [[ "$URL" = "" ]];then + URL=$(zenity --timeout 30 --entry --text "What is the YouTube URL?" --entry-text "") + if [[ "$URL" = "" ]];then + display_help + fi +fi + +#TODO - MAKE SO TUI is default +if [[ "$ACTION" = "" ]];then + ACTION=$(zenity --timeout 30 --list --column "Pick" --column "Opinion" --text "Which action?" --radiolist TRUE "VIDEO" FALSE "AUDIO" FALSE "BOTH" FALSE "PLAY"); + if [[ "$ACTION" = "" ]];then + display_help + fi +fi + + +case "$ACTION" in + VIDEO) + if [ ! -z "$GUI" ];then + ionice -c 3 youtube-dl "$URL" --netrc --ignore-errors --cookies /home/steven/vault/cookies.txt --write-thumbnail --mark-watched --continue --write-description --no-playlist --no-overwrites --restrict-filenames --no-check-certificate -o '/home/steven/downloads/videos/%(title)s-%(autonumber)s.%(ext)s' | tee >(zenity --progress --pulsate --auto-close --auto-kill) + else + ionice -c 3 youtube-dl "$URL" --netrc --ignore-errors --cookies /home/steven/vault/cookies.txt --write-thumbnail --mark-watched --continue --write-description --no-playlist --no-overwrites --restrict-filenames --no-check-certificate -o '/home/steven/downloads/videos/%(title)s-%(autonumber)s.%(ext)s' + fi + ;; + + AUDIO) + if [ ! -z "$GUI" ];then + ionice -c 3 youtube-dl "$URL" -x --netrc --ignore-errors --write-description --cookies /home/steven/vault/cookies.txt --no-check-certificate --embed-thumbnail --prefer-ffmpeg --no-playlist --mark-watched --continue --audio-format mp3 -o '/home/steven/downloads/mp3/%(title)s:%(uploader)s:%(upload_date)s.%(ext)s' --rate-limit 1M --restrict-filenames | tee >(zenity --progress --pulsate --auto-close --auto-kill) + else + ionice -c 3 youtube-dl "$URL" -x --netrc --ignore-errors --write-description --cookies /home/steven/vault/cookies.txt --no-check-certificate --embed-thumbnail --prefer-ffmpeg --no-playlist --mark-watched --continue --audio-format mp3 -o '/home/steven/downloads/mp3/%(title)s:%(uploader)s:%(upload_date)s.%(ext)s' --rate-limit 1M --restrict-filenames + fi + ;; + + PLAY) + mpv "$szAnswer" + ;; +esac +