2 from __future__ import unicode_literals
4 from .common import InfoExtractor
15 class MinhatecaIE(InfoExtractor):
16 _VALID_URL = r'https?://minhateca\.com\.br/[^?#]+,(?P<id>[0-9]+)\.'
18 'url': 'http://minhateca.com.br/pereba/misc/youtube-dl+test+video,125848331.mp4(video)',
22 'title': 'youtube-dl test video',
23 'thumbnail': 're:^https?://.*\.jpg$',
24 'filesize_approx': 1530000,
30 def _real_extract(self, url):
31 video_id = self._match_id(url)
32 webpage = self._download_webpage(url, video_id)
34 token = self._html_search_regex(
35 r'<input name="__RequestVerificationToken".*?value="([^"]+)"',
36 webpage, 'request token')
39 ('__RequestVerificationToken', token),
41 req = compat_urllib_request.Request(
42 'http://minhateca.com.br/action/License/Download',
43 data=compat_urllib_parse.urlencode(token_data))
44 req.add_header('Content-Type', 'application/x-www-form-urlencoded')
45 data = self._download_json(
46 req, video_id, note='Downloading metadata')
48 video_url = data['redirectUrl']
49 title_str = self._html_search_regex(
50 r'<h1.*?>(.*?)</h1>', webpage, 'title')
51 title, _, ext = title_str.rpartition('.')
52 filesize_approx = parse_filesize(self._html_search_regex(
53 r'<p class="fileSize">(.*?)</p>',
54 webpage, 'file size approximation', fatal=False))
55 duration = int_or_none(self._html_search_regex(
56 r'(?s)<p class="fileLeng[ht][th]">.*?([0-9]+)\s*s',
57 webpage, 'duration', fatal=False))
58 view_count = int_or_none(self._html_search_regex(
59 r'<p class="downloadsCounter">([0-9]+)</p>',
60 webpage, 'view count', fatal=False))
67 'filesize_approx': filesize_approx,
69 'view_count': view_count,
70 'thumbnail': self._og_search_thumbnail(webpage),