+
+ # Attempt to download the file, and rescue and report
+ # any (predictable) exceptions.
+ begin
+ puts "Fetching #{video_url}"
+ puts "Saving as #{site.get_video_filename()}."
+ puts ""
+ uu.download_with_progress_bar(video_uri, site.get_video_filename())
+ 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)
+ end
+
+ # Write an empty line at the end for aesthetic reasons.
+ puts ""
+
+ Kernel.exit(EXIT_SUCCESS)