- if is_live and self.get_param('live_from_start'):
- self._prepare_live_from_start_formats(formats, video_id, live_start_time, url, webpage_url, smuggled_data)
+ needs_live_processing = self._needs_live_processing(live_status, duration)
+
+ def is_bad_format(fmt):
+ if needs_live_processing and not fmt.get('is_from_start'):
+ return True
+ elif (live_status == 'is_live' and needs_live_processing != 'is_live'
+ and fmt.get('protocol') == 'http_dash_segments'):
+ return True
+
+ for fmt in filter(is_bad_format, formats):
+ fmt['preference'] = (fmt.get('preference') or -1) - 10
+ fmt['format_note'] = join_nonempty(fmt.get('format_note'), '(Last 4 hours)', delim=' ')
+
+ if needs_live_processing:
+ self._prepare_live_from_start_formats(
+ formats, video_id, live_start_time, url, webpage_url, smuggled_data, live_status == 'is_live')