]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/gputechconf.py
debian/patches: Removed, they came from upstream.
[youtubedl] / youtube_dl / extractor / gputechconf.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import (
6 xpath_element,
7 xpath_text,
8 int_or_none,
9 parse_duration,
10 )
11
12
13 class GPUTechConfIE(InfoExtractor):
14 _VALID_URL = r'https?://on-demand\.gputechconf\.com/gtc/2015/video/S(?P<id>\d+)\.html'
15 _TEST = {
16 'url': 'http://on-demand.gputechconf.com/gtc/2015/video/S5156.html',
17 'md5': 'a8862a00a0fd65b8b43acc5b8e33f798',
18 'info_dict': {
19 'id': '5156',
20 'ext': 'mp4',
21 'title': 'Coordinating More Than 3 Million CUDA Threads for Social Network Analysis',
22 'duration': 1219,
23 }
24 }
25
26 def _real_extract(self, url):
27 video_id = self._match_id(url)
28 webpage = self._download_webpage(url, video_id)
29
30 root_path = self._search_regex(r'var\s+rootPath\s*=\s*"([^"]+)', webpage, 'root path', 'http://evt.dispeak.com/nvidia/events/gtc15/')
31 xml_file_id = self._search_regex(r'var\s+xmlFileId\s*=\s*"([^"]+)', webpage, 'xml file id')
32
33 doc = self._download_xml('%sxml/%s.xml' % (root_path, xml_file_id), video_id)
34
35 metadata = xpath_element(doc, 'metadata')
36 http_host = xpath_text(metadata, 'httpHost', 'http host', True)
37 mbr_videos = xpath_element(metadata, 'MBRVideos')
38
39 formats = []
40 for mbr_video in mbr_videos.findall('MBRVideo'):
41 stream_name = xpath_text(mbr_video, 'streamName')
42 if stream_name:
43 formats.append({
44 'url': 'http://%s/%s' % (http_host, stream_name.replace('mp4:', '')),
45 'tbr': int_or_none(xpath_text(mbr_video, 'bitrate')),
46 })
47 self._sort_formats(formats)
48
49 return {
50 'id': video_id,
51 'title': xpath_text(metadata, 'title'),
52 'duration': parse_duration(xpath_text(metadata, 'endTime')),
53 'creator': xpath_text(metadata, 'speaker'),
54 'formats': formats,
55 }