]> jfr.im git - yt-dlp.git/commitdiff
Update to ytdl-commit-a803582
authorpukkandan <redacted>
Tue, 6 Jul 2021 23:47:11 +0000 (05:17 +0530)
committerpukkandan <redacted>
Tue, 6 Jul 2021 23:47:11 +0000 (05:17 +0530)
[peertube] only call description endpoint if necessary
https://github.com/ytdl-org/youtube-dl/commit/a8035827177d6b59aca03bd717acb6a9bdd75ada

yt_dlp/extractor/peertube.py
yt_dlp/extractor/periscope.py

index d9b13adc211d3623d3594e16ccdb0f4454fe4d4c..3af533925c6ad9af98b31a911048ba86fa9ca140 100644 (file)
@@ -569,15 +569,15 @@ def _real_extract(self, url):
             formats.append(f)
         self._sort_formats(formats)
 
-        full_description = self._call_api(
-            host, video_id, 'description', note='Downloading description JSON',
-            fatal=False)
+        description = video.get('description')
+        if len(description) >= 250:
+            # description is shortened
+            full_description = self._call_api(
+                host, video_id, 'description', note='Downloading description JSON',
+                fatal=False)
 
-        description = None
-        if isinstance(full_description, dict):
-            description = str_or_none(full_description.get('description'))
-        if not description:
-            description = video.get('description')
+            if isinstance(full_description, dict):
+                description = str_or_none(full_description.get('description')) or description
 
         subtitles = self.extract_subtitles(host, video_id)
 
index b15906390d07715494b5653dce5499ca0ad72141..b93a02b7d5d5c587798698fc58264f705c7f0b81 100644 (file)
 
 
 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 @@ def _extract_pscp_m3u8_formats(self, m3u8_url, video_id, format_id, state, width
             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