[periscope] pass referer to HLS requests(closes #29419)
authorRemita Amine <remitamine@gmail.com>
Mon, 28 Jun 2021 19:06:33 +0000 (20:06 +0100)
committerRemita Amine <remitamine@gmail.com>
Mon, 28 Jun 2021 19:08:39 +0000 (20:08 +0100)
youtube_dl/extractor/periscope.py

index b15906390d07715494b5653dce5499ca0ad72141..b93a02b7d5d5c587798698fc58264f705c7f0b81 100644 (file)
@@ -12,6 +12,10 @@ from ..utils import (
 
 
 class PeriscopeBaseIE(InfoExtractor):
+    _M3U8_HEADERS = {
+        'Referer': 'https://www.periscope.tv/'
+    }
+
     def _call_api(self, method, query, item_id):
         return self._download_json(
             'https://api.periscope.tv/api/v2/%s' % method,
@@ -54,9 +58,11 @@ class PeriscopeBaseIE(InfoExtractor):
             m3u8_url, video_id, 'mp4',
             entry_protocol='m3u8_native'
             if state in ('ended', 'timed_out') else 'm3u8',
-            m3u8_id=format_id, fatal=fatal)
+            m3u8_id=format_id, fatal=fatal, headers=self._M3U8_HEADERS)
         if len(m3u8_formats) == 1:
             self._add_width_and_height(m3u8_formats[0], width, height)
+        for f in m3u8_formats:
+            f.setdefault('http_headers', {}).update(self._M3U8_HEADERS)
         return m3u8_formats