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.

65 lines
2.3 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import json
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. int_or_none,
  7. mimetype2ext,
  8. )
  9. class SandiaIE(InfoExtractor):
  10. IE_DESC = 'Sandia National Laboratories'
  11. _VALID_URL = r'https?://digitalops\.sandia\.gov/Mediasite/Play/(?P<id>[0-9a-f]+)'
  12. _TEST = {
  13. 'url': 'http://digitalops.sandia.gov/Mediasite/Play/24aace4429fc450fb5b38cdbf424a66e1d',
  14. 'md5': '9422edc9b9a60151727e4b6d8bef393d',
  15. 'info_dict': {
  16. 'id': '24aace4429fc450fb5b38cdbf424a66e1d',
  17. 'ext': 'mp4',
  18. 'title': 'Xyce Software Training - Section 1',
  19. 'description': 're:(?s)SAND Number: SAND 2013-7800.{200,}',
  20. 'upload_date': '20120409',
  21. 'timestamp': 1333983600,
  22. 'duration': 7794,
  23. }
  24. }
  25. def _real_extract(self, url):
  26. video_id = self._match_id(url)
  27. presentation_data = self._download_json(
  28. 'http://digitalops.sandia.gov/Mediasite/PlayerService/PlayerService.svc/json/GetPlayerOptions',
  29. video_id, data=json.dumps({
  30. 'getPlayerOptionsRequest': {
  31. 'ResourceId': video_id,
  32. 'QueryString': '',
  33. }
  34. }), headers={
  35. 'Content-Type': 'application/json; charset=utf-8',
  36. })['d']['Presentation']
  37. title = presentation_data['Title']
  38. formats = []
  39. for stream in presentation_data.get('Streams', []):
  40. for fd in stream.get('VideoUrls', []):
  41. formats.append({
  42. 'format_id': fd['MediaType'],
  43. 'format_note': fd['MimeType'].partition('/')[2],
  44. 'ext': mimetype2ext(fd['MimeType']),
  45. 'url': fd['Location'],
  46. 'protocol': 'f4m' if fd['MimeType'] == 'video/x-mp4-fragmented' else None,
  47. })
  48. self._sort_formats(formats)
  49. return {
  50. 'id': video_id,
  51. 'title': title,
  52. 'description': presentation_data.get('Description'),
  53. 'formats': formats,
  54. 'timestamp': int_or_none(presentation_data.get('UnixTime'), 1000),
  55. 'duration': int_or_none(presentation_data.get('Duration'), 1000),
  56. }