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