- webpage = self._download_webpage(url, video_id)
- age_limit = 0
- if 'class="adultwarning-container"' in webpage:
- self.report_age_confirmation()
- age_limit = 18
- request = sanitized_Request(url)
- request.add_header('Cookie', 'confirmedAdult=true')
- webpage = self._download_webpage(request, video_id)
-
- m_youtube = re.search(r'http://www\.youtube\.com/v/(.*?)(\&|"|\?)', webpage)
- if m_youtube is not None:
- youtube_id = m_youtube.group(1)
- self.to_screen('%s: detected Youtube video.' % video_id)
- return self.url_result(youtube_id, 'Youtube')
-
- info = json.loads(
- self._search_regex(r'videoDetailsJSON = \'({.*?})\';', webpage, 'info').replace('\\\'', '\''))
-
- video = self._extract_video(info)
- video['age_limit'] = age_limit
+ thumbnail_url = None
+ q = qualities(['HQ', 'Regular'])
+ formats = []
+ for f_id, f_url in video.get('src', {}).items():
+ if not f_url:
+ continue
+ if f_id == 'poster':
+ thumbnail_url = f_url
+ else:
+ formats.append({
+ 'format_id': f_id,
+ 'quality': q(f_id),
+ 'url': f_url,
+ })
+ self._sort_formats(formats)