[compat] Add compat_datetime_from_timestamp (#11902)
Authored by: pzhlkj6612, seproDev Co-authored-by: sepro <sepro@sepr0.com>
This commit is contained in:
parent
e6e6b51214
commit
6a763a55d8
5 changed files with 77 additions and 15 deletions
|
|
@ -2717,11 +2717,7 @@ class YoutubeDL:
|
|||
('modified_timestamp', 'modified_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)
|
||||
with contextlib.suppress(ValueError, OverflowError, OSError):
|
||||
upload_date = dt.datetime.fromtimestamp(info_dict[ts_key], dt.timezone.utc)
|
||||
info_dict[date_key] = upload_date.strftime('%Y%m%d')
|
||||
info_dict[date_key] = strftime_or_none(info_dict[ts_key])
|
||||
|
||||
if not info_dict.get('release_year'):
|
||||
info_dict['release_year'] = traverse_obj(info_dict, ('release_date', {lambda x: int(x[:4])}))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue