Fix: course directory not being created

This commit is contained in:
Puyodead1 2021-05-19 19:43:29 -04:00
parent e383ca945d
commit c88414189b

11
main.py
View File

@ -459,6 +459,9 @@ def process_lecture(lecture, lecture_index, lecture_path, lecture_dir):
def parse(data):
course_dir = f"%s\\%s" % (download_dir, course_id)
if not os.path.exists(course_dir):
os.mkdir(course_dir)
chapters = []
lectures = []
@ -474,13 +477,13 @@ def parse(data):
# This is caused by there not being a starting chapter
lectures.append(obj)
lecture_index = lectures.index(obj) + 1
lecture_path = f"%s\\%s\\%s. %s.mp4" % (
download_dir, course_id, lecture_index, sanitize(obj["title"]))
lecture_path = f"%s\\%s. %s.mp4" % (course_dir, lecture_index,
sanitize(obj["title"]))
process_lecture(obj, lecture_index, lecture_path, download_dir)
for chapter in chapters:
chapter_dir = f"%s\\%s\\%s. %s" % (download_dir, course_id, chapters.index(chapter) +
1, sanitize(chapter["title"]))
chapter_dir = f"%s\\%s. %s" % (course_dir, chapters.index(chapter) + 1,
sanitize(chapter["title"]))
if not os.path.exists(chapter_dir):
os.mkdir(chapter_dir)