[peertube] only call description endpoint if necessary (#29383) master
authorbopol <bopol@e.email>
Thu, 1 Jul 2021 06:53:22 +0000 (08:53 +0200)
committerGitHub <noreply@github.com>
Thu, 1 Jul 2021 06:53:22 +0000 (06:53 +0000)
youtube_dl/extractor/peertube.py

index d9b13adc211d3623d3594e16ccdb0f4454fe4d4c..3af533925c6ad9af98b31a911048ba86fa9ca140 100644 (file)
@@ -569,15 +569,15 @@ class PeerTubeIE(InfoExtractor):
             formats.append(f)
         self._sort_formats(formats)
 
             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)
 
 
         subtitles = self.extract_subtitles(host, video_id)