def list_course_chapter_videos(s, courseId, chapterIndex): """ Create the list of playable videos within a chapter in the Kodi interface. """ course = scrape.get_course(s, courseId) chapters = course['Chapters'] videos = [] chapter = chapters[int(chapterIndex)] for video in chapter['Videos']: title = video['Title'] videoId = video['ID'] v = {"title": title, "videoId": videoId} videos.append(v) listing = [] for video in videos: list_item = xbmcgui.ListItem(label=video['title']) list_item.setProperty('IsPlayable', 'true') url = '{0}?action=play&videoId={1}'.format(__url__, video['videoId']) is_folder = False listing.append((url, list_item, is_folder)) xbmcplugin.addDirectoryItems(__handle__, listing, len(listing)) xbmcplugin.endOfDirectory(__handle__)
def list_course_chapters(s, courseId): """ Create the list of playable course chapters in the Kodi interface. """ course = scrape.get_course(s, courseId) chapters = course['Chapters'] listing = [] for i, chapter in enumerate(chapters): list_item = xbmcgui.ListItem(label=chapter['Title']) url = '{0}?action=list_course_chapter_videos&courseId={1}&chapterIndex={2}'.format(__url__, courseId, i) is_folder = True listing.append((url, list_item, is_folder)) xbmcplugin.addDirectoryItems(__handle__, listing, len(listing)) xbmcplugin.endOfDirectory(__handle__)