]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/openload.py
   2 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
   7 from ..compat 
import compat_chr
 
  16 class OpenloadIE(InfoExtractor
): 
  17     _VALID_URL 
= r
'https://openload.(?:co|io)/(?:f|embed)/(?P<id>[a-zA-Z0-9-_]+)' 
  20         'url': 'https://openload.co/f/kUEfGclsU9o', 
  21         'md5': 'bf1c059b004ebc7a256f89408e65c36e', 
  25             'title': 'skyrim_no-audio_1080.mp4', 
  26             'thumbnail': 're:^https?://.*\.jpg$', 
  29         'url': 'https://openload.co/embed/kUEfGclsU9o/skyrim_no-audio_1080.mp4', 
  30         'only_matching': True, 
  32         'url': 'https://openload.io/f/ZAn6oz-VZGE/', 
  33         'only_matching': True, 
  35         'url': 'https://openload.co/f/_-ztPaZtMhM/', 
  36         'only_matching': True, 
  38         # unavailable via https://openload.co/f/Sxz5sADo82g/, different layout 
  40         'url': 'https://openload.co/embed/Sxz5sADo82g/', 
  41         'only_matching': True, 
  45     def openload_level2_debase(m
): 
  46         radix
, num 
= int(m
.group(1)) + 27, int(m
.group(2)) 
  47         return '"' + encode_base_n(num
, radix
) + '"' 
  50     def openload_level2(cls
, txt
): 
  51         # The function name is ǃ \u01c3 
  52         # Using escaped unicode literals does not work in Python 3.2 
  53         return re
.sub(r
'ǃ\((\d+),(\d+)\)', cls
.openload_level2_debase
, txt
, re
.UNICODE
).replace('"+"', '') 
  55     # Openload uses a variant of aadecode 
  56     # openload_decode and related functions are originally written by 
  57     # vitas@matfyz.cz and released with public domain 
  58     # See https://github.com/rg3/youtube-dl/issues/8489 
  60     def openload_decode(cls
, txt
): 
  63             ('a', '(゚Д゚) [゚ω゚ノ]'), 
  64             ('b', '(゚Д゚) [゚Θ゚ノ]'), 
  65             ('c', '(゚Д゚) [\'c\']'), 
  66             ('d', '(゚Д゚) [゚ー゚ノ]'), 
  67             ('e', '(゚Д゚) [゚Д゚ノ]'), 
  70             ('o', '(゚Д゚) [\'o\']'), 
  72             ('c', '(゚Д゚) [\'c\']'), 
  74             ('7', '((゚ー゚) + (o^_^o))'), 
  75             ('6', '((o^_^o) +(o^_^o) +(c^_^o))'), 
  76             ('5', '((゚ー゚) + (゚Θ゚))'), 
  81             ('0', '((c^_^o)-(c^_^o))'), 
  85         for aachar 
in txt
.split(delim
): 
  86             for val
, pat 
in symbol_table
: 
  87                 aachar 
= aachar
.replace(pat
, val
) 
  88             aachar 
= aachar
.replace('+ ', '') 
  89             m 
= re
.match(r
'^\d+', aachar
) 
  91                 ret 
+= compat_chr(int(m
.group(0), 8)) 
  93                 m 
= re
.match(r
'^u([\da-f]+)', aachar
) 
  95                     ret 
+= compat_chr(int(m
.group(1), 16)) 
  96         return cls
.openload_level2(ret
) 
  98     def _real_extract(self
, url
): 
  99         video_id 
= self
._match
_id
(url
) 
 100         webpage 
= self
._download
_webpage
(url
, video_id
) 
 102         if 'File not found' in webpage
: 
 103             raise ExtractorError('File not found', expected
=True) 
 105         code 
= self
._search
_regex
( 
 106             r
'</video>\s*</div>\s*<script[^>]+>[^>]+</script>\s*<script[^>]+>([^<]+)</script>', 
 109         decoded 
= self
.openload_decode(code
) 
 111         video_url 
= self
._search
_regex
( 
 112             r
'return\s+"(https?://[^"]+)"', decoded
, 'video URL') 
 114         title 
= self
._og
_search
_title
(webpage
, default
=None) or self
._search
_regex
( 
 115             r
'<span[^>]+class=["\']title
["\'][^>]*>([^<]+)', webpage, 
 116             'title', default=None) or self._html_search_meta( 
 117             'description', webpage, 'title', fatal=True) 
 119         ext = mimetype2ext(self._search_regex( 
 120             r'window\.vt\s*=\s*(["\'])(?P
<mimetype
>.+?
)\
1', decoded, 
 121             'mimetype
', default=None, group='mimetype
')) or determine_ext( 
 128             'thumbnail
': self._og_search_thumbnail(webpage, default=None),