You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

457 lines
18 KiB

Switch codebase to use sanitized_Request instead of compat_urllib_request.Request [downloader/dash] Use sanitized_Request [downloader/http] Use sanitized_Request [atresplayer] Use sanitized_Request [bambuser] Use sanitized_Request [bliptv] Use sanitized_Request [brightcove] Use sanitized_Request [cbs] Use sanitized_Request [ceskatelevize] Use sanitized_Request [collegerama] Use sanitized_Request [extractor/common] Use sanitized_Request [crunchyroll] Use sanitized_Request [dailymotion] Use sanitized_Request [dcn] Use sanitized_Request [dramafever] Use sanitized_Request [dumpert] Use sanitized_Request [eitb] Use sanitized_Request [escapist] Use sanitized_Request [everyonesmixtape] Use sanitized_Request [extremetube] Use sanitized_Request [facebook] Use sanitized_Request [fc2] Use sanitized_Request [flickr] Use sanitized_Request [4tube] Use sanitized_Request [gdcvault] Use sanitized_Request [extractor/generic] Use sanitized_Request [hearthisat] Use sanitized_Request [hotnewhiphop] Use sanitized_Request [hypem] Use sanitized_Request [iprima] Use sanitized_Request [ivi] Use sanitized_Request [keezmovies] Use sanitized_Request [letv] Use sanitized_Request [lynda] Use sanitized_Request [metacafe] Use sanitized_Request [minhateca] Use sanitized_Request [miomio] Use sanitized_Request [meovideo] Use sanitized_Request [mofosex] Use sanitized_Request [moniker] Use sanitized_Request [mooshare] Use sanitized_Request [movieclips] Use sanitized_Request [mtv] Use sanitized_Request [myvideo] Use sanitized_Request [neteasemusic] Use sanitized_Request [nfb] Use sanitized_Request [niconico] Use sanitized_Request [noco] Use sanitized_Request [nosvideo] Use sanitized_Request [novamov] Use sanitized_Request [nowness] Use sanitized_Request [nuvid] Use sanitized_Request [played] Use sanitized_Request [pluralsight] Use sanitized_Request [pornhub] Use sanitized_Request [pornotube] Use sanitized_Request [primesharetv] Use sanitized_Request [promptfile] Use sanitized_Request [qqmusic] Use sanitized_Request [rtve] Use sanitized_Request [safari] Use sanitized_Request [sandia] Use sanitized_Request [shared] Use sanitized_Request [sharesix] Use sanitized_Request [sina] Use sanitized_Request [smotri] Use sanitized_Request [sohu] Use sanitized_Request [spankwire] Use sanitized_Request [sportdeutschland] Use sanitized_Request [streamcloud] Use sanitized_Request [streamcz] Use sanitized_Request [tapely] Use sanitized_Request [tube8] Use sanitized_Request [tubitv] Use sanitized_Request [twitch] Use sanitized_Request [twitter] Use sanitized_Request [udemy] Use sanitized_Request [vbox7] Use sanitized_Request [veoh] Use sanitized_Request [vessel] Use sanitized_Request [vevo] Use sanitized_Request [viddler] Use sanitized_Request [videomega] Use sanitized_Request [viewvster] Use sanitized_Request [viki] Use sanitized_Request [vk] Use sanitized_Request [vodlocker] Use sanitized_Request [voicerepublic] Use sanitized_Request [wistia] Use sanitized_Request [xfileshare] Use sanitized_Request [xtube] Use sanitized_Request [xvideos] Use sanitized_Request [yandexmusic] Use sanitized_Request [youku] Use sanitized_Request [youporn] Use sanitized_Request [youtube] Use sanitized_Request [patreon] Use sanitized_Request [extractor/common] Remove unused import [nfb] PEP 8
9 years ago
Switch codebase to use sanitized_Request instead of compat_urllib_request.Request [downloader/dash] Use sanitized_Request [downloader/http] Use sanitized_Request [atresplayer] Use sanitized_Request [bambuser] Use sanitized_Request [bliptv] Use sanitized_Request [brightcove] Use sanitized_Request [cbs] Use sanitized_Request [ceskatelevize] Use sanitized_Request [collegerama] Use sanitized_Request [extractor/common] Use sanitized_Request [crunchyroll] Use sanitized_Request [dailymotion] Use sanitized_Request [dcn] Use sanitized_Request [dramafever] Use sanitized_Request [dumpert] Use sanitized_Request [eitb] Use sanitized_Request [escapist] Use sanitized_Request [everyonesmixtape] Use sanitized_Request [extremetube] Use sanitized_Request [facebook] Use sanitized_Request [fc2] Use sanitized_Request [flickr] Use sanitized_Request [4tube] Use sanitized_Request [gdcvault] Use sanitized_Request [extractor/generic] Use sanitized_Request [hearthisat] Use sanitized_Request [hotnewhiphop] Use sanitized_Request [hypem] Use sanitized_Request [iprima] Use sanitized_Request [ivi] Use sanitized_Request [keezmovies] Use sanitized_Request [letv] Use sanitized_Request [lynda] Use sanitized_Request [metacafe] Use sanitized_Request [minhateca] Use sanitized_Request [miomio] Use sanitized_Request [meovideo] Use sanitized_Request [mofosex] Use sanitized_Request [moniker] Use sanitized_Request [mooshare] Use sanitized_Request [movieclips] Use sanitized_Request [mtv] Use sanitized_Request [myvideo] Use sanitized_Request [neteasemusic] Use sanitized_Request [nfb] Use sanitized_Request [niconico] Use sanitized_Request [noco] Use sanitized_Request [nosvideo] Use sanitized_Request [novamov] Use sanitized_Request [nowness] Use sanitized_Request [nuvid] Use sanitized_Request [played] Use sanitized_Request [pluralsight] Use sanitized_Request [pornhub] Use sanitized_Request [pornotube] Use sanitized_Request [primesharetv] Use sanitized_Request [promptfile] Use sanitized_Request [qqmusic] Use sanitized_Request [rtve] Use sanitized_Request [safari] Use sanitized_Request [sandia] Use sanitized_Request [shared] Use sanitized_Request [sharesix] Use sanitized_Request [sina] Use sanitized_Request [smotri] Use sanitized_Request [sohu] Use sanitized_Request [spankwire] Use sanitized_Request [sportdeutschland] Use sanitized_Request [streamcloud] Use sanitized_Request [streamcz] Use sanitized_Request [tapely] Use sanitized_Request [tube8] Use sanitized_Request [tubitv] Use sanitized_Request [twitch] Use sanitized_Request [twitter] Use sanitized_Request [udemy] Use sanitized_Request [vbox7] Use sanitized_Request [veoh] Use sanitized_Request [vessel] Use sanitized_Request [vevo] Use sanitized_Request [viddler] Use sanitized_Request [videomega] Use sanitized_Request [viewvster] Use sanitized_Request [viki] Use sanitized_Request [vk] Use sanitized_Request [vodlocker] Use sanitized_Request [voicerepublic] Use sanitized_Request [wistia] Use sanitized_Request [xfileshare] Use sanitized_Request [xtube] Use sanitized_Request [xvideos] Use sanitized_Request [yandexmusic] Use sanitized_Request [youku] Use sanitized_Request [youporn] Use sanitized_Request [youtube] Use sanitized_Request [patreon] Use sanitized_Request [extractor/common] Remove unused import [nfb] PEP 8
9 years ago
  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..compat import (
  5. compat_HTTPError,
  6. compat_kwargs,
  7. compat_str,
  8. compat_urllib_request,
  9. compat_urlparse,
  10. )
  11. from ..utils import (
  12. determine_ext,
  13. extract_attributes,
  14. ExtractorError,
  15. float_or_none,
  16. int_or_none,
  17. js_to_json,
  18. sanitized_Request,
  19. try_get,
  20. unescapeHTML,
  21. url_or_none,
  22. urlencode_postdata,
  23. )
  24. class UdemyIE(InfoExtractor):
  25. IE_NAME = 'udemy'
  26. _VALID_URL = r'''(?x)
  27. https?://
  28. www\.udemy\.com/
  29. (?:
  30. [^#]+\#/lecture/|
  31. lecture/view/?\?lectureId=|
  32. [^/]+/learn/v4/t/lecture/
  33. )
  34. (?P<id>\d+)
  35. '''
  36. _LOGIN_URL = 'https://www.udemy.com/join/login-popup/?displayType=ajax&showSkipButton=1'
  37. _ORIGIN_URL = 'https://www.udemy.com'
  38. _NETRC_MACHINE = 'udemy'
  39. _TESTS = [{
  40. 'url': 'https://www.udemy.com/java-tutorial/#/lecture/172757',
  41. 'md5': '98eda5b657e752cf945d8445e261b5c5',
  42. 'info_dict': {
  43. 'id': '160614',
  44. 'ext': 'mp4',
  45. 'title': 'Introduction and Installation',
  46. 'description': 'md5:c0d51f6f21ef4ec65f091055a5eef876',
  47. 'duration': 579.29,
  48. },
  49. 'skip': 'Requires udemy account credentials',
  50. }, {
  51. # new URL schema
  52. 'url': 'https://www.udemy.com/electric-bass-right-from-the-start/learn/v4/t/lecture/4580906',
  53. 'only_matching': True,
  54. }, {
  55. # no url in outputs format entry
  56. 'url': 'https://www.udemy.com/learn-web-development-complete-step-by-step-guide-to-success/learn/v4/t/lecture/4125812',
  57. 'only_matching': True,
  58. }, {
  59. # only outputs rendition
  60. 'url': 'https://www.udemy.com/how-you-can-help-your-local-community-5-amazing-examples/learn/v4/t/lecture/3225750?start=0',
  61. 'only_matching': True,
  62. }]
  63. def _extract_course_info(self, webpage, video_id):
  64. course = self._parse_json(
  65. unescapeHTML(self._search_regex(
  66. r'ng-init=["\'].*\bcourse=({.+?})[;"\']',
  67. webpage, 'course', default='{}')),
  68. video_id, fatal=False) or {}
  69. course_id = course.get('id') or self._search_regex(
  70. r'data-course-id=["\'](\d+)', webpage, 'course id')
  71. return course_id, course.get('title')
  72. def _enroll_course(self, base_url, webpage, course_id):
  73. def combine_url(base_url, url):
  74. return compat_urlparse.urljoin(base_url, url) if not url.startswith('http') else url
  75. checkout_url = unescapeHTML(self._search_regex(
  76. r'href=(["\'])(?P<url>(?:https?://(?:www\.)?udemy\.com)?/(?:payment|cart)/checkout/.+?)\1',
  77. webpage, 'checkout url', group='url', default=None))
  78. if checkout_url:
  79. raise ExtractorError(
  80. 'Course %s is not free. You have to pay for it before you can download. '
  81. 'Use this URL to confirm purchase: %s'
  82. % (course_id, combine_url(base_url, checkout_url)),
  83. expected=True)
  84. enroll_url = unescapeHTML(self._search_regex(
  85. r'href=(["\'])(?P<url>(?:https?://(?:www\.)?udemy\.com)?/course/subscribe/.+?)\1',
  86. webpage, 'enroll url', group='url', default=None))
  87. if enroll_url:
  88. webpage = self._download_webpage(
  89. combine_url(base_url, enroll_url),
  90. course_id, 'Enrolling in the course',
  91. headers={'Referer': base_url})
  92. if '>You have enrolled in' in webpage:
  93. self.to_screen('%s: Successfully enrolled in the course' % course_id)
  94. def _download_lecture(self, course_id, lecture_id):
  95. return self._download_json(
  96. 'https://www.udemy.com/api-2.0/users/me/subscribed-courses/%s/lectures/%s?'
  97. % (course_id, lecture_id),
  98. lecture_id, 'Downloading lecture JSON', query={
  99. 'fields[lecture]': 'title,description,view_html,asset',
  100. 'fields[asset]': 'asset_type,stream_url,thumbnail_url,download_urls,stream_urls,captions,data',
  101. })
  102. def _handle_error(self, response):
  103. if not isinstance(response, dict):
  104. return
  105. error = response.get('error')
  106. if error:
  107. error_str = 'Udemy returned error #%s: %s' % (error.get('code'), error.get('message'))
  108. error_data = error.get('data')
  109. if error_data:
  110. error_str += ' - %s' % error_data.get('formErrors')
  111. raise ExtractorError(error_str, expected=True)
  112. def _download_webpage_handle(self, *args, **kwargs):
  113. headers = kwargs.get('headers', {}).copy()
  114. headers['User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4'
  115. kwargs['headers'] = headers
  116. return super(UdemyIE, self)._download_webpage_handle(
  117. *args, **compat_kwargs(kwargs))
  118. def _download_json(self, url_or_request, *args, **kwargs):
  119. headers = {
  120. 'X-Udemy-Snail-Case': 'true',
  121. 'X-Requested-With': 'XMLHttpRequest',
  122. }
  123. for cookie in self._downloader.cookiejar:
  124. if cookie.name == 'client_id':
  125. headers['X-Udemy-Client-Id'] = cookie.value
  126. elif cookie.name == 'access_token':
  127. headers['X-Udemy-Bearer-Token'] = cookie.value
  128. headers['X-Udemy-Authorization'] = 'Bearer %s' % cookie.value
  129. if isinstance(url_or_request, compat_urllib_request.Request):
  130. for header, value in headers.items():
  131. url_or_request.add_header(header, value)
  132. else:
  133. url_or_request = sanitized_Request(url_or_request, headers=headers)
  134. response = super(UdemyIE, self)._download_json(url_or_request, *args, **kwargs)
  135. self._handle_error(response)
  136. return response
  137. def _real_initialize(self):
  138. self._login()
  139. def _login(self):
  140. username, password = self._get_login_info()
  141. if username is None:
  142. return
  143. login_popup = self._download_webpage(
  144. self._LOGIN_URL, None, 'Downloading login popup')
  145. def is_logged(webpage):
  146. return any(re.search(p, webpage) for p in (
  147. r'href=["\'](?:https://www\.udemy\.com)?/user/logout/',
  148. r'>Logout<'))
  149. # already logged in
  150. if is_logged(login_popup):
  151. return
  152. login_form = self._form_hidden_inputs('login-form', login_popup)
  153. login_form.update({
  154. 'email': username,
  155. 'password': password,
  156. })
  157. response = self._download_webpage(
  158. self._LOGIN_URL, None, 'Logging in',
  159. data=urlencode_postdata(login_form),
  160. headers={
  161. 'Referer': self._ORIGIN_URL,
  162. 'Origin': self._ORIGIN_URL,
  163. })
  164. if not is_logged(response):
  165. error = self._html_search_regex(
  166. r'(?s)<div[^>]+class="form-errors[^"]*">(.+?)</div>',
  167. response, 'error message', default=None)
  168. if error:
  169. raise ExtractorError('Unable to login: %s' % error, expected=True)
  170. raise ExtractorError('Unable to log in')
  171. def _real_extract(self, url):
  172. lecture_id = self._match_id(url)
  173. webpage = self._download_webpage(url, lecture_id)
  174. course_id, _ = self._extract_course_info(webpage, lecture_id)
  175. try:
  176. lecture = self._download_lecture(course_id, lecture_id)
  177. except ExtractorError as e:
  178. # Error could possibly mean we are not enrolled in the course
  179. if isinstance(e.cause, compat_HTTPError) and e.cause.code == 403:
  180. self._enroll_course(url, webpage, course_id)
  181. lecture = self._download_lecture(course_id, lecture_id)
  182. else:
  183. raise
  184. title = lecture['title']
  185. description = lecture.get('description')
  186. asset = lecture['asset']
  187. asset_type = asset.get('asset_type') or asset.get('assetType')
  188. if asset_type != 'Video':
  189. raise ExtractorError(
  190. 'Lecture %s is not a video' % lecture_id, expected=True)
  191. stream_url = asset.get('stream_url') or asset.get('streamUrl')
  192. if stream_url:
  193. youtube_url = self._search_regex(
  194. r'(https?://www\.youtube\.com/watch\?v=.*)', stream_url, 'youtube URL', default=None)
  195. if youtube_url:
  196. return self.url_result(youtube_url, 'Youtube')
  197. video_id = compat_str(asset['id'])
  198. thumbnail = asset.get('thumbnail_url') or asset.get('thumbnailUrl')
  199. duration = float_or_none(asset.get('data', {}).get('duration'))
  200. subtitles = {}
  201. automatic_captions = {}
  202. formats = []
  203. def extract_output_format(src, f_id):
  204. return {
  205. 'url': src.get('url'),
  206. 'format_id': '%sp' % (src.get('height') or f_id),
  207. 'width': int_or_none(src.get('width')),
  208. 'height': int_or_none(src.get('height')),
  209. 'vbr': int_or_none(src.get('video_bitrate_in_kbps')),
  210. 'vcodec': src.get('video_codec'),
  211. 'fps': int_or_none(src.get('frame_rate')),
  212. 'abr': int_or_none(src.get('audio_bitrate_in_kbps')),
  213. 'acodec': src.get('audio_codec'),
  214. 'asr': int_or_none(src.get('audio_sample_rate')),
  215. 'tbr': int_or_none(src.get('total_bitrate_in_kbps')),
  216. 'filesize': int_or_none(src.get('file_size_in_bytes')),
  217. }
  218. outputs = asset.get('data', {}).get('outputs')
  219. if not isinstance(outputs, dict):
  220. outputs = {}
  221. def add_output_format_meta(f, key):
  222. output = outputs.get(key)
  223. if isinstance(output, dict):
  224. output_format = extract_output_format(output, key)
  225. output_format.update(f)
  226. return output_format
  227. return f
  228. def extract_formats(source_list):
  229. if not isinstance(source_list, list):
  230. return
  231. for source in source_list:
  232. video_url = url_or_none(source.get('file') or source.get('src'))
  233. if not video_url:
  234. continue
  235. if source.get('type') == 'application/x-mpegURL' or determine_ext(video_url) == 'm3u8':
  236. formats.extend(self._extract_m3u8_formats(
  237. video_url, video_id, 'mp4', entry_protocol='m3u8_native',
  238. m3u8_id='hls', fatal=False))
  239. continue
  240. format_id = source.get('label')
  241. f = {
  242. 'url': video_url,
  243. 'format_id': '%sp' % format_id,
  244. 'height': int_or_none(format_id),
  245. }
  246. if format_id:
  247. # Some videos contain additional metadata (e.g.
  248. # https://www.udemy.com/ios9-swift/learn/#/lecture/3383208)
  249. f = add_output_format_meta(f, format_id)
  250. formats.append(f)
  251. def extract_subtitles(track_list):
  252. if not isinstance(track_list, list):
  253. return
  254. for track in track_list:
  255. if not isinstance(track, dict):
  256. continue
  257. if track.get('kind') != 'captions':
  258. continue
  259. src = url_or_none(track.get('src'))
  260. if not src:
  261. continue
  262. lang = track.get('language') or track.get(
  263. 'srclang') or track.get('label')
  264. sub_dict = automatic_captions if track.get(
  265. 'autogenerated') is True else subtitles
  266. sub_dict.setdefault(lang, []).append({
  267. 'url': src,
  268. })
  269. for url_kind in ('download', 'stream'):
  270. urls = asset.get('%s_urls' % url_kind)
  271. if isinstance(urls, dict):
  272. extract_formats(urls.get('Video'))
  273. captions = asset.get('captions')
  274. if isinstance(captions, list):
  275. for cc in captions:
  276. if not isinstance(cc, dict):
  277. continue
  278. cc_url = url_or_none(cc.get('url'))
  279. if not cc_url:
  280. continue
  281. lang = try_get(cc, lambda x: x['locale']['locale'], compat_str)
  282. sub_dict = (automatic_captions if cc.get('source') == 'auto'
  283. else subtitles)
  284. sub_dict.setdefault(lang or 'en', []).append({
  285. 'url': cc_url,
  286. })
  287. view_html = lecture.get('view_html')
  288. if view_html:
  289. view_html_urls = set()
  290. for source in re.findall(r'<source[^>]+>', view_html):
  291. attributes = extract_attributes(source)
  292. src = attributes.get('src')
  293. if not src:
  294. continue
  295. res = attributes.get('data-res')
  296. height = int_or_none(res)
  297. if src in view_html_urls:
  298. continue
  299. view_html_urls.add(src)
  300. if attributes.get('type') == 'application/x-mpegURL' or determine_ext(src) == 'm3u8':
  301. m3u8_formats = self._extract_m3u8_formats(
  302. src, video_id, 'mp4', entry_protocol='m3u8_native',
  303. m3u8_id='hls', fatal=False)
  304. for f in m3u8_formats:
  305. m = re.search(r'/hls_(?P<height>\d{3,4})_(?P<tbr>\d{2,})/', f['url'])
  306. if m:
  307. if not f.get('height'):
  308. f['height'] = int(m.group('height'))
  309. if not f.get('tbr'):
  310. f['tbr'] = int(m.group('tbr'))
  311. formats.extend(m3u8_formats)
  312. else:
  313. formats.append(add_output_format_meta({
  314. 'url': src,
  315. 'format_id': '%dp' % height if height else None,
  316. 'height': height,
  317. }, res))
  318. # react rendition since 2017.04.15 (see
  319. # https://github.com/rg3/youtube-dl/issues/12744)
  320. data = self._parse_json(
  321. self._search_regex(
  322. r'videojs-setup-data=(["\'])(?P<data>{.+?})\1', view_html,
  323. 'setup data', default='{}', group='data'), video_id,
  324. transform_source=unescapeHTML, fatal=False)
  325. if data and isinstance(data, dict):
  326. extract_formats(data.get('sources'))
  327. if not duration:
  328. duration = int_or_none(data.get('duration'))
  329. extract_subtitles(data.get('tracks'))
  330. if not subtitles and not automatic_captions:
  331. text_tracks = self._parse_json(
  332. self._search_regex(
  333. r'text-tracks=(["\'])(?P<data>\[.+?\])\1', view_html,
  334. 'text tracks', default='{}', group='data'), video_id,
  335. transform_source=lambda s: js_to_json(unescapeHTML(s)),
  336. fatal=False)
  337. extract_subtitles(text_tracks)
  338. if not formats and outputs:
  339. for format_id, output in outputs.items():
  340. f = extract_output_format(output, format_id)
  341. if f.get('url'):
  342. formats.append(f)
  343. self._sort_formats(formats, field_preference=('height', 'width', 'tbr', 'format_id'))
  344. return {
  345. 'id': video_id,
  346. 'title': title,
  347. 'description': description,
  348. 'thumbnail': thumbnail,
  349. 'duration': duration,
  350. 'formats': formats,
  351. 'subtitles': subtitles,
  352. 'automatic_captions': automatic_captions,
  353. }
  354. class UdemyCourseIE(UdemyIE):
  355. IE_NAME = 'udemy:course'
  356. _VALID_URL = r'https?://(?:www\.)?udemy\.com/(?P<id>[^/?#&]+)'
  357. _TESTS = []
  358. @classmethod
  359. def suitable(cls, url):
  360. return False if UdemyIE.suitable(url) else super(UdemyCourseIE, cls).suitable(url)
  361. def _real_extract(self, url):
  362. course_path = self._match_id(url)
  363. webpage = self._download_webpage(url, course_path)
  364. course_id, title = self._extract_course_info(webpage, course_path)
  365. self._enroll_course(url, webpage, course_id)
  366. response = self._download_json(
  367. 'https://www.udemy.com/api-2.0/courses/%s/cached-subscriber-curriculum-items' % course_id,
  368. course_id, 'Downloading course curriculum', query={
  369. 'fields[chapter]': 'title,object_index',
  370. 'fields[lecture]': 'title,asset',
  371. 'page_size': '1000',
  372. })
  373. entries = []
  374. chapter, chapter_number = [None] * 2
  375. for entry in response['results']:
  376. clazz = entry.get('_class')
  377. if clazz == 'lecture':
  378. asset = entry.get('asset')
  379. if isinstance(asset, dict):
  380. asset_type = asset.get('asset_type') or asset.get('assetType')
  381. if asset_type != 'Video':
  382. continue
  383. lecture_id = entry.get('id')
  384. if lecture_id:
  385. entry = {
  386. '_type': 'url_transparent',
  387. 'url': 'https://www.udemy.com/%s/learn/v4/t/lecture/%s' % (course_path, entry['id']),
  388. 'title': entry.get('title'),
  389. 'ie_key': UdemyIE.ie_key(),
  390. }
  391. if chapter_number:
  392. entry['chapter_number'] = chapter_number
  393. if chapter:
  394. entry['chapter'] = chapter
  395. entries.append(entry)
  396. elif clazz == 'chapter':
  397. chapter_number = entry.get('object_index')
  398. chapter = entry.get('title')
  399. return self.playlist_result(entries, course_id, title)