"nd attempt to upload files

This commit is contained in:
Peter Green 2023-01-07 19:47:56 +00:00
parent fb5d68e0d1
commit f62ee6fbd9
3 changed files with 292 additions and 0 deletions

128
YT-DL.sh Normal file
View File

@ -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

138
YouTube-DL.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 22 KiB

26
uninstall.sh Normal file
View File

@ -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