浏览代码

[YoutubeDL] Do not override id, extractor and extractor_key in url_transparent
All these meta fields must be borrowed from final extractor that actually performs extraction.
This commit fixes extractor id in download archives for url_transparent downloads. Previously, 'transparent' extractor was erroneously
used for extractor archive id, e.g. 'eggheadlesson 4n8ugwwj5t' instead of 'wistia 4n8ugwwj5t'.

Sergey M․ 8 年之前
父节点
当前提交
0396806f67
共有 2 个文件被更改,包括 7 次插入2 次删除
  1. 6 1
      test/test_YoutubeDL.py
  2. 1 1
      youtube_dl/YoutubeDL.py

+ 6 - 1
test/test_YoutubeDL.py

@@ -41,6 +41,7 @@ def _make_result(formats, **kwargs):
         'id': 'testid',
         'id': 'testid',
         'title': 'testttitle',
         'title': 'testttitle',
         'extractor': 'testex',
         'extractor': 'testex',
+        'extractor_key': 'TestEx',
     }
     }
     res.update(**kwargs)
     res.update(**kwargs)
     return res
     return res
@@ -761,7 +762,8 @@ class TestYoutubeDL(unittest.TestCase):
                     '_type': 'url_transparent',
                     '_type': 'url_transparent',
                     'url': 'foo2:',
                     'url': 'foo2:',
                     'ie_key': 'Foo2',
                     'ie_key': 'Foo2',
-                    'title': 'foo1 title'
+                    'title': 'foo1 title',
+                    'id': 'foo1_id',
                 }
                 }
 
 
         class Foo2IE(InfoExtractor):
         class Foo2IE(InfoExtractor):
@@ -787,6 +789,9 @@ class TestYoutubeDL(unittest.TestCase):
         downloaded = ydl.downloaded_info_dicts[0]
         downloaded = ydl.downloaded_info_dicts[0]
         self.assertEqual(downloaded['url'], TEST_URL)
         self.assertEqual(downloaded['url'], TEST_URL)
         self.assertEqual(downloaded['title'], 'foo1 title')
         self.assertEqual(downloaded['title'], 'foo1 title')
+        self.assertEqual(downloaded['id'], 'testid')
+        self.assertEqual(downloaded['extractor'], 'testex')
+        self.assertEqual(downloaded['extractor_key'], 'TestEx')
 
 
 
 
 if __name__ == '__main__':
 if __name__ == '__main__':

+ 1 - 1
youtube_dl/YoutubeDL.py

@@ -860,7 +860,7 @@ class YoutubeDL(object):
 
 
             force_properties = dict(
             force_properties = dict(
                 (k, v) for k, v in ie_result.items() if v is not None)
                 (k, v) for k, v in ie_result.items() if v is not None)
-            for f in ('_type', 'url', 'ie_key'):
+            for f in ('_type', 'url', 'id', 'extractor', 'extractor_key', 'ie_key'):
                 if f in force_properties:
                 if f in force_properties:
                     del force_properties[f]
                     del force_properties[f]
             new_result = info.copy()
             new_result = info.copy()