Merge remote-tracking branch 'rzhxeo/youporn-hd'
[youtube-dl] / youtube_dl / utils.py
index 64ab3091070013f840e44bf6c29a808fa75c47d1..b3d0f64ea9162876f5cd3d517ef77a9b631c781e 100644 (file)
@@ -743,3 +743,21 @@ def platform_name():
 
     assert isinstance(res, compat_str)
     return res
+
+
+def bytes_to_intlist(bs):
+    if not bs:
+        return []
+    if isinstance(bs[0], int):  # Python 3
+        return list(bs)
+    else:
+        return [ord(c) for c in bs]
+
+
+def intlist_to_bytes(xs):
+    if not xs:
+        return b''
+    if isinstance(chr(0), bytes):  # Python 2
+        return ''.join([chr(x) for x in xs])
+    else:
+        return bytes(xs)