Chillee / coursera-dl-all

MIT License
190 stars 54 forks source link

Further file and directory name sanitization needed #16

Closed kdam closed 7 years ago

kdam commented 8 years ago

Env: Ubuntu, Python 2.7.10

venture-001 has sections with forward slashes in their names, such as "Grading / Notation", "Week 1 / Semaine 1", "Final Project / Project final", and so on.

The script seems to work okay for most of the sections, but fails on "Quizzes / Quizz". Here's the trace:

Downloading Quizzes...
Downloading Quizzes / Quizz
Traceback (most recent call last):
  File "dl_all.py", line 335, in <module>
    quiz_info = get_quiz_info(session, i[0], i[1])
  File "dl_all.py", line 175, in get_quiz_info
    render(session, os.getcwd()+'/'+category_name)
  File "dl_all.py", line 44, in render
    f = open(path+'.html', 'wb')
IOError: [Errno 2] No such file or directory: u'/home/username/Documents/coursera-downloads/venture-001/Quizzes / Quizz.html'

Should be an easy fix to replace the / with a dash or something.

Ramakrishna-RK commented 8 years ago

I am getting the same error.

Env: Windows, Python 2.7.10

How do I solve this issue?

gexahedron commented 8 years ago

You can just rewrite the beginning of get_quiz_info function like this:


def get_quiz_info(session, url, category_name):
    session.get(url)
    wait_for_load(session)
    safe_category_name = category_name.replace('/', '_')
    render(session, os.getcwd()+'/'+safe_category_name)
Chillee commented 7 years ago

This project has been deprecated for a while. Just doing some cleaning.