]>
Commit | Line | Data |
---|---|---|
031ec536 | 1 | # coding: utf-8 |
617c0b22 | 2 | from __future__ import unicode_literals |
3 | ||
4 | import re | |
5 | ||
6 | from .common import InfoExtractor | |
1cc79574 | 7 | from ..utils import ( |
bccdac68 | 8 | decode_packed_codes, |
2cd668ee | 9 | determine_ext, |
1cc79574 | 10 | ExtractorError, |
ceb33673 | 11 | int_or_none, |
bccdac68 | 12 | NO_DEFAULT, |
6e6bc8da | 13 | urlencode_postdata, |
5f28a1ac PP |
14 | ) |
15 | ||
617c0b22 | 16 | |
031ec536 | 17 | class XFileShareIE(InfoExtractor): |
41745523 | 18 | _SITES = ( |
2dc48df5 S |
19 | (r'daclips\.(?:in|com)', 'DaClips'), |
20 | (r'filehoot\.com', 'FileHoot'), | |
21 | (r'gorillavid\.(?:in|com)', 'GorillaVid'), | |
22 | (r'movpod\.in', 'MovPod'), | |
23 | (r'powerwatch\.pw', 'PowerWatch'), | |
24 | (r'rapidvideo\.ws', 'Rapidvideo.ws'), | |
25 | (r'thevideobee\.to', 'TheVideoBee'), | |
beff0950 | 26 | (r'vidto\.(?:me|se)', 'Vidto'), |
2dc48df5 S |
27 | (r'streamin\.to', 'Streamin.To'), |
28 | (r'xvidstage\.com', 'XVIDSTAGE'), | |
29 | (r'vidabc\.com', 'Vid ABC'), | |
30 | (r'vidbom\.com', 'VidBom'), | |
31 | (r'vidlo\.us', 'vidlo'), | |
534863e0 | 32 | (r'rapidvideo\.(?:cool|org)', 'RapidVideo.TV'), |
0ea6efbb | 33 | (r'fastvideo\.me', 'FastVideo.me'), |
41745523 S |
34 | ) |
35 | ||
36 | IE_DESC = 'XFileShare based sites: %s' % ', '.join(list(zip(*_SITES))[1]) | |
37 | _VALID_URL = (r'https?://(?P<host>(?:www\.)?(?:%s))/(?:embed-)?(?P<id>[0-9a-zA-Z]+)' | |
2dc48df5 | 38 | % '|'.join(site for site in list(zip(*_SITES))[0])) |
5f28a1ac | 39 | |
33b72ce6 S |
40 | _FILE_NOT_FOUND_REGEXES = ( |
41 | r'>(?:404 - )?File Not Found<', | |
42 | r'>The file was removed by administrator<', | |
43 | ) | |
3ae165aa | 44 | |
5f28a1ac PP |
45 | _TESTS = [{ |
46 | 'url': 'http://gorillavid.in/06y9juieqpmi', | |
47 | 'md5': '5ae4a3580620380619678ee4875893ba', | |
48 | 'info_dict': { | |
49 | 'id': '06y9juieqpmi', | |
cf2bf840 | 50 | 'ext': 'mp4', |
e4b85e35 | 51 | 'title': 'Rebecca Black My Moment Official Music Video Reaction-6GK87Rc8bzQ', |
ec85ded8 | 52 | 'thumbnail': r're:http://.*\.jpg', |
5f28a1ac PP |
53 | }, |
54 | }, { | |
55 | 'url': 'http://gorillavid.in/embed-z08zf8le23c6-960x480.html', | |
1ed34f3d | 56 | 'only_matching': True, |
953b3586 PH |
57 | }, { |
58 | 'url': 'http://daclips.in/3rso4kdn6f9m', | |
aaefb347 | 59 | 'md5': '1ad8fd39bb976eeb66004d3a4895f106', |
953b3586 PH |
60 | 'info_dict': { |
61 | 'id': '3rso4kdn6f9m', | |
62 | 'ext': 'mp4', | |
2e9ff8f3 | 63 | 'title': 'Micro Pig piglets ready on 16th July 2009-bG0PdrCdxUc', |
ec85ded8 | 64 | 'thumbnail': r're:http://.*\.jpg', |
2e9ff8f3 | 65 | } |
b81f484b PH |
66 | }, { |
67 | 'url': 'http://movpod.in/0wguyyxi1yca', | |
68 | 'only_matching': True, | |
c7c0996d S |
69 | }, { |
70 | 'url': 'http://filehoot.com/3ivfabn7573c.html', | |
71 | 'info_dict': { | |
72 | 'id': '3ivfabn7573c', | |
73 | 'ext': 'mp4', | |
74 | 'title': 'youtube-dl test video \'äBaW_jenozKc.mp4.mp4', | |
ec85ded8 | 75 | 'thumbnail': r're:http://.*\.jpg', |
436214ba YCH |
76 | }, |
77 | 'skip': 'Video removed', | |
668db403 S |
78 | }, { |
79 | 'url': 'http://vidto.me/ku5glz52nqe1.html', | |
80 | 'info_dict': { | |
81 | 'id': 'ku5glz52nqe1', | |
82 | 'ext': 'mp4', | |
83 | 'title': 'test' | |
84 | } | |
1ad61430 S |
85 | }, { |
86 | 'url': 'http://powerwatch.pw/duecjibvicbu', | |
87 | 'info_dict': { | |
88 | 'id': 'duecjibvicbu', | |
89 | 'ext': 'mp4', | |
90 | 'title': 'Big Buck Bunny trailer', | |
91 | }, | |
bccdac68 S |
92 | }, { |
93 | 'url': 'http://xvidstage.com/e0qcnl03co6z', | |
94 | 'info_dict': { | |
95 | 'id': 'e0qcnl03co6z', | |
96 | 'ext': 'mp4', | |
97 | 'title': 'Chucky Prank 2015.mp4', | |
98 | }, | |
33b72ce6 S |
99 | }, { |
100 | # removed by administrator | |
101 | 'url': 'http://xvidstage.com/amfy7atlkx25', | |
102 | 'only_matching': True, | |
2cd668ee S |
103 | }, { |
104 | 'url': 'http://vidabc.com/i8ybqscrphfv', | |
105 | 'info_dict': { | |
106 | 'id': 'i8ybqscrphfv', | |
107 | 'ext': 'mp4', | |
108 | 'title': 're:Beauty and the Beast 2017', | |
109 | }, | |
110 | 'params': { | |
111 | 'skip_download': True, | |
112 | }, | |
534863e0 S |
113 | }, { |
114 | 'url': 'http://www.rapidvideo.cool/b667kprndr8w', | |
115 | 'only_matching': True, | |
0ea6efbb | 116 | }, { |
117 | 'url': 'http://www.fastvideo.me/k8604r8nk8sn/FAST_FURIOUS_8_-_Trailer_italiano_ufficiale.mp4.html', | |
beff0950 S |
118 | 'only_matching': True, |
119 | }, { | |
120 | 'url': 'http://vidto.se/1tx1pf6t12cg.html', | |
121 | 'only_matching': True, | |
5f28a1ac | 122 | }] |
617c0b22 | 123 | |
178ee883 S |
124 | @staticmethod |
125 | def _extract_urls(webpage): | |
126 | return [ | |
127 | mobj.group('url') | |
128 | for mobj in re.finditer( | |
129 | r'<iframe\b[^>]+\bsrc=(["\'])(?P<url>(?:https?:)?//(?:%s)/embed-[0-9a-zA-Z]+.*?)\1' | |
130 | % '|'.join(site for site in list(zip(*XFileShareIE._SITES))[0]), | |
131 | webpage)] | |
132 | ||
617c0b22 | 133 | def _real_extract(self, url): |
134 | mobj = re.match(self._VALID_URL, url) | |
135 | video_id = mobj.group('id') | |
136 | ||
e213c98d S |
137 | url = 'http://%s/%s' % (mobj.group('host'), video_id) |
138 | webpage = self._download_webpage(url, video_id) | |
617c0b22 | 139 | |
33b72ce6 | 140 | if any(re.search(p, webpage) for p in self._FILE_NOT_FOUND_REGEXES): |
3ae165aa S |
141 | raise ExtractorError('Video %s does not exist' % video_id, expected=True) |
142 | ||
f8da79f8 | 143 | fields = self._hidden_inputs(webpage) |
5f6a1245 | 144 | |
5f28a1ac | 145 | if fields['op'] == 'download1': |
ceb33673 S |
146 | countdown = int_or_none(self._search_regex( |
147 | r'<span id="countdown_str">(?:[Ww]ait)?\s*<span id="cxc">(\d+)</span>\s*(?:seconds?)?</span>', | |
148 | webpage, 'countdown', default=None)) | |
149 | if countdown: | |
150 | self._sleep(countdown, video_id) | |
151 | ||
16bc9582 S |
152 | webpage = self._download_webpage( |
153 | url, video_id, 'Downloading video page', | |
154 | data=urlencode_postdata(fields), headers={ | |
155 | 'Referer': url, | |
156 | 'Content-type': 'application/x-www-form-urlencoded', | |
157 | }) | |
5f28a1ac | 158 | |
668db403 | 159 | title = (self._search_regex( |
190d2027 | 160 | (r'style="z-index: [0-9]+;">([^<]+)</span>', |
b9ad1019 | 161 | r'<td nowrap>([^<]+)</td>', |
1ad61430 | 162 | r'h4-fine[^>]*>([^<]+)<', |
b9ad1019 | 163 | r'>Watch (.+) ', |
190d2027 S |
164 | r'<h2 class="video-page-head">([^<]+)</h2>', |
165 | r'<h2 style="[^"]*color:#403f3d[^"]*"[^>]*>([^<]+)<'), # streamin.to | |
166 | webpage, 'title', default=None) or self._og_search_title( | |
167 | webpage, default=None) or video_id).strip() | |
bccdac68 | 168 | |
2cd668ee S |
169 | def extract_formats(default=NO_DEFAULT): |
170 | urls = [] | |
171 | for regex in ( | |
02d61a65 | 172 | r'(?:file|src)\s*:\s*(["\'])(?P<url>http(?:(?!\1).)+\.(?:m3u8|mp4|flv)(?:(?!\1).)*)\1', |
2cd668ee S |
173 | r'file_link\s*=\s*(["\'])(?P<url>http(?:(?!\1).)+)\1', |
174 | r'addVariable\((\\?["\'])file\1\s*,\s*(\\?["\'])(?P<url>http(?:(?!\2).)+)\2\)', | |
175 | r'<embed[^>]+src=(["\'])(?P<url>http(?:(?!\1).)+\.(?:m3u8|mp4|flv)(?:(?!\1).)*)\1'): | |
176 | for mobj in re.finditer(regex, webpage): | |
177 | video_url = mobj.group('url') | |
178 | if video_url not in urls: | |
179 | urls.append(video_url) | |
180 | formats = [] | |
181 | for video_url in urls: | |
182 | if determine_ext(video_url) == 'm3u8': | |
183 | formats.extend(self._extract_m3u8_formats( | |
184 | video_url, video_id, 'mp4', | |
185 | entry_protocol='m3u8_native', m3u8_id='hls', | |
186 | fatal=False)) | |
187 | else: | |
188 | formats.append({ | |
189 | 'url': video_url, | |
190 | 'format_id': 'sd', | |
191 | }) | |
192 | if not formats and default is not NO_DEFAULT: | |
193 | return default | |
194 | self._sort_formats(formats) | |
195 | return formats | |
196 | ||
197 | formats = extract_formats(default=None) | |
198 | ||
199 | if not formats: | |
bccdac68 S |
200 | webpage = decode_packed_codes(self._search_regex( |
201 | r"(}\('(.+)',(\d+),(\d+),'[^']*\b(?:file|embed)\b[^']*'\.split\('\|'\))", | |
202 | webpage, 'packed code')) | |
2cd668ee | 203 | formats = extract_formats() |
bccdac68 | 204 | |
ceb33673 | 205 | thumbnail = self._search_regex( |
b9ad1019 | 206 | r'image\s*:\s*["\'](http[^"\']+)["\'],', webpage, 'thumbnail', default=None) |
5f28a1ac | 207 | |
5f28a1ac | 208 | return { |
617c0b22 | 209 | 'id': video_id, |
210 | 'title': title, | |
5f28a1ac PP |
211 | 'thumbnail': thumbnail, |
212 | 'formats': formats, | |
617c0b22 | 213 | } |