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