text: #!/usr/bin/env python
  # -*- coding: utf-8 -*-
  """
  __author__ = 'AJay'
  __mtime__ = '2020/2/25 0025'
  
  """
  ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
  
  def base62_encode(num, alphabet=ALPHABET):
  
      if (num == 0):
          return alphabet[0]
      arr = []
      base = len(alphabet)
      while num:
          rem = num % base
          num = num // base
          arr.append(alphabet[rem])
      arr.reverse()
      return ''.join(arr)
  
  def base62_decode(string, alphabet=ALPHABET):
  
      base = len(alphabet)
      strlen = len(string)
      num = 0
  
      idx = 0
      for char in string:
          power = (strlen - (idx + 1))
          num += alphabet.index(char) * (base ** power)
          idx += 1
  
      return num
  
  
  def url_to_mid(url):
  
  
      url = str(url)[::-1]
      size = len(url) / 4 if len(url) % 4 == 0 else len(url) / 4 + 1
      result = []
      for i in range(int(size)):
          s = url[i * 4: (i + 1) * 4][::-1]
          s = str(base62_decode(str(s)))
          s_len = len(s)
          if i < size - 1 and s_len < 7:
              s = (7 - s_len) * '0' + s
          result.append(s)
      result.reverse()
      return int(''.join(result))
  
  def mid_to_url(midint):
  
      midint = str(midint)[::-1]
      size = len(midint) / 7 if len(midint) % 7 == 0 else len(midint) / 7 + 1
      result = []
      for i in range(int(size)):
          s = midint[i * 7: (i + 1) * 7][::-1]
          s = base62_encode(int(s))
          s_len = len(s)
          if i < size - 1 and len(s) < 4:
              s = '0' * (4 - s_len) + s
          result.append(s)
      result.reverse()
      return ''.join(result)
  
  if __name__ == '__main__':
      print(url_to_mid('IbhGya1EF'))
      print(mid_to_url('4474368756963230'))