Skip to content

Commit

Permalink
Switched to VS Code and used shellcheck to help.
Browse files Browse the repository at this point in the history
  • Loading branch information
VidiotGeek committed Sep 20, 2022
1 parent 67c96a5 commit 27ba9e7
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 19 deletions.
10 changes: 10 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Autoformatter friendly markdownlint config (all formatting rules disabled)
default: true
blank_lines: false
bullet: false
html: false
indentation: false
line_length: false
spaces: false
url: false
whitespace: false
7 changes: 7 additions & 0 deletions .shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
enable=all
source-path=SCRIPTDIR
disable=SC2154

# If you're having issues with shellcheck following source, disable the errors via:
# disable=SC1090
# disable=SC1091
7 changes: 7 additions & 0 deletions .trunk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*out
*logs
actions
notifications
plugins
user_trunk.yaml
user.yaml
16 changes: 16 additions & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 0.1
cli:
version: 0.17.0-beta
plugins:
sources:
- id: trunk
ref: v0.0.3
uri: https://github.com/trunk-io/plugins
lint:
enabled:
- git-diff-check@SYSTEM
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
38 changes: 19 additions & 19 deletions easy-ytdl.command
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,28 @@ YTBE='youtu.be'
# Define the assitant function first. If youtube-dl is installed, this will be the only thing that runs.
function run_easy_ytdl () {
# Make a save folder on the desktop, because your download folder is probably also cluttered.
SAVE_DIR=$HOME/Desktop/YTDL-Downloads
if [ ! -d $SAVE_DIR ]; then
mkdir $SAVE_DIR && cd $SAVE_DIR
"SAVE_DIR=${HOME}/Desktop/YTDL-Downloads"
if [[ ! -d "${SAVE_DIR}" ]]; then
mkdir "${SAVE_DIR}" && cd "${SAVE_DIR}" || exit
else
cd $SAVE_DIR
cd "${SAVE_DIR}" || exit
fi
clear
printf '%-6s\n' "${GREENITALIC}============================= Easy YouTube-DL =================================${NOCOLOR}"
printf '%s\n' "Please paste the YouTube URL you would like to download at the prompt below."
printf '%s\n' "The link must be to \"$RED$YTCOM$NOCOLOR\", and not \"$RED$YTBE$NOCOLOR\" in order to work."
printf '%s\n\n' "Your file will be saved to $BLUE$SAVE_DIR$NOCOLOR."
printf '%s\n' "The link must be to \"${RED}${YTCOM}${NOCOLOR}\", and not \"${RED}${YTBE}${NOCOLOR}\" in order to work."
printf '%s\n\n' "Your file will be saved to ${BLUE}$$SAVE_DIR${NOCOLOR}."
printf '%s' "${YELLOW}URL:${NOCOLOR} "
read link_to_download
read -r link_to_download
printf '\n%-6s\n' "${GREENITALIC}===============================================================================${NOCOLOR}"
youtube-dl "$link_to_download" && printf '\n\n%s\n\n' "${PURPLE}You may now close this window.${NOCOLOR}" && open $SAVE_DIR && exit 0
youtube-dl "${link_to_download}" && printf '\n\n%s\n\n' "${PURPLE}You may now close this window.${NOCOLOR}" && open "${SAVE_DIR}" && exit 0
}

# After installation, ask user if they want to download a video now.
function ask_download_video () {
printf '%s\n' "Would you like to download a video now? (yes/no) "
read now_or_later
case $now_or_later in
read -r now_or_later
case ${now_or_later} in
y|Y|yes|Yes|YES) run_easy_ytdl
;;
*) printf '%s\n\n' "The next time you run this script, we will jump straight to the download prompt. Goodbye!"
Expand All @@ -103,12 +103,12 @@ function run_checksum () {
shasum -a 256 /usr/local/bin/youtube-dl &&
printf '\n%s\n' "If the checksums do not match, the download may be incomplete, corrupt, or modified. Choosing ${RED}\"NO\"${NOCOLOR} will remove the copy of youtube-dl that we just installed."
function confirm_checksum () {
printf '%s' "Do they match? (yes/no/skip): " && read matched
case $matched in
printf '%s' "Do they match? (yes/no/skip): " && read -r matched
case ${matched} in
y|Y|yes|Yes|YES) printf '\n%s\n' "${GREEN}Congratulations! youtube-dl is now installed.${NOCOLOR}"
ask_download_video
;;
n|N|no|No|NO) printf '\n%s\n' "$(RED)Removing youtube-dl executable\!${NOCOLOR}" && rm -vi /usr/local/bin/youtube-dl && exit 0
n|N|no|No|NO) printf '\n%s\n' "${RED}Removing youtube-dl executable\!${NOCOLOR}" && rm -vi /usr/local/bin/youtube-dl && exit 0
;;
s|S|skip|Skip|SKIP) printf '\n%s\n' "${YELLOW}Skipping verification.${NOCOLOR} youtube-dl is now installed."
ask_download_video
Expand Down Expand Up @@ -182,27 +182,27 @@ function test_python () {
# We also don't have python. Prompt for Python install.
printf '%s\n' "Sorry, Python 2.6 or later is a requirement for youtube-dl and this system doesn't have it"
printf '%s' "Do you want to manually install it from www.python.org and try this script again? (yes/no): "
read get_python
case $get_python in
read -r get_python
case ${get_python} in
y|Y|yes|Yes|YES) open "https://www.python.org/downloads/" && exit 0
;;
*) exit 1
;;
esac
else
# We've confirmed Python is present. Can we write to the default install location?
if -w /usr/local/bin ; then
if [[ -w /usr/local/bin ]] ; then
printf '%s' "Sorry, youtube-dl could not be found. Would you like to download and install it? (yes/no): "
read get_youtube_dl
case "$get_youtube_dl" in
read -r get_youtube_dl
case "${get_youtube_dl}" in
y|Y|yes|Yes|YES) printf '%s\n\n' "Proceeding..."
test_install_methods
;;
*) exit 0
;;
esac
else
printf '%s\n' "Sorry, the user $USER is not able to write to the install location at /usr/local/bin."
printf '%s\n' "Sorry, the user ${USER} is not able to write to the install location at /usr/local/bin."
printf '%s\n' "Login as an administrator and try again." && exit 1
fi
fi
Expand Down

0 comments on commit 27ba9e7

Please sign in to comment.