16
16
# ------------------------------------------------------------------------------
17
17
# DEFINE CONSTANTS - DON'T TOUCH
18
18
# ------------------------------------------------------------------------------
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
+
22
24
23
25
24
26
# ------------------------------------------------------------------------------
@@ -80,7 +82,7 @@ function reset() {
80
82
}
81
83
82
84
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 "
84
86
printf " ${bold} ----------------------------------------------------------${normal} \n"
85
87
}
86
88
@@ -89,8 +91,8 @@ function showNotification() {
89
91
then
90
92
printf " Notifications using notify-send is not supported - skipping ...\n"
91
93
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 "
94
96
fi
95
97
}
96
98
@@ -106,6 +108,24 @@ function checkIfExists() {
106
108
fi
107
109
}
108
110
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
+
109
129
110
130
# ------------------------------------------------------------------------------
111
131
# SCRIPT
@@ -114,18 +134,22 @@ reset # clear the screen
114
134
initColors # initialize the color and font formating variables
115
135
showHeader # show the script header
116
136
checkIfExists " youtube-dl"
137
+ checkIfExists " ffmpeg"
117
138
checkIfExists " zenity"
139
+ checkIfExists " curl"
140
+ checkIfExists " sed"
141
+ checkVersion
118
142
119
143
# Check if a parameter was supplied - if not stop execution
120
144
if [ -z " $1 " ]
121
145
then
122
146
printf " ${yellow} [ WARN ]${normal} no URL detected. Starting input dialog\n"
123
147
124
148
# 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:" )
126
150
if [ -z " $URL " ]
127
151
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 "
129
153
exit 1
130
154
fi
131
155
else
@@ -139,7 +163,7 @@ if curl --output /dev/null --silent --head --fail "$URL"; then
139
163
printf " \nStart processing the following url:\n\t${bold} %s${normal} \n\n" " $URL "
140
164
141
165
# 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
143
167
printf " \n${green} [ OK ]${normal} Finished processing the URL: $URL \n\n"
144
168
showNotification " Finished downloading\n\t<a href='$URL '>$URL </a>"
145
169
else
0 commit comments