diff --git a/coursera/api.py b/coursera/api.py index 5de6106..a12ad60 100644 --- a/coursera/api.py +++ b/coursera/api.py @@ -22,7 +22,7 @@ from .define import (OPENCOURSE_SUPPLEMENT_URL, OPENCOURSE_ONDEMAND_COURSE_MATERIALS, OPENCOURSE_VIDEO_URL, - INSTRUCTIONS_CSS, + INSTRUCTIONS_HTML_INJECTION, IN_MEMORY_EXTENSION, IN_MEMORY_MARKER) @@ -173,7 +173,7 @@ class CourseraOnDemand(object): @type soup: BeautifulSoup """ # 1. Inject basic CSS style - css_soup = BeautifulSoup(INSTRUCTIONS_CSS) + css_soup = BeautifulSoup(INSTRUCTIONS_HTML_INJECTION) soup.head.append(css_soup) # 2. Replace with

diff --git a/coursera/coursera_dl.py b/coursera/coursera_dl.py index 6995634..d57cdfd 100644 --- a/coursera/coursera_dl.py +++ b/coursera/coursera_dl.py @@ -53,6 +53,7 @@ import shutil import subprocess import sys import time +import codecs from distutils.version import LooseVersion as V @@ -313,7 +314,7 @@ def parse_on_demand_syllabus(session, page, reverse=False, intact_fnames=False, course_name = dom['slug'] logging.info('Parsing syllabus of on-demand course. ' - 'This may take some time, be patient ...') + 'This may take some time, please be patient ...') modules = [] json_modules = dom['courseMaterial']['elements'] course = CourseraOnDemand(session=session, course_id=dom['id']) @@ -551,7 +552,7 @@ def download_lectures(downloader, if not skip_download: if url.startswith(IN_MEMORY_MARKER): page_content = url[len(IN_MEMORY_MARKER):] - with open(lecfn, 'w') as file_object: + with codecs.open(lecfn, 'w', 'utf-8') as file_object: file_object.write(page_content) elif: if not url.startswith('mailto:'): diff --git a/coursera/define.py b/coursera/define.py index 2c3327b..9db3e85 100644 --- a/coursera/define.py +++ b/coursera/define.py @@ -151,7 +151,7 @@ IN_MEMORY_EXTENSION = 'html' IN_MEMORY_MARKER = '#inmemory#' #: CSS that is usen to prettify instructions -INSTRUCTIONS_CSS = ''' +INSTRUCTIONS_HTML_INJECTION = ''' + + + + '''