浏览代码

[theplatform] Add support for referer protected videos wuth explicit SMIL

Sergey M․ 9 年之前
父节点
当前提交
18e4088fad
共有 1 个文件被更改,包括 10 次插入4 次删除
  1. 10 4
      youtube_dl/extractor/theplatform.py

+ 10 - 4
youtube_dl/extractor/theplatform.py

@@ -16,11 +16,12 @@ from ..compat import (
 from ..utils import (
 from ..utils import (
     determine_ext,
     determine_ext,
     ExtractorError,
     ExtractorError,
-    xpath_with_ns,
-    unsmuggle_url,
+    float_or_none,
     int_or_none,
     int_or_none,
+    sanitized_Request,
+    unsmuggle_url,
     url_basename,
     url_basename,
-    float_or_none,
+    xpath_with_ns,
 )
 )
 
 
 default_ns = 'http://www.w3.org/2005/SMIL21/Language'
 default_ns = 'http://www.w3.org/2005/SMIL21/Language'
@@ -204,7 +205,12 @@ class ThePlatformIE(ThePlatformBaseIE):
             smil_url = url
             smil_url = url
         # Explicitly specified SMIL (see https://github.com/rg3/youtube-dl/issues/7385)
         # Explicitly specified SMIL (see https://github.com/rg3/youtube-dl/issues/7385)
         elif '/guid/' in url:
         elif '/guid/' in url:
-            webpage = self._download_webpage(url, video_id)
+            headers = {}
+            source_url = smuggled_data.get('source_url')
+            if source_url:
+                headers['Referer'] = source_url
+            request = sanitized_Request(url, headers=headers)
+            webpage = self._download_webpage(request, video_id)
             smil_url = self._search_regex(
             smil_url = self._search_regex(
                 r'<link[^>]+href=(["\'])(?P<url>.+?)\1[^>]+type=["\']application/smil\+xml',
                 r'<link[^>]+href=(["\'])(?P<url>.+?)\1[^>]+type=["\']application/smil\+xml',
                 webpage, 'smil url', group='url')
                 webpage, 'smil url', group='url')