From 85603a1c1fb027f5fa7f4c93a99fb7a180ceaf9e Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Wed, 7 Sep 2022 13:24:50 +0200 Subject: Adding two new scripts that might be of use. --- vid_sload | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100755 vid_sload (limited to 'vid_sload') diff --git a/vid_sload b/vid_sload new file mode 100755 index 0000000..a0cb42a --- /dev/null +++ b/vid_sload @@ -0,0 +1,71 @@ +#!/bin/sh + while getopts "s:v:S:V" flag + do + case $flag in + s) use=sound && link=$OPTARG ;; + v) use=video && link=$OPTARG;; + S) use=batch_sound ;; + V) use=batch_video ;; + esac + done +vidselect() { + :> ~/.cache/vid_sload/list && + dl_links=$(cat ~/.cache/dl_list | gsed 's/https.*v=//g' | gsed -z 's/\n/\|/g' | sed 's/\|$//g') && + num=1 + for line in $(cat ~/.cache/view_hist) + do + (echo "$line" | grep -E $dl_links && + printf '[X] %s\n' "$line" || + printf '[%s] %s\n' "$num" "$line") >> ~/.cache/vid_sload/list + num=$((( $num+1 ))) + done && cat ~/.cache/vid_sload/list && + + echo "####################################" && + echo "Add video to list (a), download (s/v/l) or exit?" && + read ans; + mode=$(echo $ans | gsed 's/\s.*//g') && + argnam=$(echo $ans | sed 's/^.//g') && + vidlink=$(grep $argnam ~/.cache/vid_sload/list | gsed 's/^.*\]\s//' | gsed 's/^.*\*\*\*//g') + cd ~/Downloads + if [ $mode == 'a' ]; then + echo $vidlink >> ~/.cache/dl_list + echo $vidlink + reload + elif [ $mode == 's' ]; then + yt-dlp -x -w -c --add-chapters --prefer-free-formats $vidlink && exit + elif [ $mode == 'v' ]; then + yt-dlp -f 'bestvideo[height<=480]+bestaudio/best[height<=360]/best[height<=720]/best' -w -c --add-chapters --prefer-free-formats $vidlink && exit + elif [ $mode == 'l' ] ; then + yt-dlp -f 'bestvideo[height<=480]+bestaudio/best[height<=360]/best[height<=720]/best' -w -c --add-chapters --prefer-free-formats -a ~/.cache/dl_list && rm ~/.cache/dl_list && touch ~/.cache/dl_list && exit + elif [ $mode == 'exit' ] ; then + exit + else + echo "Unknown option: Please try again." + fi +} + + +reload() { +clear +vidselect +} + +if [ -z "$1" ] +then + vidselect +else + cd ~/Downloads + case $use in + sound) + yt-dlp -x -w -c --add-chapters --prefer-free-formats $link && exit;; + video) + yt-dlp -f 'bestvideo[height<=480]+bestaudio/best[height<=360]/best[height<=720]/best' -w -c --add-chapters --prefer-free-formats $link && exit;; + + batch_sound) + yt-dlp -x -w -c --prefer-free-formats -a ~/.cache/dl_list && rm ~/.cache/dl_list && touch ~/.cache/dl_list && exit ;; + + batch_video) + yt-dlp -f 'bestvideo[height<=480]+bestaudio/best[height<=360]/best[height<=720]/best' -w -c --add-chapters --prefer-free-formats -a ~/.cache/dl_list && rm ~/.cache/dl_list && touch ~/.cache/dl_list && exit ;; + esac +fi + -- cgit v1.2.1