]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[theplatform] Some NBC videos require an additional cookie
authorYen Chi Hsuan <yan12125@gmail.com>
Wed, 8 Jun 2016 12:47:39 +0000 (20:47 +0800)
committerYen Chi Hsuan <yan12125@gmail.com>
Wed, 8 Jun 2016 12:47:39 +0000 (20:47 +0800)
Related: #9578

youtube_dl/extractor/theplatform.py

index 02dbef91335a7b7cd40caac1be55ca908107c7a8..5793ec6efb4e9a1abe54470c4602a68f073e51ae 100644 (file)
@@ -14,11 +14,13 @@ from ..compat import (
     compat_urllib_parse_urlparse,
 )
 from ..utils import (
+    determine_ext,
     ExtractorError,
     float_or_none,
     int_or_none,
     sanitized_Request,
     unsmuggle_url,
+    update_url_query,
     xpath_with_ns,
     mimetype2ext,
     find_xpath_attr,
@@ -48,6 +50,12 @@ class ThePlatformBaseIE(OnceIE):
             if OnceIE.suitable(_format['url']):
                 formats.extend(self._extract_once_formats(_format['url']))
             else:
+                media_url = _format['url']
+                if determine_ext(media_url) == 'm3u8':
+                    hdnea2 = self._get_cookies(media_url).get('hdnea2')
+                    if hdnea2:
+                        _format['url'] = update_url_query(media_url, {'hdnea3': hdnea2.value})
+
                 formats.append(_format)
 
         subtitles = self._parse_smil_subtitles(meta, default_ns)