]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/minhateca.py
   2 from __future__ 
import unicode_literals
 
   4 from .common 
import InfoExtractor
 
  16 class MinhatecaIE(InfoExtractor
): 
  17     _VALID_URL 
= r
'https?://minhateca\.com\.br/[^?#]+,(?P<id>[0-9]+)\.' 
  19         'url': 'http://minhateca.com.br/pereba/misc/youtube-dl+test+video,125848331.mp4(video)', 
  23             'title': 'youtube-dl test video', 
  24             'thumbnail': 're:^https?://.*\.jpg$', 
  25             'filesize_approx': 1530000, 
  31     def _real_extract(self
, url
): 
  32         video_id 
= self
._match
_id
(url
) 
  33         webpage 
= self
._download
_webpage
(url
, video_id
) 
  35         token 
= self
._html
_search
_regex
( 
  36             r
'<input name="__RequestVerificationToken".*?value="([^"]+)"', 
  37             webpage
, 'request token') 
  40             ('__RequestVerificationToken', token
), 
  42         req 
= compat_urllib_request
.Request( 
  43             'http://minhateca.com.br/action/License/Download', 
  44             data
=compat_urllib_parse
.urlencode(token_data
)) 
  45         req
.add_header('Content-Type', 'application/x-www-form-urlencoded') 
  46         data 
= self
._download
_json
( 
  47             req
, video_id
, note
='Downloading metadata') 
  49         video_url 
= data
['redirectUrl'] 
  50         title_str 
= self
._html
_search
_regex
( 
  51             r
'<h1.*?>(.*?)</h1>', webpage
, 'title') 
  52         title
, _
, ext 
= title_str
.rpartition('.') 
  53         filesize_approx 
= parse_filesize(self
._html
_search
_regex
( 
  54             r
'<p class="fileSize">(.*?)</p>', 
  55             webpage
, 'file size approximation', fatal
=False)) 
  56         duration 
= parse_duration(self
._html
_search
_regex
( 
  57             r
'(?s)<p class="fileLeng[ht][th]">.*?class="bold">(.*?)<', 
  58             webpage
, 'duration', fatal
=False)) 
  59         view_count 
= int_or_none(self
._html
_search
_regex
( 
  60             r
'<p class="downloadsCounter">([0-9]+)</p>', 
  61             webpage
, 'view count', fatal
=False)) 
  68             'filesize_approx': filesize_approx
, 
  70             'view_count': view_count
, 
  71             'thumbnail': self
._og
_search
_thumbnail
(webpage
),