Merge pull request #7691 from ryandesign/use-PYTHON-env-var
[youtube-dl] / youtube_dl / extractor / youtube.py
index 726b5ba0aa009ab5a8f871cb8d37deebc1b5d651..52f4fe36da295263db437ea412ff0dad07d4f430 100644 (file)
@@ -1475,6 +1475,11 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
             manifest_url = video_info['hlsvp'][0]
             url_map = self._extract_from_m3u8(manifest_url, video_id)
             formats = _map_to_format_list(url_map)
+            # Accept-Encoding header causes failures in live streams on Youtube and Youtube Gaming
+            for a_format in formats:
+                if 'http_headers' not in a_format:
+                    a_format['http_headers'] = {}
+                a_format['http_headers']['Youtubedl-no-compression'] = True
         else:
             raise ExtractorError('no conn, hlsvp or url_encoded_fmt_stream_map information found in video info')
 
@@ -1514,8 +1519,10 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
         if stretched_m:
             w = float(stretched_m.group('w'))
             h = float(stretched_m.group('h'))
+            # yt:stretch may hold invalid ratio data (e.g. for Q39EVAstoRM ratio is 17:0).
+            # We will only process correct ratios.
             if w > 0 and h > 0:
-                ratio = float(stretched_m.group('w')) / float(stretched_m.group('h'))
+                ratio = w / h
                 for f in formats:
                     if f.get('vcodec') != 'none':
                         f['stretched_ratio'] = ratio