Skip to content

Commit 93c51c8

Browse files
committed
20210330 - This is 1.2.0 - Fixing #1
1 parent c1eb211 commit 93c51c8

File tree

3 files changed

+40
-9
lines changed

3 files changed

+40
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# changelog
2+
## Version 1.2.0 (20210330)
3+
* Added check for updates - see #1
4+
* Added dependecy check for ffmpeg
5+
26
## Version 1.1.0 (20210327)
37
* Added output after processing finished
48
* Minor changes to status output

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ ydownl.sh is a simple youtube-dl bash script which can be used to extract audio
1212
The following packages are required:
1313

1414
* youtube-dl
15+
* ffmpeg
1516
* zenity
17+
* curl
18+
* sed
1619

1720
## usage
1821
`./ydownl.sh https://www.youtube.com/watch?v=Y52M28WQu2s`

ydownl.sh

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
# ------------------------------------------------------------------------------
1717
# DEFINE CONSTANTS - DON'T TOUCH
1818
# ------------------------------------------------------------------------------
19-
SCRIPTNAME="ydownl.sh"
20-
SCRIPTVERSION="1.1.0"
21-
SCRIPTDEMOURL="https://www.youtube.com/watch?v=Y52M28WQu2s"
19+
SCRIPT_NAME="ydownl.sh"
20+
SCRIPT_VERSION="1.2.0"
21+
SCRIPT_LATEST="https://github.com/yafp/ydownl.sh/releases/latest"
22+
SCRIPT_DEMO_URL="https://www.youtube.com/watch?v=Y52M28WQu2s"
23+
2224

2325

2426
# ------------------------------------------------------------------------------
@@ -80,7 +82,7 @@ function reset() {
8082
}
8183

8284
function showHeader() {
83-
printf " ${bold}${lime_yellow}%s${normal} - ${bold}%s ${normal}\n" "$SCRIPTNAME" "$SCRIPTVERSION"
85+
printf " ${bold}${lime_yellow}%s${normal} - ${bold}%s ${normal}\n" "$SCRIPT_NAME" "$SCRIPT_VERSION"
8486
printf " ${bold}----------------------------------------------------------${normal}\n"
8587
}
8688

@@ -89,8 +91,8 @@ function showNotification() {
8991
then
9092
printf "Notifications using notify-send is not supported - skipping ...\n"
9193
else
92-
#notify-send -u low -t 0 "$SCRIPTNAME" "$1"
93-
zenity --info --text="$1" --title="$SCRIPTNAME" --width="$CONFIG_ZENITY_WIDTH" --height="$CONFIG_ZENITY_HEIGHT" --timeout="$CONFIG_ZENITY_TIMEOUT"
94+
#notify-send -u low -t 0 "$SCRIPT_NAME" "$1"
95+
zenity --info --text="$1" --title="$SCRIPT_NAME" --width="$CONFIG_ZENITY_WIDTH" --height="$CONFIG_ZENITY_HEIGHT" --timeout="$CONFIG_ZENITY_TIMEOUT"
9496
fi
9597
}
9698

@@ -106,6 +108,24 @@ function checkIfExists() {
106108
fi
107109
}
108110

111+
function checkVersion() {
112+
SCRIPT_LATEST_VERSION=`curl --silent "https://api.github.com/repos/yafp/ydownl.sh/releases/latest" | # Get latest release from GitHub api
113+
grep '"tag_name":' | # Get tag line
114+
sed -E 's/.*"([^"]+)".*/\1/' ` # Pluck JSON value
115+
116+
117+
#printf "Your version: $SCRIPT_VERSION\n"
118+
#printf "Latest version: $SCRIPT_LATEST_VERSION\n"
119+
120+
121+
if [ "$SCRIPT_LATEST_VERSION" == "$SCRIPT_VERSION" ]
122+
then
123+
printf "${green}[ OK ]${normal} Your current version $SCRIPT_VERSION is up-to-date\n"
124+
else
125+
printf "${powder_blue}[ INFO ]${normal} Your version is outdated. $SCRIPT_LATEST_VERSION is available under: $SCRIPT_LATEST\n"
126+
fi
127+
}
128+
109129

110130
# ------------------------------------------------------------------------------
111131
# SCRIPT
@@ -114,18 +134,22 @@ reset # clear the screen
114134
initColors # initialize the color and font formating variables
115135
showHeader # show the script header
116136
checkIfExists "youtube-dl"
137+
checkIfExists "ffmpeg"
117138
checkIfExists "zenity"
139+
checkIfExists "curl"
140+
checkIfExists "sed"
141+
checkVersion
118142

119143
# Check if a parameter was supplied - if not stop execution
120144
if [ -z "$1" ]
121145
then
122146
printf "${yellow}[ WARN ]${normal} no URL detected. Starting input dialog\n"
123147

124148
# start input dialog to handle the missing url
125-
URL=$(zenity --entry --width="$CONFIG_ZENITY_WIDTH" --height="$CONFIG_ZENITY_HEIGHT" --title="$SCRIPTNAME" --text="Please insert an URL:")
149+
URL=$(zenity --entry --width="$CONFIG_ZENITY_WIDTH" --height="$CONFIG_ZENITY_HEIGHT" --title="$SCRIPT_NAME" --text="Please insert an URL:")
126150
if [ -z "$URL" ]
127151
then
128-
printf "${red}[ FAIL ]${normal} no URL provided. Usage: ./%s %s\n\n" "$SCRIPTNAME" "$SCRIPTDEMOURL"
152+
printf "${red}[ FAIL ]${normal} no URL provided. Usage: ./%s %s\n\n" "$SCRIPT_NAME" "$SCRIPT_DEMO_URL"
129153
exit 1
130154
fi
131155
else
@@ -139,7 +163,7 @@ if curl --output /dev/null --silent --head --fail "$URL"; then
139163
printf "\nStart processing the following url:\n\t${bold}%s${normal}\n\n" "$URL"
140164

141165
# start downloading (alt: youtube-dlc)
142-
youtube-dl -f bestaudio --extract-audio --restrict-filenames --write-description --newline --console-title --audio-format "$CONFIG_YTDL_AUDIOFORMAT" --audio-quality $CONFIG_YTDL_AUDIOQUALITY -o "%(playlist_index)s %(playlist)s - %(title)s.%(ext)s" $URL
166+
youtube-dl -f bestaudio --extract-audio --restrict-filenames --write-description --newline --console-title --audio-format "$CONFIG_YTDL_AUDIOFORMAT" --audio-quality $CONFIG_YTDL_AUDIOQUALITY -o "%(playlist_index)s-%(playlist)s---%(title)s.%(ext)s" $URL
143167
printf "\n${green}[ OK ]${normal} Finished processing the URL: $URL\n\n"
144168
showNotification "Finished downloading\n\t<a href='$URL'>$URL</a>"
145169
else

0 commit comments

Comments
 (0)