]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/playvid.py
   1 from __future__ 
import unicode_literals
 
   5 from .common 
import InfoExtractor
 
  15 class PlayvidIE(InfoExtractor
): 
  16     _VALID_URL 
= r
'https?://www\.playvid\.com/watch(\?v=|/)(?P<id>.+?)(?:#|$)' 
  18         'url': 'http://www.playvid.com/watch/RnmBNgtrrJu', 
  19         'md5': 'ffa2f6b2119af359f544388d8c01eb6c', 
  23             'title': 'md5:9256d01c6317e3f703848b5906880dc8', 
  29     def _real_extract(self
, url
): 
  30         video_id 
= self
._match
_id
(url
) 
  31         webpage 
= self
._download
_webpage
(url
, video_id
) 
  34             r
'<div class="block-error">\s*<div class="heading">\s*<div>(?P<msg>.+?)</div>\s*</div>', webpage
) 
  36             raise ExtractorError(clean_html(m_error
.group('msg')), expected
=True) 
  40         video_thumbnail 
= None 
  43         # most of the information is stored in the flashvars 
  44         flashvars 
= self
._html
_search
_regex
( 
  45             r
'flashvars="(.+?)"', webpage
, 'flashvars') 
  47         infos 
= compat_urllib_parse
.unquote(flashvars
).split(r
'&') 
  49             videovars_match 
= re
.match(r
'^video_vars\[(.+?)\]=(.+?)$', info
) 
  51                 key 
= videovars_match
.group(1) 
  52                 val 
= videovars_match
.group(2) 
  55                     video_title 
= compat_urllib_parse
.unquote_plus(val
) 
  61                 if key 
== 'big_thumb': 
  64                 videourl_match 
= re
.match( 
  65                     r
'^video_urls\]\[(?P<resolution>[0-9]+)p', key
) 
  67                     height 
= int(videourl_match
.group('resolution')) 
  72         self
._sort
_formats
(formats
) 
  74         # Extract title - should be in the flashvars; if not, look elsewhere 
  75         if video_title 
is None: 
  76             video_title 
= self
._html
_search
_regex
( 
  77                 r
'<title>(.*?)</title', webpage
, 'title') 
  83             'thumbnail': video_thumbnail
,