]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/adn.py
[ie/youtube] Extract upload timestamp if available (#9856)
[yt-dlp.git] / yt_dlp / extractor / adn.py
index ed23226a35225d81b2514b3a6a379c3590e8e908..2f3b67dad4cb2216839fae2e3a723fec9d3a4576 100644 (file)
@@ -3,23 +3,25 @@
 import json
 import os
 import random
+import time
 
 from .common import InfoExtractor
 from ..aes import aes_cbc_decrypt_bytes, unpad_pkcs7
 from ..compat import compat_b64decode
 from ..networking.exceptions import HTTPError
 from ..utils import (
+    ExtractorError,
     ass_subtitles_timecode,
     bytes_to_intlist,
     bytes_to_long,
-    ExtractorError,
     float_or_none,
     int_or_none,
     intlist_to_bytes,
     long_to_bytes,
+    parse_iso8601,
     pkcs1pad,
-    strip_or_none,
     str_or_none,
+    strip_or_none,
     try_get,
     unified_strdate,
     urlencode_postdata,
@@ -185,7 +187,10 @@ def _real_extract(self, url):
 
         user = options['user']
         if not user.get('hasAccess'):
-            self.raise_login_required()
+            start_date = traverse_obj(options, ('video', 'startDate', {str}))
+            if (parse_iso8601(start_date) or 0) > time.time():
+                raise ExtractorError(f'This video is not available yet. Release date: {start_date}', expected=True)
+            self.raise_login_required('This video requires a subscription', method='password')
 
         token = self._download_json(
             user.get('refreshTokenUrl') or (self._PLAYER_BASE_URL + 'refresh/token'),
@@ -267,6 +272,9 @@ def _real_extract(self, url):
                         f['language'] = 'de'
                 formats.extend(m3u8_formats)
 
+        if not formats:
+            self.raise_login_required('This video requires a subscription', method='password')
+
         video = (self._download_json(
             self._API_BASE_URL + 'video/%s' % video_id, video_id,
             'Downloading additional video metadata', fatal=False) or {}).get('video') or {}