]> jfr.im git - yt-dlp.git/blobdiff - youtube_dlc/extractor/youtube.py
[viki] Fix extractor (Closes #91)
[yt-dlp.git] / youtube_dlc / extractor / youtube.py
index 4a2f5f06b5574b020b2febd0c3d31cd69411e935..b2b02f5e2b89a3e4a27f58133f738a6f8904a323 100644 (file)
@@ -32,7 +32,7 @@
     mimetype2ext,
     parse_codecs,
     parse_duration,
-    # qualities,  # TODO: Enable this after fixing formatSort
+    qualities,
     remove_start,
     smuggle_url,
     str_or_none,
@@ -1528,8 +1528,7 @@ def feed_entry(name):
         itags = []
         itag_qualities = {}
         player_url = None
-        # TODO: Enable this after fixing formatSort
-        # q = qualities(['tiny', 'small', 'medium', 'large', 'hd720', 'hd1080', 'hd1440', 'hd2160', 'hd2880', 'highres'])
+        q = qualities(['tiny', 'small', 'medium', 'large', 'hd720', 'hd1080', 'hd1440', 'hd2160', 'hd2880', 'highres'])
         streaming_data = player_response.get('streamingData') or {}
         streaming_formats = streaming_data.get('formats') or []
         streaming_formats.extend(streaming_data.get('adaptiveFormats') or [])
@@ -1577,7 +1576,7 @@ def feed_entry(name):
                 'format_note': fmt.get('qualityLabel') or quality,
                 'fps': int_or_none(fmt.get('fps')),
                 'height': int_or_none(fmt.get('height')),
-                # 'quality': q(quality),    # TODO: Enable this after fixing formatSort
+                'quality': q(quality),
                 'tbr': tbr,
                 'url': fmt_url,
                 'width': fmt.get('width'),
@@ -1620,8 +1619,11 @@ def feed_entry(name):
                     itag = f['format_id']
                     if itag in itags:
                         continue
-                    # if itag in itag_qualities:  # TODO: Enable this after fixing formatSort
-                    #     f['quality'] = q(itag_qualities[itag])
+                    if itag in itag_qualities:
+                        # Not actually usefull since the sorting is already done with "quality,res,fps,codec"
+                        # but kept to maintain feature parity (and code similarity) with youtube-dl
+                        # Remove if this causes any issues with sorting in future
+                        f['quality'] = q(itag_qualities[itag])
                     filesize = int_or_none(self._search_regex(
                         r'/clen/(\d+)', f.get('fragment_base_url')
                         or f['url'], 'file size', default=None))
@@ -2076,7 +2078,7 @@ def get_continuation(continuation, session_token, replies=False):
                     comment = meta_comment['commentThreadRenderer']['comment']['commentRenderer']
                     video_comments.append({
                         'id': comment['commentId'],
-                        'text': ''.join([c['text'] for c in comment['contentText']['runs']]),
+                        'text': ''.join([c['text'] for c in try_get(comment, lambda x: x['contentText']['runs'], list) or []]),
                         'time_text': ''.join([c['text'] for c in comment['publishedTimeText']['runs']]),
                         'author': comment.get('authorText', {}).get('simpleText', ''),
                         'votes': comment.get('voteCount', {}).get('simpleText', '0'),