title: Too many arguments error in bash script
body: <p>I have modified this script to download songs from YouTube but I am getting the following error when I run it like this:</p>
  
  <pre><code>sh youtube2mp3.sh https://www.youtube.com/watch?v=gpOJ6iu8fqQ
  </code></pre>
  
  <p><strong>Errors:</strong></p>
  
  <pre><code>youtube2mp3.sh: line 31: [: too many arguments
  youtube2mp3.sh: line 39: [: too many arguments
  youtube2mp3.sh: line 49: [: too many arguments
  Sorry but the system encountered a problem.
  </code></pre>
  
  <p>The line numbers are referring to the three <code>if [ -f  $video_title.$ext1 ]</code> lines ... I thought I had the arguments ok as it worked in a previous version, but I'm stuck at this point — could someone explain what I need to do to correct it? </p>
  
  <pre><code>address=$1
  
  video_title="$(python youtube-dl $address)"
  
  ext1="flv"
  ext2="mp4"
  ext3="webm"
  
  
  
  if [ -f  $video_title.$ext1 ]
  then
      ffmpeg -i $video_title.$ext1 "$video_title".wav
      lame "$video_title".wav "$video_title".mp3
      rm $video_title.$ext1 "$video_title".wav
  else
      if [ -f $video_title.$ext2 ]
      then
          ffmpeg -i $video_title.$ext2 "$video_title".wav
          lame "$video_title".wav "$video_title".mp3
          rm $video_title.$ext2 "$video_title".wav
      else    
          if [ -f $video_title.$ext3 ]
          then
              ffmpeg -i $video_title.$ext3 -acodec libmp3lame -aq 4 "$video_title".mp3
              rm $video_title.$ext3
          else
              echo "Sorry but the system encountered a problem." 
          fi
  
      fi
  fi
  </code></pre>