]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/curiositystream.py
[ie/crunchyroll] Fix stream extraction (#10005)
[yt-dlp.git] / yt_dlp / extractor / curiositystream.py
index b8abcf7a5a517b5ba2103807ddbf6e97f2110c2f..941cf4e79c9549e4adef4ababae2a576809cdee4 100644 (file)
@@ -1,15 +1,9 @@
-# coding: utf-8
-from __future__ import unicode_literals
-
 import re
+import urllib.parse
 
 from .common import InfoExtractor
-from ..utils import (
-    int_or_none,
-    urlencode_postdata,
-    compat_str,
-    ExtractorError,
-)
+from ..compat import compat_str
+from ..utils import ExtractorError, int_or_none, urlencode_postdata
 
 
 class CuriosityStreamBaseIE(InfoExtractor):
@@ -26,6 +20,11 @@ def _handle_errors(self, result):
 
     def _call_api(self, path, video_id, query=None):
         headers = {}
+        if not self._auth_token:
+            auth_cookie = self._get_cookies('https://curiositystream.com').get('auth_token')
+            if auth_cookie:
+                self.write_debug('Obtained auth_token cookie')
+                self._auth_token = urllib.parse.unquote(auth_cookie.value)
         if self._auth_token:
             headers['X-Auth-Token'] = self._auth_token
         result = self._download_json(
@@ -48,7 +47,7 @@ class CuriosityStreamIE(CuriosityStreamBaseIE):
     IE_NAME = 'curiositystream'
     _VALID_URL = r'https?://(?:app\.)?curiositystream\.com/video/(?P<id>\d+)'
     _TESTS = [{
-        'url': 'https://app.curiositystream.com/video/2',
+        'url': 'http://app.curiositystream.com/video/2',
         'info_dict': {
             'id': '2',
             'ext': 'mp4',
@@ -56,8 +55,11 @@ class CuriosityStreamIE(CuriosityStreamBaseIE):
             'description': 'Vint Cerf, Google\'s Chief Internet Evangelist, describes how he and Bob Kahn created the internet.',
             'channel': 'Curiosity Stream',
             'categories': ['Technology', 'Interview'],
-            'average_rating': 96.79,
+            'average_rating': float,
             'series_id': '2',
+            'thumbnail': r're:https://img.curiositystream.com/.+\.jpg',
+            'tags': [],
+            'duration': 158
         },
         'params': {
             # m3u8 download
@@ -119,7 +121,6 @@ def _real_extract(self, url):
                             'format_id': 'http',
                         })
                     formats.append(fmt)
-        self._sort_formats(formats)
 
         title = media['title']