about summary refs log tree commit diff
path: root/youtube_dl/extractor/globo.py
diff options
context:
space:
mode:
authorRemita Amine <remitamine@gmail.com>2019-10-09 11:07:46 +0100
committerRemita Amine <remitamine@gmail.com>2019-10-09 11:08:28 +0100
commitd4bb825b83a87813f54d007febd79d2f3dcee7b9 (patch)
tree7c9be28a2bcd80af692e962d8a3852d1d820b2f6 /youtube_dl/extractor/globo.py
parent560d3b7d7c86a0bfff36d59cb977fd3c01b10ad8 (diff)
downloadyoutube-dl-d4bb825b83a87813f54d007febd79d2f3dcee7b9.tar.gz
youtube-dl-d4bb825b83a87813f54d007febd79d2f3dcee7b9.tar.xz
youtube-dl-d4bb825b83a87813f54d007febd79d2f3dcee7b9.zip
[globo] fix format extraction(closes #20319)
Diffstat (limited to 'youtube_dl/extractor/globo.py')
-rw-r--r--youtube_dl/extractor/globo.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/youtube_dl/extractor/globo.py b/youtube_dl/extractor/globo.py
index fb8f7679b..b9c400a57 100644
--- a/youtube_dl/extractor/globo.py
+++ b/youtube_dl/extractor/globo.py
@@ -96,6 +96,8 @@ class GloboIE(InfoExtractor):
         video = self._download_json(
             'http://api.globovideos.com/videos/%s/playlist' % video_id,
             video_id)['videos'][0]
+        if video.get('encrypted') is True:
+            raise ExtractorError('This video is DRM protected.', expected=True)
 
         title = video['title']
 
@@ -109,8 +111,8 @@ class GloboIE(InfoExtractor):
             security = self._download_json(
                 'http://security.video.globo.com/videos/%s/hash' % video_id,
                 video_id, 'Downloading security hash for %s' % resource_id, query={
-                    'player': 'flash',
-                    'version': '17.0.0.132',
+                    'player': 'desktop',
+                    'version': '5.19.1',
                     'resource_id': resource_id,
                 })
 
@@ -122,19 +124,18 @@ class GloboIE(InfoExtractor):
                         '%s returned error: %s' % (self.IE_NAME, message), expected=True)
                 continue
 
-            hash_code = security_hash[:2]
-            received_time = security_hash[2:12]
-            received_random = security_hash[12:22]
-            received_md5 = security_hash[22:]
+            assert security_hash[:2] in ('04', '14')
+            received_time = security_hash[3:13]
+            received_md5 = security_hash[24:]
 
             sign_time = compat_str(int(received_time) + 86400)
             padding = '%010d' % random.randint(1, 10000000000)
 
-            md5_data = (received_md5 + sign_time + padding + '0xFF01DD').encode()
+            md5_data = (received_md5 + sign_time + padding + '0xAC10FD').encode()
             signed_md5 = base64.urlsafe_b64encode(hashlib.md5(md5_data).digest()).decode().strip('=')
-            signed_hash = hash_code + received_time + received_random + sign_time + padding + signed_md5
+            signed_hash = security_hash[:23] + sign_time + padding + signed_md5
 
-            signed_url = '%s?h=%s&k=%s' % (resource_url, signed_hash, 'flash')
+            signed_url = '%s?h=%s&k=html5&a=%s&u=%s' % (resource_url, signed_hash, 'F' if video.get('subscriber_only') else 'A', security.get('user') or '')
             if resource_id.endswith('m3u8') or resource_url.endswith('.m3u8'):
                 formats.extend(self._extract_m3u8_formats(
                     signed_url, resource_id, 'mp4', entry_protocol='m3u8_native',