- player_url = None
-
- # Get video info
- self.report_video_info_webpage_download(video_id)
- for el_type in ['&el=embedded', '&el=detailpage', '&el=vevo', '']:
- video_info_url = ('http://www.youtube.com/get_video_info?&video_id=%s%s&ps=default&eurl=&gl=US&hl=en'
- % (video_id, el_type))
- request = urllib2.Request(video_info_url, None, std_headers)
- try:
- video_info_webpage = urllib2.urlopen(request).read()
- video_info = parse_qs(video_info_webpage)
- if 'token' in video_info:
- break
- except (urllib2.URLError, httplib.HTTPException, socket.error), err:
- self._downloader.trouble(u'ERROR: unable to download video info webpage: %s' % str(err))
- return
- self.report_information_extraction(video_id)
-
- # "t" param
- if 'token' not in video_info:
- # Attempt to see if YouTube has issued an error message
- if 'reason' not in video_info:
- self._downloader.trouble(u'ERROR: unable to extract "t" parameter for unknown reason')
- stream = open('reportme-ydl-%s.dat' % time.time(), 'wb')
- stream.write(video_info_webpage)
- stream.close()
- else:
- reason = urllib.unquote_plus(video_info['reason'][0])
- self._downloader.trouble(u'ERROR: YouTube said: %s' % reason.decode('utf-8'))
- return
- token = urllib.unquote_plus(video_info['token'][0])
- video_real_url = 'http://www.youtube.com/get_video?video_id=%s&t=%s&eurl=&el=detailpage&ps=default&gl=US&hl=en' % (video_id, token)
- if format_param is not None:
- video_real_url = '%s&fmt=%s' % (video_real_url, format_param)
-
- # Check possible RTMP download
- if 'conn' in video_info and video_info['conn'][0].startswith('rtmp'):
- self.report_rtmp_download()
- video_real_url = video_info['conn'][0]
-
- # uploader
- if 'author' not in video_info:
- self._downloader.trouble(u'ERROR: unable to extract uploader nickname')