'twitter card player')
@staticmethod
- def _form_hidden_inputs(html):
- return dict(re.findall(
- r'<input\s+type="hidden"\s+name="([^"]+)"\s+(?:id="[^"]+"\s+)?value="([^"]*)"',
- html))
+ def _hidden_inputs(html):
+ return dict([
+ (input.group('name'), input.group('value')) for input in re.finditer(
+ r'''(?x)
+ <input\s+
+ type=(?P<q_hidden>["\'])hidden(?P=q_hidden)\s+
+ name=(?P<q_name>["\'])(?P<name>.+?)(?P=q_name)\s+
+ (?:id=(?P<q_id>["\']).+?(?P=q_id)\s+)?
+ value=(?P<q_value>["\'])(?P<value>.*?)(?P=q_value)
+ ''', html)
+ ])
def _sort_formats(self, formats, field_preference=None):
if not formats:
if re.search(self._FILE_NOT_FOUND_REGEX, webpage) is not None:
raise ExtractorError('Video %s does not exist' % video_id, expected=True)
- fields = self._form_hidden_inputs(webpage)
+ fields = self._hidden_inputs(webpage)
if fields['op'] == 'download1':
countdown = int_or_none(self._search_regex(
r'<img src="([^"]+)".+?class="pic"',
webpage, 'thumbnail', fatal=False)
- fields = self._form_hidden_inputs(webpage)
+ fields = self._hidden_inputs(webpage)
request = compat_urllib_request.Request(url, urlencode_postdata(fields))
request.add_header('Content-type', 'application/x-www-form-urlencoded')
if m_error:
raise ExtractorError(m_error.group('msg'), expected=True)
- data = self._form_hidden_inputs(orig_webpage)
+ data = self._hidden_inputs(orig_webpage)
self._sleep(2, video_id)
if '>File not exist<' in webpage:
raise ExtractorError('Video %s does not exist' % video_id, expected=True)
- fields = self._form_hidden_inputs(webpage)
+ fields = self._hidden_inputs(webpage)
headers = {
'Referer': url,
raise ExtractorError('Video %s does not exist' % video_id,
expected=True)
- fields = self._form_hidden_inputs(webpage)
+ fields = self._hidden_inputs(webpage)
post = compat_urllib_parse.urlencode(fields)
req = compat_urllib_request.Request(url, post)
req.add_header('Content-type', 'application/x-www-form-urlencoded')
raise ExtractorError(
'Video %s does not exist' % video_id, expected=True)
- download_form = self._form_hidden_inputs(webpage)
+ download_form = self._hidden_inputs(webpage)
request = compat_urllib_request.Request(
url, compat_urllib_parse.urlencode(download_form))
request.add_header('Content-Type', 'application/x-www-form-urlencoded')
login_page = self._download_webpage(
self._LOGIN_URL, None, 'Downloading login page')
- login_form = self._form_hidden_inputs(login_page)
+ login_form = self._hidden_inputs(login_page)
login_form.update({
'login': username.encode('utf-8'),
password = self._downloader.params.get('videopassword', None)
if password is None:
raise ExtractorError('This album is protected by a password, use the --video-password option', expected=True)
- fields = self._form_hidden_inputs(login_form)
+ fields = self._hidden_inputs(login_form)
token = self._search_regex(r'xsrft[\s=:"\']+([^"\']+)', webpage, 'login token')
fields['token'] = token
fields['password'] = password
login_page = self._download_webpage(
'https://vk.com', None, 'Downloading login page')
- login_form = self._form_hidden_inputs(login_page)
+ login_form = self._hidden_inputs(login_page)
login_form.update({
'email': username.encode('cp1251'),
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
- fields = self._form_hidden_inputs(webpage)
+ fields = self._hidden_inputs(webpage)
if fields['op'] == 'download1':
self._sleep(3, video_id) # they do detect when requests happen too fast!