From 15ee7bce5e1f8f924305c721cf2ccc3a35192702 Mon Sep 17 00:00:00 2001 From: tommieharyanto Date: Tue, 2 Oct 2018 11:05:46 +0700 Subject: [PATCH] Make regex pattern more discriminating --- youtube/youtube2mp3.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube/youtube2mp3.sh b/youtube/youtube2mp3.sh index 6c832cd..95108d2 100755 --- a/youtube/youtube2mp3.sh +++ b/youtube/youtube2mp3.sh @@ -2,7 +2,7 @@ # A very simple Bash script to download a YouTube video # and extract the music file from it. address=$1 -regex='v=(.*)' +regex='v=([A-Za-z0-9_-]{11})' if [[ $address =~ $regex ]]; then video_id=${BASH_REMATCH[1]} video_id=$(echo $video_id | cut -d'&' -f1)