Skip to content

Commit

Permalink
Major additions, initial public release.
Browse files Browse the repository at this point in the history
  • Loading branch information
VidiotGeek committed Sep 11, 2022
1 parent 25100c4 commit 290fc44
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 1 deletion.
131 changes: 131 additions & 0 deletions Easy-YouTube-DL.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#!/usr/bin/env bash
###################################################################################
# Easy-YouTube-DL #
# #
# The goals of this Easy-YouTube-DL script are: #
# #
# 1) To have a thinly veiled excuse to learn and practice as many #
# bash scripting concepts as I can force into what started as #
# a six line script that probably should have stayed that way. #
# #
# 2) Maybe actually assist users who are CLI-phobic, primarily on #
# macOS, to download, install, and use youtube-dl with as #
# little, or as simple, command line interaction as possible. #
# #
# 3) Finally publish some original code in open source for public #
# benefit, constructive critique, or vehement ridicule. #
# #
# Change History #
# 2022-09-10 Massive mission scope bloat. Added GPLv3 License. #
# 2022-09-06 Original release. #
# #
###################################################################################
###################################################################################
# #
# Copyright (C) 2022, Matt Bailey #
# [email protected] #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
# #
###################################################################################
###################################################################################

# Clear the screen and print system info just for funsies. Will probably delete later.
clear
printf '\n\e[3;35m%-6s\a\e[m\n' "=============================== SYSTEM INFO ==================================" ;
printf "System Version:\t\t $(uname -srm) \n"
printf "Current Date/Time:\t $(date) \n"
printf "Current Directory:\t $(pwd) \n"
printf '\n\e[3;35m%-6s\a\e[m\n' "==============================================================================" ;
echo

#The farther I went down the path of writing everything in line, it seems like
#it might be easier and fewer lines of code to run all my tests ahead of time, save the
#results into variables, then also break each step out into a function... TBD


# Test if youtube-dl is in $PATH
if ! command -v youtube-dl &> /dev/null ; then
# We don't have it. Do we have Python as a requirement?
if ! command -v python &> /dev/null ; then
# We also don't have python. Prompt for install.
echo "Sorry, Python 2.6 or later is a requirement for youtube-dl and this system doesn't have it"
read -p "Do you want to install it from www.python.org and try again? (yes/no): " "get_python"
case $get_python in
y|Y|yes|Yes|YES) open "https://www.python.org/downloads/"
;;
*) exit
;;
esac
else
echo "youtube-dl could not be found. Installation requires admin privileges."
read -p "Would you like to download and install it? (yes/no): " "get_youtube_dl"
if ! command -v curl &> /dev/null ; then
# We can't use curl to install.
if ! command -v wget &> /dev/null ; then
# We also can't use wget to install.
if ! command -v pip &> /dev/null ; then
# We don't even have pip which should have come with Python when installed?
# Abandon all hope.
exit 0
else
case "$get_youtube_dl" in
y|Y|yes|Yes|YES) echo "Proceeding..."
sudo pip install --upgrade youtube_dl
;;
*) exit 0
;;
esac
fi
else
case "$get_youtube_dl" in
y|Y|yes|Yes|YES) echo "Proceeding..."
if -w /usr/local/bin ; then
sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
else
echo "We cannot write to /usr/local/bin"
exit 0
fi
;;
*) exit 0
;;
esac
fi
else
case "$get_youtube_dl" in
y|Y|yes|Yes|YES) echo "Proceeding..."
if -w /usr/local/bin ; then
sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
else
echo "We cannot write to /usr/local/bin"
exit 0
fi
;;
*) exit 0
;;
esac
fi
fi

cd ~/Desktop
# Save file to the desktop, because your download folder is probably also cluttered.
printf '\n\e[3;35m%-6s\a\e[m\n' "============================= Easy YouTube-DL =================================" ;
echo "Please paste the YouTube URL you would like to download below."
echo "Must be "youtube.com", not "youtu.be". The file will be saved to ~/Desktop"
echo
read -p "URL: " "link_to_download"
echo
printf '\n\e[3;35m%-6s\a\e[m\n' "===============================================================================" ;
echo
youtube-dl "$link_to_download"
Binary file added Papirus-Team-Papirus-Apps-Youtube-dl.icns
Binary file not shown.
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,27 @@
# Easy-YouTube-DL
This is a simple script to make the great command line utility youtube-dl eaasier to use for GUI-centric / CLI-phobic users.

This started as a simple script to make the great command line utility [_youtube-dl_](https://yt-dl.org/)\
easier to use for GUI-centric / CLI-phobic users. Folks who wouldn't have a _clue_ \
what to do with a terminal window in front of them. The idea being, if the sight of \
a command prompt doesn't **immediately** scare them away, all the user would have to \
do is paste the URL into the prompt when asked. No having to remember to put it in \
"quotes" or otherwise having to understand anything about escape characters for the \
"?" and "=" present in URLs.

It turned into an excuse for me to practice as **many** bash scripting concepts as I could and\
is now _kind_ of a full download and install assistant for youtube-dl. In addition to\
it's original function as a very stripped down interface for it.

I realize that my would-be target audience are highly unlikely to know what [Github](https://github.com/) is,\
but perhaps you also are the go-to tech support person for many of the people in your life.\
Maybe this is just the thing for you to use to assist those people in their legal, fair use,\
downloading of youtube clips.

I hope you find it useful in some way.

**Thanks!**\
Matt Bailey

Icon by [Papirus Development Team](https://github.com/PapirusDevelopmentTeam)\
Licensed under GNU General Public Licesne v3.0\
Sourced from [IconArchive](https://iconarchive.com/show/papirus-apps-icons-by-papirus-team/youtube-dl-icon.html)

0 comments on commit 290fc44

Please sign in to comment.