Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for mathesis platform #548

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions edx_dl/edx_dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@
'bits':{
'url':'http://any-learn.bits-pilani.ac.in',
'courseware-selector': ('nav', {'aria-label': 'Course Navigation'}),
},
'mathesis':{
'url': 'https://mathesis.cup.gr',
'courseware-selector': ('nav', {'aria-label': 'Course Navigation'}),
}
}
BASE_URL = OPENEDX_SITES['edx']['url']
Expand Down Expand Up @@ -409,7 +413,6 @@ def parse_args():

return args


def edx_get_headers():
"""
Build the Open edX headers to create future requests.
Expand Down Expand Up @@ -828,11 +831,20 @@ def download(args, selections, all_units, headers):
# sections/subsections to add correct prefixes and show nicer information.

for selected_course, selected_sections in selections.items():
coursename = directory_name(selected_course.name)
# If the platform is mathesis don't convert the directory name to ascii
if args.platform == 'mathesis':
coursename = directory_name(selected_course.name, dont_use_ascii=True)
else:
coursename = directory_name(selected_course.name)
for selected_section in selected_sections:
section_dirname = "%02d-%s" % (selected_section.position,
selected_section.name)
target_dir = os.path.join(args.output_dir, coursename,
# If our platform is mathesis, then the filename contains greek chars, so clean the bare minimum
if args.platform == 'mathesis':
target_dir = os.path.join(args.output_dir, coursename,
clean_filename(section_dirname, minimal_change=True))
else:
target_dir = os.path.join(args.output_dir, coursename,
clean_filename(section_dirname))
mkdir_p(target_dir)
counter = 0
Expand Down
4 changes: 3 additions & 1 deletion edx_dl/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,9 @@ def get_page_extractor(url):
"""
if (
url.startswith('https://courses.edx.org') or
url.startswith('https://mitxpro.mit.edu')
url.startswith('https://mitxpro.mit.edu') or
url.startswith('https://mathesis.cup.gr')

):
return NewEdXPageExtractor()
elif (
Expand Down
4 changes: 2 additions & 2 deletions edx_dl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ def execute_command(cmd, args):
raise e


def directory_name(initial_name):
def directory_name(initial_name, dont_use_ascii=False):
"""
Transform the name of a directory into an ascii version
"""
result = clean_filename(initial_name)
result = clean_filename(initial_name, minimal_change=dont_use_ascii)
return result if result != "" else "course_folder"


Expand Down