]>
Commit | Line | Data |
---|---|---|
cc253000 | 1 | from __future__ import unicode_literals |
2 | ||
3 | import re | |
4 | ||
5 | from .common import InfoExtractor | |
5c2266df | 6 | from ..compat import compat_urlparse |
cc253000 | 7 | from ..utils import ( |
8 | ExtractorError, | |
82393e2b | 9 | NO_DEFAULT, |
5c2266df | 10 | sanitized_Request, |
82393e2b | 11 | urlencode_postdata, |
cc253000 | 12 | ) |
13 | ||
10bff13a | 14 | |
ce78943a S |
15 | class NovaMovIE(InfoExtractor): |
16 | IE_NAME = 'novamov' | |
17 | IE_DESC = 'NovaMov' | |
18 | ||
56019444 S |
19 | _VALID_URL_TEMPLATE = r'''(?x) |
20 | http:// | |
21 | (?: | |
22 | (?:www\.)?%(host)s/(?:file|video|mobile/\#/videos)/| | |
23 | (?:(?:embed|www)\.)%(host)s/embed(?:\.php|/)?\?(?:.*?&)?\bv= | |
24 | ) | |
25 | (?P<id>[a-z\d]{13}) | |
26 | ''' | |
ec85ded8 | 27 | _VALID_URL = _VALID_URL_TEMPLATE % {'host': r'novamov\.com'} |
ce78943a S |
28 | |
29 | _HOST = 'www.novamov.com' | |
30 | ||
31 | _FILE_DELETED_REGEX = r'This file no longer exists on our servers!</h2>' | |
47c7f3d9 | 32 | _FILEKEY_REGEX = r'flashvars\.filekey=(?P<filekey>"?[^"]+"?);' |
ce78943a S |
33 | _TITLE_REGEX = r'(?s)<div class="v_tab blockborder rounded5" id="v_tab1">\s*<h3>([^<]+)</h3>' |
34 | _DESCRIPTION_REGEX = r'(?s)<div class="v_tab blockborder rounded5" id="v_tab1">\s*<h3>[^<]+</h3><p>([^<]+)</p>' | |
47c7f3d9 | 35 | _URL_TEMPLATE = 'http://%s/video/%s' |
cc253000 | 36 | |
e7d77efb | 37 | _TEST = None |
cc253000 | 38 | |
b5424acd YCH |
39 | def _check_existence(self, webpage, video_id): |
40 | if re.search(self._FILE_DELETED_REGEX, webpage) is not None: | |
41 | raise ExtractorError('Video %s does not exist' % video_id, expected=True) | |
42 | ||
cc253000 | 43 | def _real_extract(self, url): |
699ed30c | 44 | video_id = self._match_id(url) |
cc253000 | 45 | |
47c7f3d9 | 46 | url = self._URL_TEMPLATE % (self._HOST, video_id) |
cc253000 | 47 | |
82393e2b S |
48 | webpage = self._download_webpage( |
49 | url, video_id, 'Downloading video page') | |
cc253000 | 50 | |
b5424acd | 51 | self._check_existence(webpage, video_id) |
cc253000 | 52 | |
82393e2b | 53 | def extract_filekey(default=NO_DEFAULT): |
47c7f3d9 | 54 | filekey = self._search_regex( |
82393e2b | 55 | self._FILEKEY_REGEX, webpage, 'filekey', default=default) |
47c7f3d9 YCH |
56 | if filekey is not default and (filekey[0] != '"' or filekey[-1] != '"'): |
57 | return self._search_regex( | |
eb0bdc2c | 58 | r'var\s+%s\s*=\s*"([^"]+)"' % re.escape(filekey), webpage, 'filekey', default=default) |
47c7f3d9 YCH |
59 | else: |
60 | return filekey | |
82393e2b S |
61 | |
62 | filekey = extract_filekey(default=None) | |
63 | ||
64 | if not filekey: | |
65 | fields = self._hidden_inputs(webpage) | |
66 | post_url = self._search_regex( | |
67 | r'<form[^>]+action=(["\'])(?P<url>.+?)\1', webpage, | |
68 | 'post url', default=url, group='url') | |
69 | if not post_url.startswith('http'): | |
70 | post_url = compat_urlparse.urljoin(url, post_url) | |
5c2266df | 71 | request = sanitized_Request( |
15707c7e | 72 | post_url, urlencode_postdata(fields)) |
82393e2b S |
73 | request.add_header('Content-Type', 'application/x-www-form-urlencoded') |
74 | request.add_header('Referer', post_url) | |
75 | webpage = self._download_webpage( | |
76 | request, video_id, 'Downloading continue to the video page') | |
b5424acd | 77 | self._check_existence(webpage, video_id) |
82393e2b S |
78 | |
79 | filekey = extract_filekey() | |
80 | ||
995cf05c | 81 | title = self._html_search_regex(self._TITLE_REGEX, webpage, 'title') |
82393e2b | 82 | description = self._html_search_regex(self._DESCRIPTION_REGEX, webpage, 'description', default='', fatal=False) |
cc253000 | 83 | |
10bff13a | 84 | api_response = self._download_webpage( |
ce78943a S |
85 | 'http://%s/api/player.api.php?key=%s&file=%s' % (self._HOST, filekey, video_id), video_id, |
86 | 'Downloading video api response') | |
cc253000 | 87 | |
88 | response = compat_urlparse.parse_qs(api_response) | |
89 | ||
90 | if 'error_msg' in response: | |
ce78943a | 91 | raise ExtractorError('%s returned error: %s' % (self.IE_NAME, response['error_msg'][0]), expected=True) |
cc253000 | 92 | |
93 | video_url = response['url'][0] | |
94 | ||
95 | return { | |
96 | 'id': video_id, | |
97 | 'url': video_url, | |
98 | 'title': title, | |
99 | 'description': description | |
5f6a1245 | 100 | } |
33d152b6 S |
101 | |
102 | ||
36066dd3 S |
103 | class WholeCloudIE(NovaMovIE): |
104 | IE_NAME = 'wholecloud' | |
105 | IE_DESC = 'WholeCloud' | |
33d152b6 | 106 | |
ec85ded8 | 107 | _VALID_URL = NovaMovIE._VALID_URL_TEMPLATE % {'host': r'(?:wholecloud\.net|movshare\.(?:net|sx|ag))'} |
33d152b6 | 108 | |
36066dd3 | 109 | _HOST = 'www.wholecloud.net' |
33d152b6 S |
110 | |
111 | _FILE_DELETED_REGEX = r'>This file no longer exists on our servers.<' | |
112 | _TITLE_REGEX = r'<strong>Title:</strong> ([^<]+)</p>' | |
113 | _DESCRIPTION_REGEX = r'<strong>Description:</strong> ([^<]+)</p>' | |
114 | ||
115 | _TEST = { | |
36066dd3 | 116 | 'url': 'http://www.wholecloud.net/video/559e28be54d96', |
33d152b6 S |
117 | 'md5': 'abd31a2132947262c50429e1d16c1bfd', |
118 | 'info_dict': { | |
119 | 'id': '559e28be54d96', | |
120 | 'ext': 'flv', | |
121 | 'title': 'dissapeared image', | |
122 | 'description': 'optical illusion dissapeared image magic illusion', | |
123 | } | |
124 | } | |
125 | ||
126 | ||
127 | class NowVideoIE(NovaMovIE): | |
128 | IE_NAME = 'nowvideo' | |
129 | IE_DESC = 'NowVideo' | |
130 | ||
ec85ded8 | 131 | _VALID_URL = NovaMovIE._VALID_URL_TEMPLATE % {'host': r'nowvideo\.(?:to|ch|ec|sx|eu|at|ag|co|li)'} |
33d152b6 S |
132 | |
133 | _HOST = 'www.nowvideo.to' | |
134 | ||
135 | _FILE_DELETED_REGEX = r'>This file no longer exists on our servers.<' | |
33d152b6 S |
136 | _TITLE_REGEX = r'<h4>([^<]+)</h4>' |
137 | _DESCRIPTION_REGEX = r'</h4>\s*<p>([^<]+)</p>' | |
138 | ||
139 | _TEST = { | |
6583c741 YCH |
140 | 'url': 'http://www.nowvideo.sx/video/f1d6fce9a968b', |
141 | 'md5': '12c82cad4f2084881d8bc60ee29df092', | |
33d152b6 | 142 | 'info_dict': { |
6583c741 | 143 | 'id': 'f1d6fce9a968b', |
33d152b6 | 144 | 'ext': 'flv', |
6583c741 | 145 | 'title': 'youtubedl test video BaWjenozKc', |
33d152b6 | 146 | 'description': 'Description', |
f6abca50 | 147 | }, |
33d152b6 S |
148 | } |
149 | ||
150 | ||
151 | class VideoWeedIE(NovaMovIE): | |
152 | IE_NAME = 'videoweed' | |
153 | IE_DESC = 'VideoWeed' | |
154 | ||
ec85ded8 | 155 | _VALID_URL = NovaMovIE._VALID_URL_TEMPLATE % {'host': r'videoweed\.(?:es|com)'} |
33d152b6 S |
156 | |
157 | _HOST = 'www.videoweed.es' | |
158 | ||
159 | _FILE_DELETED_REGEX = r'>This file no longer exists on our servers.<' | |
160 | _TITLE_REGEX = r'<h1 class="text_shadow">([^<]+)</h1>' | |
47c7f3d9 | 161 | _URL_TEMPLATE = 'http://%s/file/%s' |
33d152b6 S |
162 | |
163 | _TEST = { | |
164 | 'url': 'http://www.videoweed.es/file/b42178afbea14', | |
165 | 'md5': 'abd31a2132947262c50429e1d16c1bfd', | |
166 | 'info_dict': { | |
167 | 'id': 'b42178afbea14', | |
168 | 'ext': 'flv', | |
169 | 'title': 'optical illusion dissapeared image magic illusion', | |
170 | 'description': '' | |
171 | }, | |
172 | } | |
636aa83e S |
173 | |
174 | ||
175 | class CloudTimeIE(NovaMovIE): | |
176 | IE_NAME = 'cloudtime' | |
177 | IE_DESC = 'CloudTime' | |
178 | ||
ec85ded8 | 179 | _VALID_URL = NovaMovIE._VALID_URL_TEMPLATE % {'host': r'cloudtime\.to'} |
636aa83e S |
180 | |
181 | _HOST = 'www.cloudtime.to' | |
182 | ||
183 | _FILE_DELETED_REGEX = r'>This file no longer exists on our servers.<' | |
184 | _TITLE_REGEX = r'<div[^>]+class=["\']video_det["\'][^>]*>\s*<strong>([^<]+)</strong>' | |
185 | ||
186 | _TEST = None | |
e7d77efb S |
187 | |
188 | ||
189 | class AuroraVidIE(NovaMovIE): | |
190 | IE_NAME = 'auroravid' | |
191 | IE_DESC = 'AuroraVid' | |
192 | ||
ec85ded8 | 193 | _VALID_URL = NovaMovIE._VALID_URL_TEMPLATE % {'host': r'auroravid\.to'} |
e7d77efb S |
194 | |
195 | _HOST = 'www.auroravid.to' | |
196 | ||
197 | _FILE_DELETED_REGEX = r'This file no longer exists on our servers!<' | |
198 | ||
56019444 | 199 | _TESTS = [{ |
e7d77efb S |
200 | 'url': 'http://www.auroravid.to/video/4rurhn9x446jj', |
201 | 'md5': '7205f346a52bbeba427603ba10d4b935', | |
202 | 'info_dict': { | |
203 | 'id': '4rurhn9x446jj', | |
204 | 'ext': 'flv', | |
205 | 'title': 'search engine optimization', | |
206 | 'description': 'search engine optimization is used to rank the web page in the google search engine' | |
207 | }, | |
208 | 'skip': '"Invalid token" errors abound (in web interface as well as youtube-dl, there is nothing we can do about it.)' | |
56019444 S |
209 | }, { |
210 | 'url': 'http://www.auroravid.to/embed/?v=4rurhn9x446jj', | |
211 | 'only_matching': True, | |
212 | }] |