]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/vshare.py
   2 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
   7 from ..compat 
import compat_chr
 
  14 class VShareIE(InfoExtractor
): 
  15     _VALID_URL 
= r
'https?://(?:www\.)?vshare\.io/[dv]/(?P<id>[^/?#&]+)' 
  17         'url': 'https://vshare.io/d/0f64ce6', 
  18         'md5': '17b39f55b5497ae8b59f5fbce8e35886', 
  21             'title': 'vl14062007715967', 
  25         'url': 'https://vshare.io/v/0f64ce6/width-650/height-430/1', 
  26         'only_matching': True, 
  30     def _extract_urls(webpage
): 
  32             r
'<iframe[^>]+?src=["\'](?P
<url
>(?
:https?
:)?
//(?
:www\
.)?vshare\
.io
/v
/[^
/?
#&]+)', 
  35     def _extract_packed(self
, webpage
): 
  36         packed 
= self
._search
_regex
( 
  37             r
'(eval\(function.+)', webpage
, 'packed code') 
  38         unpacked 
= decode_packed_codes(packed
) 
  39         digits 
= self
._search
_regex
(r
'\[((?:\d+,?)+)\]', unpacked
, 'digits') 
  40         digits 
= [int(digit
) for digit 
in digits
.split(',')] 
  41         key_digit 
= self
._search
_regex
( 
  42             r
'fromCharCode\(.+?(\d+)\)}', unpacked
, 'key digit') 
  43         chars 
= [compat_chr(d 
- int(key_digit
)) for d 
in digits
] 
  46     def _real_extract(self
, url
): 
  47         video_id 
= self
._match
_id
(url
) 
  49         webpage 
= self
._download
_webpage
( 
  50             'https://vshare.io/v/%s/width-650/height-430/1' % video_id
, 
  53         title 
= self
._html
_search
_regex
( 
  54             r
'<title>([^<]+)</title>', webpage
, 'title') 
  55         title 
= title
.split(' - ')[0] 
  57         error 
= self
._html
_search
_regex
( 
  58             r
'(?s)<div[^>]+\bclass=["\']xxx
-error
[^
>]+>(.+?
)</div
', webpage, 
  59             'error
', default=None) 
  61             raise ExtractorError(error, expected=True) 
  63         info = self._parse_html5_media_entries( 
  64             url, '<video
>%s</video
>' % self._extract_packed(webpage), 
  67         self._sort_formats(info['formats
'])