aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
authorYen Chi Hsuan <yan12125@gmail.com>2016-02-24 22:08:40 +0800
committerYen Chi Hsuan <yan12125@gmail.com>2016-02-26 14:26:26 +0800
commit81bdc8fdf6516b05bc3a26f82eacb1889f5e46d5 (patch)
treeb1f707f5f19a737ef06982b868b1df9a7b2a997c /youtube_dl/utils.py
parente048d87fc9b5cfa19806649faf20fc1a7bdb82a6 (diff)
downloadyoutube-dl-81bdc8fdf6516b05bc3a26f82eacb1889f5e46d5.tar.xz
[utils] Move base62 to utils
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r--youtube_dl/utils.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index a3df90fad..d7a1586c0 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -2619,3 +2619,17 @@ def ohdave_rsa_encrypt(data, exponent, modulus):
payload = int(binascii.hexlify(data[::-1]), 16)
encrypted = pow(payload, exponent, modulus)
return '%x' % encrypted
+
+
+def base_n(num, n, table):
+ if num == 0:
+ return '0'
+ ret = ''
+ while num:
+ ret = table[num % n] + ret
+ num = num // n
+ return ret
+
+
+def base62(num):
+ return base_n(num, 62, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')