2014-03-22 00:38:37 +11:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2015-10-02 02:39:38 +10:00
|
|
|
import re
|
|
|
|
|
2014-03-22 00:38:37 +11:00
|
|
|
from .common import InfoExtractor
|
2015-10-02 02:44:51 +10:00
|
|
|
from ..compat import (
|
|
|
|
compat_urlparse,
|
2015-11-08 06:38:33 +11:00
|
|
|
compat_str,
|
2015-10-02 02:44:51 +10:00
|
|
|
)
|
|
|
|
from ..utils import (
|
|
|
|
parse_duration,
|
2015-11-07 06:16:14 +11:00
|
|
|
js_to_json,
|
|
|
|
parse_iso8601,
|
2015-10-02 02:44:51 +10:00
|
|
|
)
|
2014-03-22 00:38:37 +11:00
|
|
|
|
|
|
|
|
2015-11-07 07:23:41 +11:00
|
|
|
class ViideaIE(InfoExtractor):
|
|
|
|
_VALID_URL = r'''(?x)http://(?:www\.)?(?:
|
|
|
|
videolectures\.net|
|
|
|
|
flexilearn\.viidea\.net|
|
|
|
|
presentations\.ocwconsortium\.org|
|
|
|
|
video\.travel-zoom\.si|
|
|
|
|
video\.pomp-forum\.si|
|
|
|
|
tv\.nil\.si|
|
|
|
|
video\.hekovnik.com|
|
|
|
|
video\.szko\.si|
|
|
|
|
kpk\.viidea\.com|
|
|
|
|
inside\.viidea\.net|
|
|
|
|
video\.kiberpipa\.org|
|
|
|
|
bvvideo\.si|
|
|
|
|
kongres\.viidea\.net|
|
|
|
|
edemokracija\.viidea\.com
|
2015-11-08 03:43:23 +11:00
|
|
|
)(?:/lecture)?/(?P<id>[^/]+)(?:/video/(?P<part>\d+))?/*(?:[#?].*)?$'''
|
2014-03-22 00:38:37 +11:00
|
|
|
|
2015-10-02 02:45:10 +10:00
|
|
|
_TESTS = [{
|
2014-03-22 00:38:37 +11:00
|
|
|
'url': 'http://videolectures.net/promogram_igor_mekjavic_eng/',
|
|
|
|
'info_dict': {
|
2015-11-07 06:16:14 +11:00
|
|
|
'id': '20171_part1',
|
2014-03-22 00:38:37 +11:00
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Automatics, robotics and biocybernetics',
|
|
|
|
'description': 'md5:815fc1deb6b3a2bff99de2d5325be482',
|
|
|
|
'upload_date': '20130627',
|
|
|
|
'duration': 565,
|
|
|
|
'thumbnail': 're:http://.*\.jpg',
|
|
|
|
},
|
2015-10-02 03:10:36 +10:00
|
|
|
}, {
|
|
|
|
# video with invalid direct format links (HTTP 403)
|
|
|
|
'url': 'http://videolectures.net/russir2010_filippova_nlp/',
|
|
|
|
'info_dict': {
|
2015-11-07 06:16:14 +11:00
|
|
|
'id': '14891_part1',
|
2015-10-02 03:10:36 +10:00
|
|
|
'ext': 'flv',
|
|
|
|
'title': 'NLP at Google',
|
|
|
|
'description': 'md5:fc7a6d9bf0302d7cc0e53f7ca23747b3',
|
|
|
|
'duration': 5352,
|
|
|
|
'thumbnail': 're:http://.*\.jpg',
|
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
# rtmp download
|
|
|
|
'skip_download': True,
|
|
|
|
},
|
2015-10-02 02:45:10 +10:00
|
|
|
}, {
|
|
|
|
'url': 'http://videolectures.net/deeplearning2015_montreal/',
|
|
|
|
'info_dict': {
|
2015-11-07 06:16:14 +11:00
|
|
|
'id': '23181',
|
2015-10-02 02:45:10 +10:00
|
|
|
'title': 'Deep Learning Summer School, Montreal 2015',
|
2015-11-07 06:16:14 +11:00
|
|
|
'description': 'md5:0533a85e4bd918df52a01f0e1ebe87b7',
|
|
|
|
'timestamp': 1438560000,
|
2015-10-02 02:45:10 +10:00
|
|
|
},
|
|
|
|
'playlist_count': 30,
|
2015-11-07 06:16:14 +11:00
|
|
|
}, {
|
|
|
|
# multi part lecture
|
|
|
|
'url': 'http://videolectures.net/mlss09uk_bishop_ibi/',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '9737',
|
|
|
|
'title': 'Introduction To Bayesian Inference',
|
|
|
|
'timestamp': 1251622800,
|
|
|
|
},
|
|
|
|
'playlist': [{
|
|
|
|
'info_dict': {
|
|
|
|
'id': '9737_part1',
|
|
|
|
'ext': 'wmv',
|
|
|
|
'title': 'Introduction To Bayesian Inference',
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
'info_dict': {
|
|
|
|
'id': '9737_part2',
|
|
|
|
'ext': 'wmv',
|
|
|
|
'title': 'Introduction To Bayesian Inference',
|
|
|
|
},
|
|
|
|
}],
|
|
|
|
'playlist_count': 2,
|
2015-10-02 02:45:10 +10:00
|
|
|
}]
|
2014-03-22 00:38:37 +11:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2015-11-07 06:16:14 +11:00
|
|
|
lecture_slug, part = re.match(self._VALID_URL, url).groups()
|
|
|
|
|
|
|
|
webpage = self._download_webpage(url, lecture_slug)
|
2014-03-22 00:38:37 +11:00
|
|
|
|
2015-11-08 06:38:33 +11:00
|
|
|
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)
|
2015-10-02 02:44:51 +10:00
|
|
|
|
2015-11-08 06:38:33 +11:00
|
|
|
lecture_id = compat_str(cfg['obj_id'])
|
2014-03-22 00:38:37 +11:00
|
|
|
|
2015-11-07 07:23:41 +11:00
|
|
|
base_url = self._proto_relative_url(cfg['livepipe'], 'http:')
|
|
|
|
|
|
|
|
lecture_data = self._download_json('%s/site/api/lecture/%s?format=json' % (base_url, lecture_id), lecture_id)['lecture'][0]
|
2014-03-22 00:38:37 +11:00
|
|
|
|
2015-11-07 06:16:14 +11:00
|
|
|
lecture_info = {
|
|
|
|
'id': lecture_id,
|
|
|
|
'display_id': lecture_slug,
|
|
|
|
'title': lecture_data['title'],
|
|
|
|
'timestamp': parse_iso8601(lecture_data.get('time')),
|
|
|
|
'description': lecture_data.get('description_wiki'),
|
|
|
|
'thumbnail': lecture_data.get('thumb'),
|
|
|
|
}
|
2014-03-22 00:38:37 +11:00
|
|
|
|
2015-11-07 06:16:14 +11:00
|
|
|
entries = []
|
|
|
|
parts = cfg.get('videos')
|
|
|
|
if parts:
|
|
|
|
if len(parts) == 1:
|
2015-11-08 06:38:33 +11:00
|
|
|
part = compat_str(parts[0])
|
2015-11-07 06:16:14 +11:00
|
|
|
if part:
|
2015-11-07 07:23:41 +11:00
|
|
|
smil_url = '%s/%s/video/%s/smil.xml' % (base_url, lecture_slug, part)
|
2015-11-07 06:16:14 +11:00
|
|
|
smil = self._download_smil(smil_url, lecture_id)
|
|
|
|
info = self._parse_smil(smil, smil_url, lecture_id)
|
|
|
|
info['id'] = '%s_part%s' % (lecture_id, part)
|
|
|
|
switch = smil.find('.//switch')
|
|
|
|
if switch is not None:
|
|
|
|
info['duration'] = parse_duration(switch.attrib.get('dur'))
|
|
|
|
return info
|
|
|
|
else:
|
|
|
|
for part in parts:
|
2015-11-08 03:43:23 +11:00
|
|
|
entries.append(self.url_result('%s/%s/video/%s' % (base_url, lecture_slug, part), 'Viidea'))
|
2015-11-07 06:16:14 +11:00
|
|
|
lecture_info['_type'] = 'multi_video'
|
2015-11-08 06:38:33 +11:00
|
|
|
if not parts or lecture_data.get('type') == 'evt':
|
2015-11-07 06:16:14 +11:00
|
|
|
# Probably a playlist
|
2015-11-07 07:23:41 +11:00
|
|
|
playlist_webpage = self._download_webpage('%s/site/ajax/drilldown/?id=%s' % (base_url, lecture_id), lecture_id)
|
2015-11-07 06:16:14 +11:00
|
|
|
entries = [
|
2015-11-07 07:23:41 +11:00
|
|
|
self.url_result(compat_urlparse.urljoin(url, video_url), 'Viidea')
|
|
|
|
for _, video_url in re.findall(r'<a[^>]+href=(["\'])(.+?)\1[^>]+id=["\']lec=\d+', playlist_webpage)]
|
2015-11-07 06:16:14 +11:00
|
|
|
lecture_info['_type'] = 'playlist'
|
2014-03-22 00:38:37 +11:00
|
|
|
|
2015-11-07 06:16:14 +11:00
|
|
|
lecture_info['entries'] = entries
|
|
|
|
return lecture_info
|