# Combine file variables into the full file name $download =~ s/&itag=\d+&signature=/&signature=/g $download = "$youtubeurl\&title=$titleurl" # Combine the YouTube URL and title string My ($youtubeurl) = $download =~ /(http?.+)/ # Clean up the URL by translating unicode and removing unwanted strings # This is where we look through the HTMl code and select the file type and # Print all of the separated strings in the HTML page My ($download) = $html =~ /"url_encoded_fmt_stream_map"(.*)/ig # Collect the URL of the video from the HTML page $title =~ s/+/_/g or die "\nError: we could not find the title of the HTML page.
While ( $retry != 0 & $retr圜ounter (.+)/si # Retry getting the video if the script fails for any reason $prefix = "$1" if ($user_prefix =~ m/^(+)$/ or die "\nError: Illegal characters in filename prefix\n\n" ) # Declare the user defined file name prefix if specified My $url = "$1" if ($user_url =~ m/^(+)$/ or die "\nError: Illegal characters in YouTube URL\n\n" ) # Collect the URL from the command line argument # Initialize retry loop and resolution variables # making changes or you are building your own YouTube download script. Use this to reverse engineering this code if you are This option simply puts "_hd1080.mp4" or similar at the # Option: do you want the resolution of the video in the file name? zero(0) is # any reason? Do not make this too high as a reoccurring error will just hit # Option: How many times should the script retry the download if wget fails for
# The script will always prefer to download the highest resolution video format # definition 640x380 and "itag=17" which is mobile resolution 144p (176x144). # script will look for the next resolution. # multiple values just in case the highest quality video is not available, the # Option: what visual resolution or quality do you want to download? List # work on the most players like Android, iPod, iPad, iPhones, VLC media player # in the YouTube URL so you can choose mp4, webm, avi or flv. # Option: what file type do you want to download? The string is used to search # $2 Prefix to the file name of the video (optional) # OS Support : Linux, Mac OSX, OpenBSD, FreeBSD or any system with perl
# ,:, Download YouTube videos and music using wget First, if you don't have wget, install it: sudo apt-get install wget