def download_class(args, class_name): """ Download all requested resources from the class given in class_name. Returns True if the class appears completed. """ session = requests.Session() if args.preview: # Todo, remove this. session.cookie_values = 'dummy=dummy' else: get_cookies_for_class( session, class_name, cookies_file=args.cookies_file, username=args.username, password=args.password ) session.cookie_values = make_cookie_values(session.cookies, class_name) # get the syllabus listing page = get_syllabus(session, class_name, args.local_page, args.preview) # parse it sections = parse_syllabus(session, page, args.reverse, args.intact_fnames) if args.about: download_about(session, class_name, args.path, args.overwrite) downloader = get_downloader(session, class_name, args) # obtain the resources completed = download_lectures( downloader, class_name, sections, args.file_formats, args.overwrite, args.skip_download, args.section_filter, args.lecture_filter, args.resource_filter, args.path, args.verbose_dirs, args.preview, args.combined_section_lectures_nums, args.hooks, args.playlist, args.intact_fnames) return completed
def download_class(args, class_name): """ Download all requested resources from the class given in class_name. Returns True if the class appears completed. """ session = requests.Session() if args.preview: # Todo, remove this. session.cookie_values = 'dummy=dummy' else: get_cookies_for_class(session, class_name, cookies_file=args.cookies_file, username=args.username, password=args.password) session.cookie_values = make_cookie_values(session.cookies, class_name) # get the syllabus listing page = get_syllabus(session, class_name, args.local_page, args.preview) # parse it sections = parse_syllabus(session, page, args.reverse, args.intact_fnames) if args.about: download_about(session, class_name, args.path, args.overwrite) downloader = get_downloader(session, class_name, args) # obtain the resources completed = download_lectures( downloader, class_name, sections, args.file_formats, args.overwrite, args.skip_download, args.section_filter, args.lecture_filter, args.resource_filter, args.path, args.verbose_dirs, args.preview, args.combined_section_lectures_nums, args.hooks, args.playlist, args.intact_fnames) return completed
def download_old_style_class(args, class_name): """ Download all requested resources from the class given in class_name. Old style classes are classes located at class.coursera.org. Read more about course types here: https://learner.coursera.help/hc/en-us/articles/203879739-Course-Types Returns True if the class appears completed. """ session = get_session() if args.preview: # Todo, remove this. session.cookie_values = "dummy=dummy" else: get_cookies_for_class( session, class_name, cookies_file=args.cookies_file, username=args.username, password=args.password ) session.cookie_values = make_cookie_values(session.cookies, class_name) subtitle_language = args.subtitle_language if args.about or args.subtitle_language != "en": about = download_about(session, class_name, args.path, args.overwrite, args.subtitle_language) # Check if subtitle is available if not about or not about["subtitleLanguagesCsv"].split(",").count(args.subtitle_language): logging.warning("Subtitle unavailable in specified language") subtitle_language = "en" # get the syllabus listing page = get_old_style_syllabus(session, class_name, args.local_page, args.preview) # parse it sections = parse_old_style_syllabus(session, page, args.reverse, args.intact_fnames, subtitle_language) downloader = get_downloader(session, class_name, args) ignored_formats = [] if args.ignore_formats: ignored_formats = args.ignore_formats.split(",") # obtain the resources completed = download_lectures( downloader, class_name, sections, args.file_formats, args.overwrite, args.skip_download, args.section_filter, args.lecture_filter, args.resource_filter, args.path, args.verbose_dirs, args.preview, args.combined_section_lectures_nums, args.hooks, args.playlist, args.intact_fnames, ignored_formats, args.resume, args.video_resolution, ) return completed