videolecturesnet.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. parse_duration,
  5. )
  6. class VideoLecturesNetIE(InfoExtractor):
  7. _VALID_URL = r'http://(?:www\.)?videolectures\.net/(?P<id>[^/#?]+)/*(?:[#?].*)?$'
  8. IE_NAME = 'videolectures.net'
  9. _TEST = {
  10. 'url': 'http://videolectures.net/promogram_igor_mekjavic_eng/',
  11. 'info_dict': {
  12. 'id': 'promogram_igor_mekjavic_eng',
  13. 'ext': 'mp4',
  14. 'title': 'Automatics, robotics and biocybernetics',
  15. 'description': 'md5:815fc1deb6b3a2bff99de2d5325be482',
  16. 'upload_date': '20130627',
  17. 'duration': 565,
  18. 'thumbnail': 're:http://.*\.jpg',
  19. },
  20. }
  21. def _real_extract(self, url):
  22. video_id = self._match_id(url)
  23. smil_url = 'http://videolectures.net/%s/video/1/smil.xml' % video_id
  24. smil = self._download_smil(smil_url, video_id)
  25. info = self._parse_smil(smil, smil_url, video_id)
  26. info['id'] = video_id
  27. switch = smil.find('.//switch')
  28. if switch is not None:
  29. info['duration'] = parse_duration(switch.attrib.get('dur'))
  30. return info