From f62ee6fbd95d56b8cfd91473c7ffb50355ef0e30 Mon Sep 17 00:00:00 2001 From: greenpete Date: Sat, 7 Jan 2023 19:47:56 +0000 Subject: [PATCH] "nd attempt to upload files --- YT-DL.sh | 128 +++++++++++++++++++++++++++++++++++++++++++++ YouTube-DL.svg | 138 +++++++++++++++++++++++++++++++++++++++++++++++++ uninstall.sh | 26 ++++++++++ 3 files changed, 292 insertions(+) create mode 100644 YT-DL.sh create mode 100644 YouTube-DL.svg create mode 100644 uninstall.sh diff --git a/YT-DL.sh b/YT-DL.sh new file mode 100644 index 0000000..2aeae57 --- /dev/null +++ b/YT-DL.sh @@ -0,0 +1,128 @@ +#!/bin/bash + +############################################# +# # +# Script for downloading YouTube videos # +# It also checks that ytdl is installed # +# and up to date! # +# By Peter Green # +# Version 0.9.1 # +# Date of first version; 2022-04-04 # +# Date of last update; 2022-05-08 # +# Moved to my own Gitea instance 26-12-2022 # +# # +############################################# + +# Config... + +# How many times should this script run before it checks for updates? +ud_frq=11 # This means the script will run on the number after that which you set here. The counter starts at 0. + +# End config. + +# Say hi, and declare version number... +echo " + + ############################################################# + # # + # Welcome to the Peter's YouTube video downloader! # + # Version 0.9.1 # + # # + #############################################################" + +# Move to working dir... +cd ~/Desktop || exit + +# Start database incrementation... + +# Read the database and put it in a variable... +ud_count=$(cat ~/bin/YT-DL/db.txt) + +# Echo the latest value of the database +echo " + This script has run $ud_count times since the last check for an update. + It will check for updates after $ud_frq runs." + +# Make the script increment the value in the database by 1 each run... +let "ud_count=ud_count+1" + +# Write the new value to the database... +echo "$ud_count" > ~/bin/YT-DL/db.txt + +# End database incrementation... + +# Start processing the update counter db... + +if [ "$ud_count" -gt $ud_frq ]; + then echo " We need to update!" && echo " Checking for updates..." && youtube-dl -U && echo "0" > ~/bin/YT-DL/db.txt + else echo " No need to update yet..." +fi + +# End processing the update counter db... + +# Start acquiring info' about the desired video to download... + +# Ask the user what the URL of the video is... + +echo " + ############################################################# + # # + # Please enter the URL of the video you want to download - # + # # + #############################################################" + +read -r URL #Example - https://youtu.be/S8UNBfatLTo + +# Validate user input of the URL variable... +until [[ $URL = https://* ]]; + do echo " That is not a recognised URL. + Please try again..." && read -r URL +done + +clear + +# Ask user if they want to see the download options... +echo " + + ############################################################# + # # + # Would you like to see the video download options? (y/n) # + # # + ############################################################# + +" +read -r options + +until [ "$options" = y ] || [ "$options" = n ]; + do echo " That is not a valid answer. + Your answer must be 'y' or 'n' + Please try again..." && read -r options +done + +clear + +if [ "$options" = y ]; + then youtube-dl -F "$URL" && echo " + Which of the options above would you + like to choose? (See number at start of + each line)." && read -r option && clear && youtube-dl -f "$option" "$URL" + else echo " + ##################################################### + # # + # Downloading full resolution video with audio... # + # # + #####################################################" && youtube-dl "$URL" +fi + +# End aquiring info' about the desired video to download... + +echo " + ################################################ + # # + # Finished downloading. # + # # + # Please press 'Enter' to close this window. # + # # + ################################################" +read -r + diff --git a/YouTube-DL.svg b/YouTube-DL.svg new file mode 100644 index 0000000..b744d84 --- /dev/null +++ b/YouTube-DL.svg @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/uninstall.sh b/uninstall.sh new file mode 100644 index 0000000..73ce234 --- /dev/null +++ b/uninstall.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Remove YT-DL-W +echo "Removing youtube-dl-wrapper..." +rm -R ~/bin/YT-DL + +# Remove youtube-dl +echo "Checking to see if we need to remove youtube-dl" +instytdl="$(cat ./dbytdl.txt)" +if [ "$instytdl" = 1 ]; + then echo "Removing youtube-dl" && sudo rm /usr/local/bin/youtube-dl + else echo >/dev/null +fi + +# Remove python symlink +echo "Checking to see if we need to remove python symlink" +pylnk=$(cat ./dbpyer.txt) +if [ "$pylnk" = 1 ]; + then echo "Removing python sym link" && sudo rm /usr/bin/python + else echo >/dev/null +fi + +echo "Uninstall finished! + +Press 'Enter' to close this window..." +read -r