]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/viidea.py
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
19 class ViideaIE(InfoExtractor
):
20 _VALID_URL
= r
'''(?x)https?://(?:www\.)?(?:
22 flexilearn\.viidea\.net|
23 presentations\.ocwconsortium\.org|
24 video\.travel-zoom\.si|
25 video\.pomp-forum\.si|
31 video\.kiberpipa\.org|
34 edemokracija\.viidea\.com
35 )(?:/lecture)?/(?P<id>[^/]+)(?:/video/(?P<part>\d+))?/*(?:[#?].*)?$'''
38 'url': 'http://videolectures.net/promogram_igor_mekjavic_eng/',
41 'display_id': 'promogram_igor_mekjavic_eng',
43 'title': 'Automatics, robotics and biocybernetics',
44 'description': 'md5:815fc1deb6b3a2bff99de2d5325be482',
45 'thumbnail': r
're:http://.*\.jpg',
46 'timestamp': 1372349289,
47 'upload_date': '20130627',
52 'skip_download': True,
55 # video with invalid direct format links (HTTP 403)
56 'url': 'http://videolectures.net/russir2010_filippova_nlp/',
59 'display_id': 'russir2010_filippova_nlp',
61 'title': 'NLP at Google',
62 'description': 'md5:fc7a6d9bf0302d7cc0e53f7ca23747b3',
63 'thumbnail': r
're:http://.*\.jpg',
64 'timestamp': 1284375600,
65 'upload_date': '20100913',
70 'skip_download': True,
74 'url': 'http://videolectures.net/deeplearning2015_montreal/',
77 'title': 'Deep Learning Summer School, Montreal 2015',
78 'description': 'md5:0533a85e4bd918df52a01f0e1ebe87b7',
79 'thumbnail': r
're:http://.*\.jpg',
80 'timestamp': 1438560000,
85 'url': 'http://videolectures.net/mlss09uk_bishop_ibi/',
88 'display_id': 'mlss09uk_bishop_ibi',
89 'title': 'Introduction To Bayesian Inference',
90 'thumbnail': r
're:http://.*\.jpg',
91 'timestamp': 1251622800,
96 'display_id': 'mlss09uk_bishop_ibi_part1',
98 'title': 'Introduction To Bayesian Inference (Part 1)',
99 'thumbnail': r
're:http://.*\.jpg',
101 'timestamp': 1251622800,
102 'upload_date': '20090830',
107 'display_id': 'mlss09uk_bishop_ibi_part2',
109 'title': 'Introduction To Bayesian Inference (Part 2)',
110 'thumbnail': r
're:http://.*\.jpg',
112 'timestamp': 1251622800,
113 'upload_date': '20090830',
119 def _real_extract(self
, url
):
120 lecture_slug
, explicit_part_id
= re
.match(self
._VALID
_URL
, url
).groups()
122 webpage
= self
._download
_webpage
(url
, lecture_slug
)
124 cfg
= self
._parse
_json
(self
._search
_regex
(
125 [r
'cfg\s*:\s*({.+?})\s*,\s*[\da-zA-Z_]+\s*:\s*\(?\s*function',
126 r
'cfg\s*:\s*({[^}]+})'],
127 webpage
, 'cfg'), lecture_slug
, js_to_json
)
129 lecture_id
= compat_str(cfg
['obj_id'])
131 base_url
= self
._proto
_relative
_url
(cfg
['livepipe'], 'http:')
134 lecture_data
= self
._download
_json
(
135 '%s/site/api/lecture/%s?format=json' % (base_url
, lecture_id
),
136 lecture_id
)['lecture'][0]
137 except ExtractorError
as e
:
138 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 403:
139 msg
= self
._parse
_json
(
140 e
.cause
.read().decode('utf-8'), lecture_id
)
141 raise ExtractorError(msg
['detail'], expected
=True)
146 'display_id': lecture_slug
,
147 'title': lecture_data
['title'],
148 'timestamp': parse_iso8601(lecture_data
.get('time')),
149 'description': lecture_data
.get('description_wiki'),
150 'thumbnail': lecture_data
.get('thumb'),
153 playlist_entries
= []
154 lecture_type
= lecture_data
.get('type')
155 parts
= [compat_str(video
) for video
in cfg
.get('videos', [])]
157 multipart
= len(parts
) > 1
159 def extract_part(part_id
):
160 smil_url
= '%s/%s/video/%s/smil.xml' % (base_url
, lecture_slug
, part_id
)
161 smil
= self
._download
_smil
(smil_url
, lecture_id
)
162 info
= self
._parse
_smil
(smil
, smil_url
, lecture_id
)
163 self
._sort
_formats
(info
['formats'])
164 info
['id'] = lecture_id
if not multipart
else '%s_part%s' % (lecture_id
, part_id
)
165 info
['display_id'] = lecture_slug
if not multipart
else '%s_part%s' % (lecture_slug
, part_id
)
167 info
['title'] += ' (Part %s)' % part_id
168 switch
= smil
.find('.//switch')
169 if switch
is not None:
170 info
['duration'] = parse_duration(switch
.attrib
.get('dur'))
171 item_info
= lecture_info
.copy()
172 item_info
.update(info
)
175 if explicit_part_id
or not multipart
:
176 result
= extract_part(explicit_part_id
or parts
[0])
179 '_type': 'multi_video',
180 'entries': [extract_part(part
) for part
in parts
],
182 result
.update(lecture_info
)
184 # Immediately return explicitly requested part or non event item
185 if explicit_part_id
or lecture_type
!= 'evt':
188 playlist_entries
.append(result
)
190 # It's probably a playlist
191 if not parts
or lecture_type
== 'evt':
192 playlist_webpage
= self
._download
_webpage
(
193 '%s/site/ajax/drilldown/?id=%s' % (base_url
, lecture_id
), lecture_id
)
195 self
.url_result(compat_urlparse
.urljoin(url
, video_url
), 'Viidea')
196 for _
, video_url
in re
.findall(
197 r
'<a[^>]+href=(["\'])(.+?
)\
1[^
>]+id=["\']lec=\d+', playlist_webpage)]
198 playlist_entries.extend(entries)
200 playlist = self.playlist_result(playlist_entries, lecture_id)
201 playlist.update(lecture_info)