- # The following decryption algorithm is written by @yokrysty and
- # declared to be freely used in youtube-dl
- # See https://github.com/rg3/youtube-dl/issues/10408
- enc_data = self._html_search_regex(
- r'<span[^>]*>([^<]+)</span>\s*<span[^>]*>[^<]+</span>\s*<span[^>]+id="streamurl"',
- webpage, 'encrypted data')
-
- enc_code = self._html_search_regex(r'<script[^>]+>(゚ω゚[^<]+)</script>',
- webpage, 'encrypted code')
-
- js_code = self.openload_decode(enc_code)
- jsi = JSInterpreter(js_code)
-
- m_offset_fun = self._search_regex(r'slice\(0\s*-\s*(%s)\(\)' % _NAME_RE, js_code, 'javascript offset function')
- m_diff_fun = self._search_regex(r'charCodeAt\(0\)\s*\+\s*(%s)\(\)' % _NAME_RE, js_code, 'javascript diff function')
-
- offset = jsi.call_function(m_offset_fun)
- diff = jsi.call_function(m_diff_fun)
-
- video_url_chars = []
-
- for idx, c in enumerate(enc_data):
- j = compat_ord(c)
- if j >= 33 and j <= 126:
- j = ((j + 14) % 94) + 33
- if idx == len(enc_data) - offset:
- j += diff
- video_url_chars += compat_chr(j)
-
- video_url = 'https://openload.co/stream/%s?mime=true' % ''.join(video_url_chars)
+ ol_id = self._search_regex(
+ '<span[^>]+id="[^"]+"[^>]*>([0-9A-Za-z]+)</span>',
+ webpage, 'openload ID')
+
+ decoded = ''
+ a = ol_id[0:24]
+ b = []
+ for i in range(0, len(a), 8):
+ b.append(int(a[i:i + 8] or '0', 16))
+ ol_id = ol_id[24:]
+ j = 0
+ k = 0
+ while j < len(ol_id):
+ c = 128
+ d = 0
+ e = 0
+ f = 0
+ _more = True
+ while _more:
+ if j + 1 >= len(ol_id):
+ c = 143
+ f = int(ol_id[j:j + 2] or '0', 16)
+ j += 2
+ d += (f & 127) << e
+ e += 7
+ _more = f >= c
+ g = d ^ b[k % 3]
+ for i in range(4):
+ char_dec = (g >> 8 * i) & (c + 127)
+ char = compat_chr(char_dec)
+ if char != '#':
+ decoded += char
+ k += 1
+
+ video_url = 'https://openload.co/stream/%s?mime=true'
+ video_url = video_url % decoded