+ puts 'Error retrieving video URL:'
+ puts "Site not supported, and the generic parser couldn't find any videos."
+ exit(EXIT_COULDNT_GET_VIDEO_URL) end
+
+ # The Downloader class is a factory; it should decide
+ # which subclass we get.
+ downloader = Downloader.create(Configuration::DOWNLOAD_METHOD)
+
+ # Attempt to download the file, and rescue and report
+ # any (predictable) exceptions. The wget downloader will
+ # naturally not report any of these, since it will die in
+ # its own process.
+ begin
+ downloader.download(video_url,
+ site.get_video_filename(),
+ site.headers(),
+ continue=options[:continue])
+ rescue Errno::ECONNREFUSED => e
+ puts 'The connection to the server (to download the video file) was refused. Check your connection, and try again later.'
+ Kernel.exit(EXIT_CONNECTION_REFUSED)
+ rescue Errno::EACCES => e
+ puts "Access denied. Check that you have write permission to the output file/directory. Details: #{e.message}."
+ rescue OpenURI::HTTPError => e
+ puts "An HTTP error occurred while downloading the video file: #{e.message}."
+ Kernel.exit(EXIT_HTTP_ERROR)
+ rescue IOError => e
+ puts "Input/Output Error: #{e.message}"
+ Kernel.exit(EXIT_IO_ERROR)