Skip to content

Commit

Permalink
Merge pull request #30 from TheRusskiy/master
Browse files Browse the repository at this point in the history
Fix for issues #29 and #17, now invalid chars in directory name are being omitted
  • Loading branch information
shk3 committed Jun 21, 2013
2 parents fd50c35 + 2c431bd commit 2755642
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion edx-dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ def get_page_contents(url, headers):
result = urlopen(Request(url, None, headers))
return result.read()

def directory_name(initial_name):
import string
allowed_chars = string.digits+string.ascii_letters+" _."
result_name = ""
for ch in initial_name:
if allowed_chars.find(ch) != -1:
result_name+=ch
return result_name if result_name != "" else "course_folder"

if __name__ == '__main__':
if len(sys.argv) != 3:
Expand Down Expand Up @@ -190,7 +198,7 @@ def get_page_contents(url, headers):
c = 0
for v in video_link:
c += 1
cmd = 'youtube-dl -o "Downloaded/' + selected_course[0] + '/' + \
cmd = 'youtube-dl -o "Downloaded/' + directory_name(selected_course[0]) + '/' + \
str(c).zfill(2) + '-%(title)s.%(ext)s" -f ' + str(video_fmt)
if subtitles:
cmd += ' --write-srt'
Expand Down

0 comments on commit 2755642

Please sign in to comment.