aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/compat.py
diff options
context:
space:
mode:
authordirkf <fieldhouse@gmx.net>2023-07-04 16:06:21 +0100
committerdirkf <fieldhouse@gmx.net>2023-07-05 22:58:54 +0100
commitf24bc9272e9b74efc4c4af87c862f5f78921d424 (patch)
tree6454f8c8ab758b3e18f6d39395b91da822069819 /youtube_dl/compat.py
parentb08a58090635777f1001d5cde2cd141a5565177c (diff)
downloadyoutube-dl-f24bc9272e9b74efc4c4af87c862f5f78921d424.tar.xz
[Misc] Fixes for 2.6 compatibility
Diffstat (limited to 'youtube_dl/compat.py')
-rw-r--r--youtube_dl/compat.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/youtube_dl/compat.py b/youtube_dl/compat.py
index 0f4d3756f..2554fd1c3 100644
--- a/youtube_dl/compat.py
+++ b/youtube_dl/compat.py
@@ -1,10 +1,12 @@
# coding: utf-8
from __future__ import unicode_literals
+from __future__ import division
import base64
import binascii
import collections
import ctypes
+import datetime
import email
import getpass
import io
@@ -3150,6 +3152,15 @@ def compat_register_utf8():
lambda name: lookup('utf-8') if name == 'cp65001' else None)
+# compat_datetime_timedelta_total_seconds
+try:
+ compat_datetime_timedelta_total_seconds = datetime.timedelta.total_seconds
+except AttributeError:
+ # Py 2.6
+ def compat_datetime_timedelta_total_seconds(td):
+ return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6
+
+
legacy = [
'compat_HTMLParseError',
'compat_HTMLParser',
@@ -3187,6 +3198,7 @@ __all__ = [
'compat_chr',
'compat_collections_abc',
'compat_collections_chain_map',
+ 'compat_datetime_timedelta_total_seconds',
'compat_http_cookiejar',
'compat_http_cookiejar_Cookie',
'compat_http_cookies',