]>
Commit | Line | Data |
---|---|---|
5f28a1ac | 1 | # -*- coding: utf-8 -*- |
617c0b22 | 2 | from __future__ import unicode_literals |
3 | ||
4 | import re | |
5 | ||
6 | from .common import InfoExtractor | |
5f28a1ac | 7 | from ..utils import ( |
e4b85e35 | 8 | ExtractorError, |
5f28a1ac PP |
9 | determine_ext, |
10 | compat_urllib_parse, | |
11 | compat_urllib_request, | |
12 | ) | |
13 | ||
617c0b22 | 14 | |
15 | class GorillaVidIE(InfoExtractor): | |
b81f484b | 16 | IE_DESC = 'GorillaVid.in, daclips.in and movpod.in' |
953b3586 | 17 | _VALID_URL = r'''(?x) |
aaefb347 | 18 | https?://(?P<host>(?:www\.)? |
b81f484b | 19 | (?:daclips\.in|gorillavid\.in|movpod\.in))/ |
953b3586 PH |
20 | (?:embed-)?(?P<id>[0-9a-zA-Z]+)(?:-[0-9]+x[0-9]+\.html)? |
21 | ''' | |
5f28a1ac | 22 | |
3ae165aa S |
23 | _FILE_NOT_FOUND_REGEX = r'>(?:404 - )?File Not Found<' |
24 | ||
5f28a1ac PP |
25 | _TESTS = [{ |
26 | 'url': 'http://gorillavid.in/06y9juieqpmi', | |
27 | 'md5': '5ae4a3580620380619678ee4875893ba', | |
28 | 'info_dict': { | |
29 | 'id': '06y9juieqpmi', | |
30 | 'ext': 'flv', | |
e4b85e35 | 31 | 'title': 'Rebecca Black My Moment Official Music Video Reaction-6GK87Rc8bzQ', |
5f28a1ac PP |
32 | 'thumbnail': 're:http://.*\.jpg', |
33 | }, | |
34 | }, { | |
35 | 'url': 'http://gorillavid.in/embed-z08zf8le23c6-960x480.html', | |
77abae55 | 36 | 'md5': 'c9e293ca74d46cad638e199c3f3fe604', |
617c0b22 | 37 | 'info_dict': { |
77abae55 | 38 | 'id': 'z08zf8le23c6', |
39 | 'ext': 'mp4', | |
40 | 'title': 'Say something nice', | |
5f28a1ac PP |
41 | 'thumbnail': 're:http://.*\.jpg', |
42 | }, | |
953b3586 PH |
43 | }, { |
44 | 'url': 'http://daclips.in/3rso4kdn6f9m', | |
aaefb347 | 45 | 'md5': '1ad8fd39bb976eeb66004d3a4895f106', |
953b3586 PH |
46 | 'info_dict': { |
47 | 'id': '3rso4kdn6f9m', | |
48 | 'ext': 'mp4', | |
2e9ff8f3 | 49 | 'title': 'Micro Pig piglets ready on 16th July 2009-bG0PdrCdxUc', |
953b3586 | 50 | 'thumbnail': 're:http://.*\.jpg', |
2e9ff8f3 | 51 | } |
b81f484b PH |
52 | }, { |
53 | 'url': 'http://movpod.in/0wguyyxi1yca', | |
54 | 'only_matching': True, | |
5f28a1ac | 55 | }] |
617c0b22 | 56 | |
57 | def _real_extract(self, url): | |
58 | mobj = re.match(self._VALID_URL, url) | |
59 | video_id = mobj.group('id') | |
60 | ||
aaefb347 | 61 | webpage = self._download_webpage('http://%s/%s' % (mobj.group('host'), video_id), video_id) |
617c0b22 | 62 | |
3ae165aa S |
63 | if re.search(self._FILE_NOT_FOUND_REGEX, webpage) is not None: |
64 | raise ExtractorError('Video %s does not exist' % video_id, expected=True) | |
65 | ||
5f28a1ac PP |
66 | fields = dict(re.findall(r'''(?x)<input\s+ |
67 | type="hidden"\s+ | |
68 | name="([^"]+)"\s+ | |
69 | (?:id="[^"]+"\s+)? | |
70 | value="([^"]*)" | |
71 | ''', webpage)) | |
5f6a1245 | 72 | |
5f28a1ac PP |
73 | if fields['op'] == 'download1': |
74 | post = compat_urllib_parse.urlencode(fields) | |
75 | ||
76 | req = compat_urllib_request.Request(url, post) | |
77 | req.add_header('Content-type', 'application/x-www-form-urlencoded') | |
617c0b22 | 78 | |
5f28a1ac PP |
79 | webpage = self._download_webpage(req, video_id, 'Downloading video page') |
80 | ||
e4b85e35 S |
81 | title = self._search_regex(r'style="z-index: [0-9]+;">([^<]+)</span>', webpage, 'title') |
82 | video_url = self._search_regex(r'file\s*:\s*\'(http[^\']+)\',', webpage, 'file url') | |
83 | thumbnail = self._search_regex(r'image\s*:\s*\'(http[^\']+)\',', webpage, 'thumbnail', fatal=False) | |
5f28a1ac PP |
84 | |
85 | formats = [{ | |
86 | 'format_id': 'sd', | |
e4b85e35 S |
87 | 'url': video_url, |
88 | 'ext': determine_ext(video_url), | |
5f28a1ac PP |
89 | 'quality': 1, |
90 | }] | |
91 | ||
92 | return { | |
617c0b22 | 93 | 'id': video_id, |
94 | 'title': title, | |
5f28a1ac PP |
95 | 'thumbnail': thumbnail, |
96 | 'formats': formats, | |
617c0b22 | 97 | } |