You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
2.0 KiB

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