]>
Commit | Line | Data |
---|---|---|
e5de3f6c S |
1 | from __future__ import unicode_literals |
2 | ||
efcba804 S |
3 | import re |
4 | ||
e5de3f6c | 5 | from .common import InfoExtractor |
1cc79574 | 6 | from ..compat import ( |
328f82d5 | 7 | compat_HTTPError, |
abe8766c | 8 | compat_kwargs, |
0a439c5c | 9 | compat_str, |
e5de3f6c | 10 | compat_urllib_request, |
ff9d5d09 | 11 | compat_urlparse, |
1cc79574 PH |
12 | ) |
13 | from ..utils import ( | |
efcba804 S |
14 | determine_ext, |
15 | extract_attributes, | |
e5de3f6c | 16 | ExtractorError, |
328f82d5 | 17 | float_or_none, |
3b35c342 | 18 | int_or_none, |
57a38a38 | 19 | js_to_json, |
5c2266df | 20 | sanitized_Request, |
2fbd8635 | 21 | try_get, |
17b2d7ca | 22 | unescapeHTML, |
3052a30d | 23 | url_or_none, |
6e6bc8da | 24 | urlencode_postdata, |
e5de3f6c S |
25 | ) |
26 | ||
27 | ||
28 | class UdemyIE(InfoExtractor): | |
29 | IE_NAME = 'udemy' | |
5eb7db4e S |
30 | _VALID_URL = r'''(?x) |
31 | https?:// | |
d7d51389 | 32 | (?:[^/]+\.)?udemy\.com/ |
5eb7db4e S |
33 | (?: |
34 | [^#]+\#/lecture/| | |
35 | lecture/view/?\?lectureId=| | |
36 | [^/]+/learn/v4/t/lecture/ | |
37 | ) | |
38 | (?P<id>\d+) | |
39 | ''' | |
dcd4d95c S |
40 | _LOGIN_URL = 'https://www.udemy.com/join/login-popup/?displayType=ajax&showSkipButton=1' |
41 | _ORIGIN_URL = 'https://www.udemy.com' | |
e5de3f6c S |
42 | _NETRC_MACHINE = 'udemy' |
43 | ||
6563837e | 44 | _TESTS = [{ |
e5de3f6c S |
45 | 'url': 'https://www.udemy.com/java-tutorial/#/lecture/172757', |
46 | 'md5': '98eda5b657e752cf945d8445e261b5c5', | |
47 | 'info_dict': { | |
48 | 'id': '160614', | |
49 | 'ext': 'mp4', | |
50 | 'title': 'Introduction and Installation', | |
51 | 'description': 'md5:c0d51f6f21ef4ec65f091055a5eef876', | |
52 | 'duration': 579.29, | |
53 | }, | |
54 | 'skip': 'Requires udemy account credentials', | |
5eb7db4e S |
55 | }, { |
56 | # new URL schema | |
57 | 'url': 'https://www.udemy.com/electric-bass-right-from-the-start/learn/v4/t/lecture/4580906', | |
58 | 'only_matching': True, | |
b7f87493 S |
59 | }, { |
60 | # no url in outputs format entry | |
61 | 'url': 'https://www.udemy.com/learn-web-development-complete-step-by-step-guide-to-success/learn/v4/t/lecture/4125812', | |
62 | 'only_matching': True, | |
85139634 S |
63 | }, { |
64 | # only outputs rendition | |
65 | 'url': 'https://www.udemy.com/how-you-can-help-your-local-community-5-amazing-examples/learn/v4/t/lecture/3225750?start=0', | |
66 | 'only_matching': True, | |
d7d51389 S |
67 | }, { |
68 | 'url': 'https://wipro.udemy.com/java-tutorial/#/lecture/172757', | |
69 | 'only_matching': True, | |
6563837e | 70 | }] |
e5de3f6c | 71 | |
81da8cbc S |
72 | def _extract_course_info(self, webpage, video_id): |
73 | course = self._parse_json( | |
74 | unescapeHTML(self._search_regex( | |
6f1ec339 S |
75 | r'ng-init=["\'].*\bcourse=({.+?})[;"\']', |
76 | webpage, 'course', default='{}')), | |
81da8cbc S |
77 | video_id, fatal=False) or {} |
78 | course_id = course.get('id') or self._search_regex( | |
5de53878 RA |
79 | [ |
80 | r'data-course-id=["\'](\d+)', | |
81 | r'"courseId"\s*:\s*(\d+)' | |
82 | ], webpage, 'course id') | |
81da8cbc S |
83 | return course_id, course.get('title') |
84 | ||
ff9d5d09 | 85 | def _enroll_course(self, base_url, webpage, course_id): |
b24ab3e3 S |
86 | def combine_url(base_url, url): |
87 | return compat_urlparse.urljoin(base_url, url) if not url.startswith('http') else url | |
88 | ||
17b2d7ca | 89 | checkout_url = unescapeHTML(self._search_regex( |
5f5c7b92 | 90 | r'href=(["\'])(?P<url>(?:https?://(?:www\.)?udemy\.com)?/(?:payment|cart)/checkout/.+?)\1', |
17b2d7ca S |
91 | webpage, 'checkout url', group='url', default=None)) |
92 | if checkout_url: | |
93 | raise ExtractorError( | |
f20756fb | 94 | 'Course %s is not free. You have to pay for it before you can download. ' |
b24ab3e3 S |
95 | 'Use this URL to confirm purchase: %s' |
96 | % (course_id, combine_url(base_url, checkout_url)), | |
97 | expected=True) | |
17b2d7ca S |
98 | |
99 | enroll_url = unescapeHTML(self._search_regex( | |
ff9d5d09 | 100 | r'href=(["\'])(?P<url>(?:https?://(?:www\.)?udemy\.com)?/course/subscribe/.+?)\1', |
17b2d7ca S |
101 | webpage, 'enroll url', group='url', default=None)) |
102 | if enroll_url: | |
b24ab3e3 S |
103 | webpage = self._download_webpage( |
104 | combine_url(base_url, enroll_url), | |
aabdc83d S |
105 | course_id, 'Enrolling in the course', |
106 | headers={'Referer': base_url}) | |
17b2d7ca S |
107 | if '>You have enrolled in' in webpage: |
108 | self.to_screen('%s: Successfully enrolled in the course' % course_id) | |
328f82d5 S |
109 | |
110 | def _download_lecture(self, course_id, lecture_id): | |
111 | return self._download_json( | |
75b81df3 S |
112 | 'https://www.udemy.com/api-2.0/users/me/subscribed-courses/%s/lectures/%s?' |
113 | % (course_id, lecture_id), | |
114 | lecture_id, 'Downloading lecture JSON', query={ | |
115 | 'fields[lecture]': 'title,description,view_html,asset', | |
2fbd8635 | 116 | 'fields[asset]': 'asset_type,stream_url,thumbnail_url,download_urls,stream_urls,captions,data', |
75b81df3 | 117 | }) |
328f82d5 | 118 | |
e5de3f6c S |
119 | def _handle_error(self, response): |
120 | if not isinstance(response, dict): | |
121 | return | |
122 | error = response.get('error') | |
123 | if error: | |
124 | error_str = 'Udemy returned error #%s: %s' % (error.get('code'), error.get('message')) | |
125 | error_data = error.get('data') | |
126 | if error_data: | |
127 | error_str += ' - %s' % error_data.get('formErrors') | |
128 | raise ExtractorError(error_str, expected=True) | |
129 | ||
e5eadfa8 | 130 | def _download_webpage_handle(self, *args, **kwargs): |
c8f6ab8c | 131 | headers = kwargs.get('headers', {}).copy() |
ae65c93a | 132 | headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36' |
c8f6ab8c | 133 | kwargs['headers'] = headers |
ae65c93a | 134 | ret = super(UdemyIE, self)._download_webpage_handle( |
abe8766c | 135 | *args, **compat_kwargs(kwargs)) |
ae65c93a S |
136 | if not ret: |
137 | return ret | |
138 | webpage, _ = ret | |
139 | if any(p in webpage for p in ( | |
140 | '>Please verify you are a human', | |
141 | 'Access to this page has been denied because we believe you are using automation tools to browse the website', | |
142 | '"_pxCaptcha"')): | |
143 | raise ExtractorError( | |
144 | 'Udemy asks you to solve a CAPTCHA. Login with browser, ' | |
145 | 'solve CAPTCHA, then export cookies and pass cookie file to ' | |
7a5c1cfe | 146 | 'yt-dlp with --cookies.', expected=True) |
ae65c93a | 147 | return ret |
abe8766c | 148 | |
81da8cbc | 149 | def _download_json(self, url_or_request, *args, **kwargs): |
e2937118 S |
150 | headers = { |
151 | 'X-Udemy-Snail-Case': 'true', | |
152 | 'X-Requested-With': 'XMLHttpRequest', | |
153 | } | |
154 | for cookie in self._downloader.cookiejar: | |
155 | if cookie.name == 'client_id': | |
156 | headers['X-Udemy-Client-Id'] = cookie.value | |
157 | elif cookie.name == 'access_token': | |
158 | headers['X-Udemy-Bearer-Token'] = cookie.value | |
328f82d5 | 159 | headers['X-Udemy-Authorization'] = 'Bearer %s' % cookie.value |
61c0663c S |
160 | |
161 | if isinstance(url_or_request, compat_urllib_request.Request): | |
162 | for header, value in headers.items(): | |
163 | url_or_request.add_header(header, value) | |
164 | else: | |
5c2266df | 165 | url_or_request = sanitized_Request(url_or_request, headers=headers) |
61c0663c | 166 | |
81da8cbc | 167 | response = super(UdemyIE, self)._download_json(url_or_request, *args, **kwargs) |
61c0663c S |
168 | self._handle_error(response) |
169 | return response | |
e2937118 | 170 | |
e5de3f6c S |
171 | def _real_initialize(self): |
172 | self._login() | |
173 | ||
174 | def _login(self): | |
68217024 | 175 | username, password = self._get_login_info() |
e5de3f6c | 176 | if username is None: |
78717fc3 | 177 | return |
e5de3f6c S |
178 | |
179 | login_popup = self._download_webpage( | |
dcd4d95c | 180 | self._LOGIN_URL, None, 'Downloading login popup') |
e5de3f6c | 181 | |
d609edf4 | 182 | def is_logged(webpage): |
807cf7b0 S |
183 | return any(re.search(p, webpage) for p in ( |
184 | r'href=["\'](?:https://www\.udemy\.com)?/user/logout/', | |
185 | r'>Logout<')) | |
d609edf4 S |
186 | |
187 | # already logged in | |
188 | if is_logged(login_popup): | |
e5de3f6c S |
189 | return |
190 | ||
dcd4d95c | 191 | login_form = self._form_hidden_inputs('login-form', login_popup) |
e5de3f6c | 192 | |
dcd4d95c | 193 | login_form.update({ |
a3373823 S |
194 | 'email': username, |
195 | 'password': password, | |
dcd4d95c S |
196 | }) |
197 | ||
dcd4d95c | 198 | response = self._download_webpage( |
e4d95865 | 199 | self._LOGIN_URL, None, 'Logging in', |
75b81df3 S |
200 | data=urlencode_postdata(login_form), |
201 | headers={ | |
202 | 'Referer': self._ORIGIN_URL, | |
203 | 'Origin': self._ORIGIN_URL, | |
204 | }) | |
e5de3f6c | 205 | |
d609edf4 | 206 | if not is_logged(response): |
dcd4d95c S |
207 | error = self._html_search_regex( |
208 | r'(?s)<div[^>]+class="form-errors[^"]*">(.+?)</div>', | |
209 | response, 'error message', default=None) | |
210 | if error: | |
211 | raise ExtractorError('Unable to login: %s' % error, expected=True) | |
e5de3f6c S |
212 | raise ExtractorError('Unable to log in') |
213 | ||
214 | def _real_extract(self, url): | |
810fb84d | 215 | lecture_id = self._match_id(url) |
e5de3f6c | 216 | |
328f82d5 S |
217 | webpage = self._download_webpage(url, lecture_id) |
218 | ||
81da8cbc | 219 | course_id, _ = self._extract_course_info(webpage, lecture_id) |
e5de3f6c | 220 | |
328f82d5 S |
221 | try: |
222 | lecture = self._download_lecture(course_id, lecture_id) | |
223 | except ExtractorError as e: | |
224 | # Error could possibly mean we are not enrolled in the course | |
225 | if isinstance(e.cause, compat_HTTPError) and e.cause.code == 403: | |
ff9d5d09 | 226 | self._enroll_course(url, webpage, course_id) |
3092fc40 | 227 | lecture = self._download_lecture(course_id, lecture_id) |
328f82d5 S |
228 | else: |
229 | raise | |
230 | ||
231 | title = lecture['title'] | |
232 | description = lecture.get('description') | |
233 | ||
234 | asset = lecture['asset'] | |
235 | ||
03caa463 | 236 | asset_type = asset.get('asset_type') or asset.get('assetType') |
e2937118 S |
237 | if asset_type != 'Video': |
238 | raise ExtractorError( | |
239 | 'Lecture %s is not a video' % lecture_id, expected=True) | |
e5de3f6c | 240 | |
03caa463 | 241 | stream_url = asset.get('stream_url') or asset.get('streamUrl') |
328f82d5 S |
242 | if stream_url: |
243 | youtube_url = self._search_regex( | |
244 | r'(https?://www\.youtube\.com/watch\?v=.*)', stream_url, 'youtube URL', default=None) | |
245 | if youtube_url: | |
246 | return self.url_result(youtube_url, 'Youtube') | |
e5de3f6c | 247 | |
0a439c5c | 248 | video_id = compat_str(asset['id']) |
03caa463 | 249 | thumbnail = asset.get('thumbnail_url') or asset.get('thumbnailUrl') |
328f82d5 | 250 | duration = float_or_none(asset.get('data', {}).get('duration')) |
328f82d5 | 251 | |
3dfceb28 S |
252 | subtitles = {} |
253 | automatic_captions = {} | |
254 | ||
328f82d5 | 255 | formats = [] |
f0e83681 | 256 | |
3dfceb28 | 257 | def extract_output_format(src, f_id): |
f0e83681 | 258 | return { |
b7f87493 | 259 | 'url': src.get('url'), |
3dfceb28 | 260 | 'format_id': '%sp' % (src.get('height') or f_id), |
f0e83681 S |
261 | 'width': int_or_none(src.get('width')), |
262 | 'height': int_or_none(src.get('height')), | |
263 | 'vbr': int_or_none(src.get('video_bitrate_in_kbps')), | |
264 | 'vcodec': src.get('video_codec'), | |
265 | 'fps': int_or_none(src.get('frame_rate')), | |
266 | 'abr': int_or_none(src.get('audio_bitrate_in_kbps')), | |
267 | 'acodec': src.get('audio_codec'), | |
268 | 'asr': int_or_none(src.get('audio_sample_rate')), | |
269 | 'tbr': int_or_none(src.get('total_bitrate_in_kbps')), | |
270 | 'filesize': int_or_none(src.get('file_size_in_bytes')), | |
328f82d5 | 271 | } |
f0e83681 S |
272 | |
273 | outputs = asset.get('data', {}).get('outputs') | |
274 | if not isinstance(outputs, dict): | |
275 | outputs = {} | |
276 | ||
af4116f4 | 277 | def add_output_format_meta(f, key): |
62f55aa6 S |
278 | output = outputs.get(key) |
279 | if isinstance(output, dict): | |
3dfceb28 | 280 | output_format = extract_output_format(output, key) |
62f55aa6 S |
281 | output_format.update(f) |
282 | return output_format | |
af4116f4 | 283 | return f |
62f55aa6 | 284 | |
3dfceb28 S |
285 | def extract_formats(source_list): |
286 | if not isinstance(source_list, list): | |
287 | return | |
288 | for source in source_list: | |
3052a30d S |
289 | video_url = url_or_none(source.get('file') or source.get('src')) |
290 | if not video_url: | |
3dfceb28 | 291 | continue |
913b61ee S |
292 | if source.get('type') == 'application/x-mpegURL' or determine_ext(video_url) == 'm3u8': |
293 | formats.extend(self._extract_m3u8_formats( | |
294 | video_url, video_id, 'mp4', entry_protocol='m3u8_native', | |
295 | m3u8_id='hls', fatal=False)) | |
296 | continue | |
3dfceb28 S |
297 | format_id = source.get('label') |
298 | f = { | |
299 | 'url': video_url, | |
300 | 'format_id': '%sp' % format_id, | |
301 | 'height': int_or_none(format_id), | |
302 | } | |
303 | if format_id: | |
304 | # Some videos contain additional metadata (e.g. | |
305 | # https://www.udemy.com/ios9-swift/learn/#/lecture/3383208) | |
306 | f = add_output_format_meta(f, format_id) | |
307 | formats.append(f) | |
308 | ||
57a38a38 S |
309 | def extract_subtitles(track_list): |
310 | if not isinstance(track_list, list): | |
311 | return | |
312 | for track in track_list: | |
313 | if not isinstance(track, dict): | |
314 | continue | |
315 | if track.get('kind') != 'captions': | |
316 | continue | |
3052a30d S |
317 | src = url_or_none(track.get('src')) |
318 | if not src: | |
57a38a38 S |
319 | continue |
320 | lang = track.get('language') or track.get( | |
321 | 'srclang') or track.get('label') | |
322 | sub_dict = automatic_captions if track.get( | |
323 | 'autogenerated') is True else subtitles | |
324 | sub_dict.setdefault(lang, []).append({ | |
325 | 'url': src, | |
326 | }) | |
327 | ||
0ce76801 S |
328 | for url_kind in ('download', 'stream'): |
329 | urls = asset.get('%s_urls' % url_kind) | |
330 | if isinstance(urls, dict): | |
331 | extract_formats(urls.get('Video')) | |
3b35c342 | 332 | |
2fbd8635 S |
333 | captions = asset.get('captions') |
334 | if isinstance(captions, list): | |
335 | for cc in captions: | |
336 | if not isinstance(cc, dict): | |
337 | continue | |
3052a30d S |
338 | cc_url = url_or_none(cc.get('url')) |
339 | if not cc_url: | |
2fbd8635 S |
340 | continue |
341 | lang = try_get(cc, lambda x: x['locale']['locale'], compat_str) | |
342 | sub_dict = (automatic_captions if cc.get('source') == 'auto' | |
343 | else subtitles) | |
344 | sub_dict.setdefault(lang or 'en', []).append({ | |
345 | 'url': cc_url, | |
346 | }) | |
347 | ||
efcba804 S |
348 | view_html = lecture.get('view_html') |
349 | if view_html: | |
350 | view_html_urls = set() | |
351 | for source in re.findall(r'<source[^>]+>', view_html): | |
352 | attributes = extract_attributes(source) | |
353 | src = attributes.get('src') | |
354 | if not src: | |
355 | continue | |
356 | res = attributes.get('data-res') | |
357 | height = int_or_none(res) | |
358 | if src in view_html_urls: | |
359 | continue | |
360 | view_html_urls.add(src) | |
361 | if attributes.get('type') == 'application/x-mpegURL' or determine_ext(src) == 'm3u8': | |
362 | m3u8_formats = self._extract_m3u8_formats( | |
363 | src, video_id, 'mp4', entry_protocol='m3u8_native', | |
364 | m3u8_id='hls', fatal=False) | |
365 | for f in m3u8_formats: | |
366 | m = re.search(r'/hls_(?P<height>\d{3,4})_(?P<tbr>\d{2,})/', f['url']) | |
367 | if m: | |
368 | if not f.get('height'): | |
369 | f['height'] = int(m.group('height')) | |
370 | if not f.get('tbr'): | |
371 | f['tbr'] = int(m.group('tbr')) | |
372 | formats.extend(m3u8_formats) | |
373 | else: | |
62f55aa6 | 374 | formats.append(add_output_format_meta({ |
efcba804 | 375 | 'url': src, |
af4116f4 | 376 | 'format_id': '%dp' % height if height else None, |
efcba804 | 377 | 'height': height, |
af4116f4 | 378 | }, res)) |
efcba804 | 379 | |
3dfceb28 | 380 | # react rendition since 2017.04.15 (see |
067aa17e | 381 | # https://github.com/ytdl-org/youtube-dl/issues/12744) |
3dfceb28 S |
382 | data = self._parse_json( |
383 | self._search_regex( | |
384 | r'videojs-setup-data=(["\'])(?P<data>{.+?})\1', view_html, | |
385 | 'setup data', default='{}', group='data'), video_id, | |
386 | transform_source=unescapeHTML, fatal=False) | |
387 | if data and isinstance(data, dict): | |
388 | extract_formats(data.get('sources')) | |
389 | if not duration: | |
390 | duration = int_or_none(data.get('duration')) | |
57a38a38 S |
391 | extract_subtitles(data.get('tracks')) |
392 | ||
393 | if not subtitles and not automatic_captions: | |
394 | text_tracks = self._parse_json( | |
395 | self._search_regex( | |
396 | r'text-tracks=(["\'])(?P<data>\[.+?\])\1', view_html, | |
397 | 'text tracks', default='{}', group='data'), video_id, | |
398 | transform_source=lambda s: js_to_json(unescapeHTML(s)), | |
399 | fatal=False) | |
400 | extract_subtitles(text_tracks) | |
3dfceb28 | 401 | |
85139634 S |
402 | if not formats and outputs: |
403 | for format_id, output in outputs.items(): | |
404 | f = extract_output_format(output, format_id) | |
405 | if f.get('url'): | |
406 | formats.append(f) | |
407 | ||
54f37eea | 408 | self._sort_formats(formats) |
e5de3f6c | 409 | |
e5de3f6c S |
410 | return { |
411 | 'id': video_id, | |
412 | 'title': title, | |
413 | 'description': description, | |
414 | 'thumbnail': thumbnail, | |
415 | 'duration': duration, | |
3dfceb28 S |
416 | 'formats': formats, |
417 | 'subtitles': subtitles, | |
418 | 'automatic_captions': automatic_captions, | |
e5de3f6c S |
419 | } |
420 | ||
421 | ||
422 | class UdemyCourseIE(UdemyIE): | |
423 | IE_NAME = 'udemy:course' | |
d7d51389 S |
424 | _VALID_URL = r'https?://(?:[^/]+\.)?udemy\.com/(?P<id>[^/?#&]+)' |
425 | _TESTS = [{ | |
426 | 'url': 'https://www.udemy.com/java-tutorial/', | |
427 | 'only_matching': True, | |
428 | }, { | |
429 | 'url': 'https://wipro.udemy.com/java-tutorial/', | |
430 | 'only_matching': True, | |
431 | }] | |
e5de3f6c S |
432 | |
433 | @classmethod | |
434 | def suitable(cls, url): | |
435 | return False if UdemyIE.suitable(url) else super(UdemyCourseIE, cls).suitable(url) | |
436 | ||
437 | def _real_extract(self, url): | |
328f82d5 S |
438 | course_path = self._match_id(url) |
439 | ||
440 | webpage = self._download_webpage(url, course_path) | |
e5de3f6c | 441 | |
81da8cbc | 442 | course_id, title = self._extract_course_info(webpage, course_path) |
e5de3f6c | 443 | |
ff9d5d09 | 444 | self._enroll_course(url, webpage, course_id) |
e5de3f6c | 445 | |
6bb46007 | 446 | response = self._download_json( |
81da8cbc | 447 | 'https://www.udemy.com/api-2.0/courses/%s/cached-subscriber-curriculum-items' % course_id, |
6bb46007 | 448 | course_id, 'Downloading course curriculum', query={ |
81da8cbc | 449 | 'fields[chapter]': 'title,object_index', |
03caa463 | 450 | 'fields[lecture]': 'title,asset', |
81da8cbc S |
451 | 'page_size': '1000', |
452 | }) | |
453 | ||
4d402db5 | 454 | entries = [] |
81da8cbc S |
455 | chapter, chapter_number = [None] * 2 |
456 | for entry in response['results']: | |
457 | clazz = entry.get('_class') | |
458 | if clazz == 'lecture': | |
03caa463 S |
459 | asset = entry.get('asset') |
460 | if isinstance(asset, dict): | |
461 | asset_type = asset.get('asset_type') or asset.get('assetType') | |
462 | if asset_type != 'Video': | |
463 | continue | |
81da8cbc S |
464 | lecture_id = entry.get('id') |
465 | if lecture_id: | |
4d402db5 S |
466 | entry = { |
467 | '_type': 'url_transparent', | |
b53a06e3 | 468 | 'url': 'https://www.udemy.com/%s/learn/v4/t/lecture/%s' % (course_path, entry['id']), |
81da8cbc | 469 | 'title': entry.get('title'), |
4d402db5 S |
470 | 'ie_key': UdemyIE.ie_key(), |
471 | } | |
5bafcf65 S |
472 | if chapter_number: |
473 | entry['chapter_number'] = chapter_number | |
4d402db5 S |
474 | if chapter: |
475 | entry['chapter'] = chapter | |
476 | entries.append(entry) | |
81da8cbc S |
477 | elif clazz == 'chapter': |
478 | chapter_number = entry.get('object_index') | |
479 | chapter = entry.get('title') | |
e5de3f6c | 480 | |
81da8cbc | 481 | return self.playlist_result(entries, course_id, title) |