1 from __future__ import unicode_literals
5 from .common import InfoExtractor
17 class ViideaIE(InfoExtractor):
18 _VALID_URL = r'''(?x)http://(?:www\.)?(?:
20 flexilearn\.viidea\.net|
21 presentations\.ocwconsortium\.org|
22 video\.travel-zoom\.si|
23 video\.pomp-forum\.si|
29 video\.kiberpipa\.org|
32 edemokracija\.viidea\.com
33 )(?:/lecture)?/(?P<id>[^/]+)(?:/video/(?P<part>\d+))?/*(?:[#?].*)?$'''
36 'url': 'http://videolectures.net/promogram_igor_mekjavic_eng/',
40 'title': 'Automatics, robotics and biocybernetics',
41 'description': 'md5:815fc1deb6b3a2bff99de2d5325be482',
42 'upload_date': '20130627',
44 'thumbnail': 're:http://.*\.jpg',
47 # video with invalid direct format links (HTTP 403)
48 'url': 'http://videolectures.net/russir2010_filippova_nlp/',
52 'title': 'NLP at Google',
53 'description': 'md5:fc7a6d9bf0302d7cc0e53f7ca23747b3',
55 'thumbnail': 're:http://.*\.jpg',
59 'skip_download': True,
62 'url': 'http://videolectures.net/deeplearning2015_montreal/',
65 'title': 'Deep Learning Summer School, Montreal 2015',
66 'description': 'md5:0533a85e4bd918df52a01f0e1ebe87b7',
67 'timestamp': 1438560000,
72 'url': 'http://videolectures.net/mlss09uk_bishop_ibi/',
75 'title': 'Introduction To Bayesian Inference',
76 'timestamp': 1251622800,
82 'title': 'Introduction To Bayesian Inference',
88 'title': 'Introduction To Bayesian Inference',
94 def _real_extract(self, url):
95 lecture_slug, part = re.match(self._VALID_URL, url).groups()
97 webpage = self._download_webpage(url, lecture_slug)
99 cfg = self._parse_json(self._search_regex([r'cfg\s*:\s*({.+?}),[\da-zA-Z_]:\(?function', r'cfg\s*:\s*({[^}]+})'], webpage, 'cfg'), lecture_slug, js_to_json)
101 lecture_id = compat_str(cfg['obj_id'])
103 base_url = self._proto_relative_url(cfg['livepipe'], 'http:')
105 lecture_data = self._download_json('%s/site/api/lecture/%s?format=json' % (base_url, lecture_id), lecture_id)['lecture'][0]
109 'display_id': lecture_slug,
110 'title': lecture_data['title'],
111 'timestamp': parse_iso8601(lecture_data.get('time')),
112 'description': lecture_data.get('description_wiki'),
113 'thumbnail': lecture_data.get('thumb'),
117 parts = cfg.get('videos')
120 part = compat_str(parts[0])
122 smil_url = '%s/%s/video/%s/smil.xml' % (base_url, lecture_slug, part)
123 smil = self._download_smil(smil_url, lecture_id)
124 info = self._parse_smil(smil, smil_url, lecture_id)
125 info['id'] = '%s_part%s' % (lecture_id, part)
126 switch = smil.find('.//switch')
127 if switch is not None:
128 info['duration'] = parse_duration(switch.attrib.get('dur'))
132 entries.append(self.url_result('%s/%s/video/%s' % (base_url, lecture_slug, part), 'Viidea'))
133 lecture_info['_type'] = 'multi_video'
134 if not parts or lecture_data.get('type') == 'evt':
135 # Probably a playlist
136 playlist_webpage = self._download_webpage('%s/site/ajax/drilldown/?id=%s' % (base_url, lecture_id), lecture_id)
138 self.url_result(compat_urlparse.urljoin(url, video_url), 'Viidea')
139 for _, video_url in re.findall(r'<a[^>]+href=(["\'])(.+?)\1[^>]+id=["\']lec=\d+', playlist_webpage)]
140 lecture_info['_type'] = 'playlist'
142 lecture_info['entries'] = entries