slideslive.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import smuggle_url
  5. class SlidesLiveIE(InfoExtractor):
  6. _VALID_URL = r'https?://slideslive\.com/(?P<id>[0-9]+)'
  7. _TESTS = [{
  8. # video_service_name = YOUTUBE
  9. 'url': 'https://slideslive.com/38902413/gcc-ia16-backend',
  10. 'md5': 'b29fcd6c6952d0c79c5079b0e7a07e6f',
  11. 'info_dict': {
  12. 'id': 'LMtgR8ba0b0',
  13. 'ext': 'mp4',
  14. 'title': 'GCC IA16 backend',
  15. 'description': 'Watch full version of this video at https://slideslive.com/38902413.',
  16. 'uploader': 'SlidesLive Videos - A',
  17. 'uploader_id': 'UC62SdArr41t_-_fX40QCLRw',
  18. 'upload_date': '20170925',
  19. }
  20. }, {
  21. # video_service_name = youtube
  22. 'url': 'https://slideslive.com/38903721/magic-a-scientific-resurrection-of-an-esoteric-legend',
  23. 'only_matching': True,
  24. }, {
  25. # video_service_name = url
  26. 'url': 'https://slideslive.com/38922070/learning-transferable-skills-1',
  27. 'only_matching': True,
  28. }, {
  29. # video_service_name = vimeo
  30. 'url': 'https://slideslive.com/38921896/retrospectives-a-venue-for-selfreflection-in-ml-research-3',
  31. 'only_matching': True,
  32. }]
  33. def _real_extract(self, url):
  34. video_id = self._match_id(url)
  35. video_data = self._download_json(
  36. 'https://ben.slideslive.com/player/' + video_id, video_id)
  37. service_name = video_data['video_service_name'].lower()
  38. assert service_name in ('url', 'vimeo', 'youtube')
  39. service_id = video_data['video_service_id']
  40. info = {
  41. 'id': video_id,
  42. 'thumbnail': video_data.get('thumbnail'),
  43. 'url': service_id,
  44. }
  45. if service_name == 'url':
  46. info['title'] = video_data['title']
  47. else:
  48. info.update({
  49. '_type': 'url_transparent',
  50. 'ie_key': service_name.capitalize(),
  51. 'title': video_data.get('title'),
  52. })
  53. if service_name == 'vimeo':
  54. info['url'] = smuggle_url(
  55. 'https://player.vimeo.com/video/' + service_id,
  56. {'http_headers': {'Referer': url}})
  57. return info