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