about summary refs log tree commit diff
path: root/youtube_dl/YoutubeDL.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2021-03-10 03:36:31 +0700
committerSergey M․ <dstftw@gmail.com>2021-03-10 03:36:31 +0700
commit477bff69065872fff6bab5c3a1b0512018fbb6eb (patch)
treed8b63d6d605da361566d4d44a002406697a7f53e /youtube_dl/YoutubeDL.py
parent1a1ccd9a6e8e9e90ab129e89c2524ab3eb9ed2ae (diff)
downloadyoutube-dl-477bff69065872fff6bab5c3a1b0512018fbb6eb.tar.gz
youtube-dl-477bff69065872fff6bab5c3a1b0512018fbb6eb.tar.xz
youtube-dl-477bff69065872fff6bab5c3a1b0512018fbb6eb.zip
Introduce release_timestamp meta field (refs #28386)
Diffstat (limited to 'youtube_dl/YoutubeDL.py')
-rwxr-xr-xyoutube_dl/YoutubeDL.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py
index ecac31f7a..8f65c6499 100755
--- a/youtube_dl/YoutubeDL.py
+++ b/youtube_dl/YoutubeDL.py
@@ -1511,14 +1511,18 @@ class YoutubeDL(object):
         if 'display_id' not in info_dict and 'id' in info_dict:
             info_dict['display_id'] = info_dict['id']
 
-        if info_dict.get('upload_date') is None and info_dict.get('timestamp') is not None:
-            # Working around out-of-range timestamp values (e.g. negative ones on Windows,
-            # see http://bugs.python.org/issue1646728)
-            try:
-                upload_date = datetime.datetime.utcfromtimestamp(info_dict['timestamp'])
-                info_dict['upload_date'] = upload_date.strftime('%Y%m%d')
-            except (ValueError, OverflowError, OSError):
-                pass
+        for ts_key, date_key in (
+                ('timestamp', 'upload_date'),
+                ('release_timestamp', 'release_date'),
+        ):
+            if info_dict.get(date_key) is None and info_dict.get(ts_key) is not None:
+                # Working around out-of-range timestamp values (e.g. negative ones on Windows,
+                # see http://bugs.python.org/issue1646728)
+                try:
+                    upload_date = datetime.datetime.utcfromtimestamp(info_dict[ts_key])
+                    info_dict[date_key] = upload_date.strftime('%Y%m%d')
+                except (ValueError, OverflowError, OSError):
+                    pass
 
         # Auto generate title fields corresponding to the *_number fields when missing
         # in order to always have clean titles. This is very common for TV series.