+video_url = site.get_video_url()
+
+if video_url.nil?
+ msg = 'Error retrieving video URL: '
+ msg += "Site not supported, and the generic parser couldn't find any videos."
+ log.error(msg)
+ exit(ExitCodes::EXIT_COULDNT_GET_VIDEO_URL)
+end
+
+# The Downloader class is a factory; it should decide
+# which subclass we get.
+puts "download_method: #{cfg.download_method}"
+downloader = Downloader.create(cfg.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)
+