+
+# 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
+ msg = 'The connection to the server (to download the video file) '
+ msg += 'was refused. Check your connection, and try again later.'
+ log.error(msg)
+ Kernel.exit(ExitCodes::EXIT_CONNECTION_REFUSED)
+
+rescue Errno::EACCES => e
+ msg = 'Access denied. Check that you have write permission '
+ msg += "to the output file/directory. Details: #{e.message}."
+ log.error(msg)
+ Kernel.exit(ExitCodes::EXIT_ACCESS_DENIED)
+
+rescue OpenURI::HTTPError => e
+ msg = 'An HTTP error occurred while downloading '
+ msg += " the video file: #{e.message}."
+ log.error(msg)
+ Kernel.exit(ExitCodes::EXIT_HTTP_ERROR)
+
+rescue IOError => e
+ log.error("Input/Output Error: #{e.message}")
+ Kernel.exit(ExitCodes::EXIT_IO_ERROR)
+
+end
+
+# Write an empty line at the end for aesthetic reasons.
+puts ''
+
+Kernel.exit(ExitCodes::EXIT_SUCCESS)