2 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from ..compat import compat_chr
8 from ..utils import encode_base_n
11 class OpenloadIE(InfoExtractor):
12 _VALID_URL = r'https://openload.co/f/(?P<id>[a-zA-Z0-9]+)'
15 'url': 'https://openload.co/f/kUEfGclsU9o',
16 'md5': 'bf1c059b004ebc7a256f89408e65c36e',
20 'title': 'skyrim_no-audio_1080.mp4',
25 def openload_level2_debase(m):
26 radix, num = int(m.group(1)) + 27, int(m.group(2))
27 return '"' + encode_base_n(num, radix) + '"'
30 def openload_level2(cls, txt):
31 # The function name is ǃ \u01c3
32 # Using escaped unicode literals does not work in Python 3.2
33 return re.sub(r'ǃ\((\d+),(\d+)\)', cls.openload_level2_debase, txt, re.UNICODE).replace('"+"', '')
35 # Openload uses a variant of aadecode
36 # openload_decode and related functions are originally written by
37 # vitas@matfyz.cz and released with public domain
38 # See https://github.com/rg3/youtube-dl/issues/8489
40 def openload_decode(cls, txt):
43 ('a', '(゚Д゚) [゚ω゚ノ]'),
44 ('b', '(゚Д゚) [゚Θ゚ノ]'),
45 ('c', '(゚Д゚) [\'c\']'),
46 ('d', '(゚Д゚) [゚ー゚ノ]'),
47 ('e', '(゚Д゚) [゚Д゚ノ]'),
50 ('o', '(゚Д゚) [\'o\']'),
52 ('c', '(゚Д゚) [\'c\']'),
54 ('7', '((゚ー゚) + (o^_^o))'),
55 ('6', '((o^_^o) +(o^_^o) +(c^_^o))'),
56 ('5', '((゚ー゚) + (゚Θ゚))'),
61 ('0', '((c^_^o)-(c^_^o))'),
65 for aachar in txt.split(delim):
66 for val, pat in symbol_table:
67 aachar = aachar.replace(pat, val)
68 aachar = aachar.replace('+ ', '')
69 m = re.match(r'^\d+', aachar)
71 ret += compat_chr(int(m.group(0), 8))
73 m = re.match(r'^u([\da-f]+)', aachar)
75 ret += compat_chr(int(m.group(1), 16))
76 return cls.openload_level2(ret)
78 def _real_extract(self, url):
79 video_id = self._match_id(url)
80 webpage = self._download_webpage(url, video_id)
81 code = self._search_regex(
82 r'<video[^>]+>\s*<script[^>]+>([^<]+)</script>',
85 video_url = self._search_regex(
86 r'return\s+"(https?://[^"]+)"', self.openload_decode(code), 'video URL')
90 'title': self._og_search_title(webpage),