mouhsineelachbi

youtube-dl automatic download & convert youtube video to MP3

May 25th, 2014
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.09 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # This script downloads YouTube videos and converts them
  4. # You will end up with an MPG video and MP3 audio of each YouTube movie
  5. # You need to install the following three programs:
  6. # youtube_dl, ffmpeg, and mplayer
  7.  
  8. # Use this script at your own risk!
  9. # Make sure that you understand how it works before you use it!
  10.  
  11. # USAGE:
  12. # Make a file called videos.txt with the URL of 1 YouTube video on each line.
  13. # Don't leave any blank lines in the file
  14. # Put the videos.txt file in an empty folder along with this script
  15. # run this script with the following commands:
  16. # $ ./youtube_downloader.sh
  17. # It will take a long time to run, depending on
  18. # how many videos you have in your videos.txt file.
  19.  
  20. while read inputline
  21. do
  22.   youtube_url="$(echo $inputline)"
  23.   youtube-dl $youtube_url
  24. done < videos.txt
  25.  
  26. # Convert the flv files to mpg and mp3 files
  27. for i in *.flv
  28. do
  29.   ffmpeg -i $i $i.mpg
  30.   # comment out the next line if you don't want MP3's extracted
  31.   mplayer -dumpaudio $i -dumpfile $i.mp3
  32.   # The next line deletes all FLV files in the current directory to cleanup
  33.   rm $i
  34. done
Add Comment
Please, Sign In to add comment