]> jfr.im git - yt-dlp.git/commitdiff
[extractor] Support merging subtitles with data
authorcoletdjnz <redacted>
Fri, 11 Mar 2022 22:20:58 +0000 (11:20 +1300)
committercoletdjnz <redacted>
Fri, 11 Mar 2022 22:22:28 +0000 (11:22 +1300)
Authored-by: coletdjnz
yt_dlp/extractor/common.py

index 3548144330fca4520202d8194ca9cf5c9b90345d..345da9a72318bfdc2dc50bc32d74313a56d20fe2 100644 (file)
@@ -3651,11 +3651,11 @@ def _get_comments(self, *args, **kwargs):
 
     @staticmethod
     def _merge_subtitle_items(subtitle_list1, subtitle_list2):
-        """ Merge subtitle items for one language. Items with duplicated URLs
+        """ Merge subtitle items for one language. Items with duplicated URLs/data
         will be dropped. """
-        list1_urls = set([item['url'] for item in subtitle_list1])
+        list1_data = set([item.get('url') or item['data'] for item in subtitle_list1])
         ret = list(subtitle_list1)
-        ret.extend([item for item in subtitle_list2 if item['url'] not in list1_urls])
+        ret.extend([item for item in subtitle_list2 if (item.get('url') or item['data']) not in list1_data])
         return ret
 
     @classmethod