From 1a7314b62f96d154d89c5b61b0bce6d1cb2a9d06 Mon Sep 17 00:00:00 2001 From: Puyodead1 <23562356riley@gmail.com> Date: Thu, 20 May 2021 10:45:28 -0400 Subject: [PATCH 1/2] added articles and external urls to the asset downloads (UNTESTED, only pushing to github to transfer between computers :P) --- main.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 08cfadc..96aa18e 100644 --- a/main.py +++ b/main.py @@ -398,7 +398,6 @@ def process_lecture(lecture, lecture_index, lecture_path, lecture_dir): "> Couldn't find dash url for lecture '%s', skipping...", lecture_title) return - base_url = mpd_url.split("index.mpd")[0] media_info = manifest_parser(mpd_url) handle_irregular_segments(media_info, lecture_title, lecture_working_dir, lecture_path) @@ -428,6 +427,19 @@ def process_lecture(lecture, lecture_index, lecture_path, lecture_dir): f"> Error downloading lecture asset: {e}. Skipping" ) continue + elif asset["asset_type"] == "Article": + assets.append(asset) + asset_path = f"%s\\%s.html" % (lecture_dir, + sanitize(lecture_title)) + with open(asset_path, 'w') as f: + f.write(asset["body"]) + elif asset["asset_type"] == "ExternalLink": + assets.append(asset) + asset_path = f"%s\\%s. External URLs.txt" % (lecture_dir, + lecture_index) + with open(asset_path, 'wa') as f: + f.write(f"%s : %s\n" % + (asset["title"], asset["external_url"])) print("> Found %s assets for lecture '%s'" % (len(assets), lecture_title)) From ec3ba980b1acaf4c3fd96a304523407af25b2c98 Mon Sep 17 00:00:00 2001 From: Puyodead1 <23562356riley@gmail.com> Date: Thu, 20 May 2021 20:49:52 -0400 Subject: [PATCH 2/2] removed useless variable --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 96aa18e..32c75e7 100644 --- a/main.py +++ b/main.py @@ -437,7 +437,7 @@ def process_lecture(lecture, lecture_index, lecture_path, lecture_dir): assets.append(asset) asset_path = f"%s\\%s. External URLs.txt" % (lecture_dir, lecture_index) - with open(asset_path, 'wa') as f: + with open(asset_path, 'a') as f: f.write(f"%s : %s\n" % (asset["title"], asset["external_url"])) print("> Found %s assets for lecture '%s'" %