-video_url_params = extract_step('Extracting video URL parameters', 'unable to extract URL parameters', const_video_url_params_re, video_webpage)
-video_url_real = const_video_url_real_str % video_url_params
+video_url_t_param = extract_step('Extracting URL "t" parameter', 'unable to extract URL "t" parameter', const_url_t_param_re, video_webpage)
+video_url_real = const_video_url_real_str % (video_url_id, video_url_t_param)
+if cmdl_opts.best_quality:
+ video_url_real = '%s%s' % (video_url_real, const_video_url_best_quality_suffix)
+
+# Rebuild filename if needed
+if cmdl_opts.use_title or cmdl_opts.use_literal:
+ if cmdl_opts.use_title:
+ prefix = title_string_norm(video_title)
+ else:
+ prefix = title_string_touch(video_title)
+ video_filename = '%s-%s%s' % (prefix, video_url_id, video_extension)
+
+# Check name
+if not video_filename.lower().endswith(video_extension):
+ sys.stderr.write('Warning: video file name does not end in %s\n' % video_extension)