mirror of
https://github.com/coursera-dl/coursera-dl.git
synced 2026-01-23 02:35:37 +00:00
Typo (#671)
This commit is contained in:
parent
e788aed798
commit
5bc5cd9c77
8 changed files with 35 additions and 35 deletions
|
|
@ -52,7 +52,7 @@ from .define import (OPENCOURSE_SUPPLEMENT_URL,
|
|||
IN_MEMORY_MARKER)
|
||||
|
||||
|
||||
from .cookies import prepape_auth_headers
|
||||
from .cookies import prepare_auth_headers
|
||||
|
||||
|
||||
class QuizExamToMarkupConverter(object):
|
||||
|
|
@ -681,7 +681,7 @@ class CourseraOnDemand(object):
|
|||
return reply['contentResponseBody']['session']['id']
|
||||
|
||||
def _auth_headers_with_json(self):
|
||||
headers = prepape_auth_headers(self._session, include_cauth=True)
|
||||
headers = prepare_auth_headers(self._session, include_cauth=True)
|
||||
headers.update({
|
||||
'Content-Type': 'application/json; charset=UTF-8'
|
||||
})
|
||||
|
|
@ -943,7 +943,7 @@ class CourseraOnDemand(object):
|
|||
", ".join(subtitle_set_nonexist), video_id,
|
||||
subtitle_description)
|
||||
if not subtitle_set_download:
|
||||
logging.warning("%s all requested subtitles are unavaliable,"
|
||||
logging.warning("%s all requested subtitles are unavailable,"
|
||||
"with video id: [%s], falling back to 'en' "
|
||||
"%s", subtitle_description.capitalize(),
|
||||
video_id,
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ def parse_args(args=None):
|
|||
help='Choose language to download subtitles and transcripts. (Default: all)'
|
||||
'Use special value "all" to download all available.'
|
||||
'To download subtitles and transcripts of multiple languages,'
|
||||
'use comma(s) (without spaces) to seperate the names of the languages, i.e., "en,zh-CN".'
|
||||
'use comma(s) (without spaces) to separate the names of the languages, i.e., "en,zh-CN".'
|
||||
'To download subtitles and transcripts of alternative language(s) '
|
||||
'if only the current language is not available,'
|
||||
'put an "|<lang>" for each of the alternative languages after '
|
||||
|
|
@ -132,7 +132,7 @@ def parse_args(args=None):
|
|||
dest='download_notebooks',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='download Python Jupyther Notebooks. (Default: False)')
|
||||
help='download Python Jupyter Notebooks. (Default: False)')
|
||||
|
||||
group_material.add_argument('--about', # FIXME: should be --about-course
|
||||
dest='about',
|
||||
|
|
|
|||
|
|
@ -69,15 +69,15 @@ class AuthenticationFailed(BaseException):
|
|||
"""
|
||||
|
||||
|
||||
def prepape_auth_headers(session, include_cauth=False):
|
||||
def prepare_auth_headers(session, include_cauth=False):
|
||||
"""
|
||||
This function prepapes headers with CSRF/CAUTH tokens that can
|
||||
This function prepares headers with CSRF/CAUTH tokens that can
|
||||
be used in POST requests such as login/get_quiz.
|
||||
|
||||
@param session: Requests session.
|
||||
@type session: requests.Session
|
||||
|
||||
@param include_cauth: Flag that indicates whethe CAUTH cookies should be
|
||||
@param include_cauth: Flag that indicates whether CAUTH cookies should be
|
||||
included as well.
|
||||
@type include_cauth: bool
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ def login(session, username, password, class_name=None):
|
|||
logging.error(e)
|
||||
raise ClassNotFound(class_name)
|
||||
|
||||
headers = prepape_auth_headers(session, include_cauth=False)
|
||||
headers = prepare_auth_headers(session, include_cauth=False)
|
||||
|
||||
data = {
|
||||
'email': username,
|
||||
|
|
@ -355,7 +355,7 @@ def get_cookies_for_class(session, class_name,
|
|||
Get the cookies for the given class.
|
||||
|
||||
We do not validate the cookies if they are loaded from a cookies file
|
||||
because this is intented for debugging purposes or if the coursera
|
||||
because this is intended for debugging purposes or if the coursera
|
||||
authentication process has changed.
|
||||
"""
|
||||
if cookies_file:
|
||||
|
|
|
|||
|
|
@ -115,12 +115,12 @@ def download_on_demand_class(args, class_name):
|
|||
Download all requested resources from the on-demand class given in class_name.
|
||||
|
||||
@return: Tuple of (bool, bool), where the first bool indicates whether
|
||||
errors occured while parsing syllabus, the second bool indicaters
|
||||
errors occurred while parsing syllabus, the second bool indicates
|
||||
whether the course appears to be completed.
|
||||
@rtype: (bool, bool)
|
||||
"""
|
||||
|
||||
error_occured = False
|
||||
error_occurred = False
|
||||
session = get_session()
|
||||
extractor = CourseraExtractor(session, args.username, args.password)
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ def download_on_demand_class(args, class_name):
|
|||
with open(cached_syllabus_filename) as syllabus_file:
|
||||
modules = json.load(syllabus_file)
|
||||
else:
|
||||
error_occured, modules = extractor.get_modules(
|
||||
error_occurred, modules = extractor.get_modules(
|
||||
class_name,
|
||||
args.reverse,
|
||||
args.unrestricted_filenames,
|
||||
|
|
@ -145,7 +145,7 @@ def download_on_demand_class(args, class_name):
|
|||
json.dump(modules, file_object, indent=4)
|
||||
|
||||
if args.only_syllabus:
|
||||
return error_occured, False
|
||||
return error_occurred, False
|
||||
|
||||
downloader = get_downloader(session, class_name, args)
|
||||
downloader_wrapper = ParallelDownloader(downloader, args.jobs) \
|
||||
|
|
@ -177,7 +177,7 @@ def download_on_demand_class(args, class_name):
|
|||
if course_downloader.failed_urls:
|
||||
print_failed_urls(course_downloader.failed_urls)
|
||||
|
||||
return error_occured, completed
|
||||
return error_occurred, completed
|
||||
|
||||
|
||||
def print_skipped_urls(skipped_urls):
|
||||
|
|
@ -205,7 +205,7 @@ def download_class(args, class_name):
|
|||
Try to download on-demand class.
|
||||
|
||||
@return: Tuple of (bool, bool), where the first bool indicates whether
|
||||
errors occured while parsing syllabus, the second bool indicaters
|
||||
errors occurred while parsing syllabus, the second bool indicaters
|
||||
whether the course appears to be completed.
|
||||
@rtype: (bool, bool)
|
||||
"""
|
||||
|
|
@ -235,10 +235,10 @@ def main():
|
|||
try:
|
||||
logging.info('Downloading class: %s (%d / %d)',
|
||||
class_name, class_index + 1, len(args.class_names))
|
||||
error_occured, completed = download_class(args, class_name)
|
||||
error_occurred, completed = download_class(args, class_name)
|
||||
if completed:
|
||||
completed_classes.append(class_name)
|
||||
if error_occured:
|
||||
if error_occurred:
|
||||
classes_with_errors.append(class_name)
|
||||
except requests.exceptions.HTTPError as e:
|
||||
logging.error('HTTPError %s', e)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ AUTH_URL = 'https://accounts.coursera.org/api/v1/login'
|
|||
AUTH_URL_V3 = 'https://api.coursera.org/api/login/v3'
|
||||
CLASS_URL = 'https://class.coursera.org/{class_name}'
|
||||
|
||||
# The following link is left just for illustative purposes:
|
||||
# The following link is left just for illustrative purposes:
|
||||
# https://api.coursera.org/api/courses.v1?fields=display%2CpartnerIds%2CphotoUrl%2CstartDate%2Cpartners.v1(homeLink%2Cname)&includes=partnerIds&q=watchlist&start=0
|
||||
# Reply is as follows:
|
||||
# {
|
||||
|
|
@ -36,7 +36,7 @@ CLASS_URL = 'https://class.coursera.org/{class_name}'
|
|||
# }
|
||||
OPENCOURSE_LIST_COURSES = 'https://api.coursera.org/api/courses.v1?q=watchlist&start={start}'
|
||||
|
||||
# The following link is left just for illustative purposes:
|
||||
# The following link is left just for illustrative purposes:
|
||||
# https://api.coursera.org/api/memberships.v1?fields=courseId,enrolledTimestamp,grade,id,lastAccessedTimestamp,onDemandSessionMembershipIds,onDemandSessionMemberships,role,v1SessionId,vc,vcMembershipId,courses.v1(courseStatus,display,partnerIds,photoUrl,specializations,startDate,v1Details,v2Details),partners.v1(homeLink,name),v1Details.v1(sessionIds),v1Sessions.v1(active,certificatesReleased,dbEndDate,durationString,hasSigTrack,startDay,startMonth,startYear),v2Details.v1(onDemandSessions,plannedLaunchDate,sessionsEnabledAt),specializations.v1(logo,name,partnerIds,shortName)&includes=courseId,onDemandSessionMemberships,vcMembershipId,courses.v1(partnerIds,specializations,v1Details,v2Details),v1Details.v1(sessionIds),v2Details.v1(onDemandSessions),specializations.v1(partnerIds)&q=me&showHidden=true&filter=current,preEnrolled
|
||||
# Sample reply:
|
||||
# {
|
||||
|
|
|
|||
|
|
@ -51,11 +51,11 @@ class CourseraExtractor(PlatformExtractor):
|
|||
download_notebooks=False):
|
||||
|
||||
page = self._get_on_demand_syllabus(class_name)
|
||||
error_occured, modules = self._parse_on_demand_syllabus(
|
||||
error_occurred, modules = self._parse_on_demand_syllabus(
|
||||
page, reverse, unrestricted_filenames,
|
||||
subtitle_language, video_resolution,
|
||||
download_quizzes, mathjax_cdn_url, download_notebooks)
|
||||
return error_occured, modules
|
||||
return error_occurred, modules
|
||||
|
||||
def _get_on_demand_syllabus(self, class_name):
|
||||
"""
|
||||
|
|
@ -107,7 +107,7 @@ class CourseraExtractor(PlatformExtractor):
|
|||
with open('%s-course-material-items.json' % course_name, 'w') as file_object:
|
||||
json.dump(ondemand_material_items._items, file_object, indent=4)
|
||||
|
||||
error_occured = False
|
||||
error_occurred = False
|
||||
|
||||
for module in json_modules:
|
||||
module_slug = module['slug']
|
||||
|
|
@ -135,7 +135,7 @@ class CourseraExtractor(PlatformExtractor):
|
|||
logging.info('Processing lecture %s (%s)',
|
||||
lecture_slug, typename)
|
||||
# Empty dictionary means there were no data
|
||||
# None means an error occured
|
||||
# None means an error occurred
|
||||
links = {}
|
||||
|
||||
if typename == 'lecture':
|
||||
|
|
@ -180,7 +180,7 @@ class CourseraExtractor(PlatformExtractor):
|
|||
continue
|
||||
|
||||
if links is None:
|
||||
error_occured = True
|
||||
error_occurred = True
|
||||
elif links:
|
||||
lectures.append((lecture_slug, links))
|
||||
|
||||
|
|
@ -206,7 +206,7 @@ class CourseraExtractor(PlatformExtractor):
|
|||
|
||||
links = course.extract_links_from_reference(json_reference['shortId'])
|
||||
if links is None:
|
||||
error_occured = True
|
||||
error_occurred = True
|
||||
elif links:
|
||||
reference.append(('', links))
|
||||
|
||||
|
|
@ -216,4 +216,4 @@ class CourseraExtractor(PlatformExtractor):
|
|||
if references:
|
||||
modules.append(("Resources", references))
|
||||
|
||||
return error_occured, modules
|
||||
return error_occurred, modules
|
||||
|
|
|
|||
12
coursera/test/test_api.py
vendored
12
coursera/test/test_api.py
vendored
|
|
@ -149,7 +149,7 @@ def test_ondemand_programming_supplement_no_instructions(get_page, course):
|
|||
('peer-assignment-no-instructions.json', ''),
|
||||
]
|
||||
)
|
||||
def test_ondemand_from_peer_assgnment_instructions(
|
||||
def test_ondemand_from_peer_assignment_instructions(
|
||||
get_page, course, input_filename, expected_output):
|
||||
instructions = slurp_fixture('json/%s' % input_filename)
|
||||
get_page.return_value = json.loads(instructions)
|
||||
|
|
@ -176,7 +176,7 @@ def test_ondemand_programming_supplement_empty_instructions(get_page, course):
|
|||
output = course.extract_links_from_programming('0')
|
||||
|
||||
# Make sure that SOME html content has been extracted, but remove
|
||||
# it immeditely because it's a hassle to properly prepare test input
|
||||
# it immediately because it's a hassle to properly prepare test input
|
||||
# for it. FIXME later.
|
||||
assert 'html' in output
|
||||
del output['html']
|
||||
|
|
@ -193,7 +193,7 @@ def test_ondemand_programming_immediate_instructions_empty_instructions(
|
|||
output = course.extract_links_from_programming_immediate_instructions('0')
|
||||
|
||||
# Make sure that SOME html content has been extracted, but remove
|
||||
# it immeditely because it's a hassle to properly prepare test input
|
||||
# it immediately because it's a hassle to properly prepare test input
|
||||
# for it. FIXME later.
|
||||
assert 'html' in output
|
||||
del output['html']
|
||||
|
|
@ -214,7 +214,7 @@ def test_ondemand_programming_supplement_one_asset(get_page, course):
|
|||
output = course.extract_links_from_programming('0')
|
||||
|
||||
# Make sure that SOME html content has been extracted, but remove
|
||||
# it immeditely because it's a hassle to properly prepare test input
|
||||
# it immediately because it's a hassle to properly prepare test input
|
||||
# for it. FIXME later.
|
||||
assert 'html' in output
|
||||
del output['html']
|
||||
|
|
@ -249,7 +249,7 @@ def test_ondemand_programming_immediate_instructions_one_asset(get_page, course)
|
|||
output = course.extract_links_from_programming_immediate_instructions('0')
|
||||
|
||||
# Make sure that SOME html content has been extracted, but remove
|
||||
# it immeditely because it's a hassle to properly prepare test input
|
||||
# it immediately because it's a hassle to properly prepare test input
|
||||
# for it. FIXME later.
|
||||
assert 'html' in output
|
||||
del output['html']
|
||||
|
|
@ -269,7 +269,7 @@ def test_ondemand_programming_supplement_three_assets(get_page, course):
|
|||
output = json.loads(json.dumps(output))
|
||||
|
||||
# Make sure that SOME html content has been extracted, but remove
|
||||
# it immeditely because it's a hassle to properly prepare test input
|
||||
# it immediately because it's a hassle to properly prepare test input
|
||||
# for it. FIXME later.
|
||||
assert 'html' in output
|
||||
del output['html']
|
||||
|
|
|
|||
4
coursera/test/test_parsing.py
vendored
4
coursera/test/test_parsing.py
vendored
|
|
@ -65,7 +65,7 @@ def test_that_we_parse_and_write_json_correctly(get_page, json_path):
|
|||
def get_old_style_video(monkeypatch):
|
||||
pytest.skip()
|
||||
"""
|
||||
Mock some methods that would, otherwise, create repeateadly many web
|
||||
Mock some methods that would, otherwise, create repeatedly many web
|
||||
requests.
|
||||
|
||||
More specifically, we mock:
|
||||
|
|
@ -139,7 +139,7 @@ def test_get_on_demand_supplement_url_accumulates_assets(mocked):
|
|||
output = course.extract_links_from_supplement('element_id')
|
||||
|
||||
# Make sure that SOME html content has been extracted, but remove
|
||||
# it immeditely because it's a hassle to properly prepare test input
|
||||
# it immediately because it's a hassle to properly prepare test input
|
||||
# for it. FIXME later.
|
||||
assert 'html' in output
|
||||
del output['html']
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue