diff --git a/main_windows.py b/main_windows.py index 49ec030..c5585df 100644 --- a/main_windows.py +++ b/main_windows.py @@ -151,7 +151,7 @@ folder_name = folder_name.replace('/', '\\') folder_name = re.sub(r'[“”]', '_', folder_name) - print('folder name would be:',folder_name) + print('folder name would be:', folder_name) # Rename old folder if os.path.exists(f"{DOWNLOAD_FOLDER}/{course['name']}"): @@ -163,7 +163,6 @@ os.makedirs(f"{DOWNLOAD_FOLDER}/{folder_name}", exist_ok=True) os.makedirs(f"{CACHE_FOLDER}/{folder_name}", exist_ok=True) - name_prefix += folder_name.rstrip() + "/" name_prefix = option.windows_filesame_sanitizer(name_prefix) @@ -175,7 +174,7 @@ if args.video: for index, lesson in enumerate(lesson_data['data']['activities']): - if not lesson['type'] in [2, 14, 15, 17]: + if not lesson['type'] in [2, 3, 14, 15, 17]: continue lesson['classroom_id'] = course['classroom_id'] @@ -185,7 +184,7 @@ if lesson['type'] == 2: print('Script type detected!') download_lesson_video_type2(lesson, name_prefix + str(length - index)) - elif lesson['type'] == 14: + elif lesson['type'] in [3, 14]: print('Normal type detected!') download_lesson_video(lesson, name_prefix + str(length - index)) elif lesson['type'] == 15: @@ -201,14 +200,17 @@ print('sbykt may not prepare cold data in one run, rescanning for missing ones') for index, lesson in enumerate(lesson_data['data']['activities']): - if not lesson['type'] in [14, 15, 17]: + if not lesson['type'] in [2, 3, 14, 15, 17]: continue lesson['classroom_id'] = course['classroom_id'] # Lesson try: - if lesson['type'] == 14: + if lesson['type'] == 2: + print('Script type detected!') + download_lesson_video_type2(lesson, name_prefix + str(length - index)) + elif lesson['type'] in [3, 14]: print('Normal type detected!') download_lesson_video(lesson, name_prefix + str(length - index)) elif lesson['type'] == 15: @@ -359,7 +361,8 @@ f"https://{YKT_HOST}/api/open/audiovideo/playurl?video_id={mooc_orphan_media_id}&provider=cc&is_single=0&format=json" ).json() - quality_keys = list(map(lambda x: (int(x[7:]), x), mooc_orphan_media_data['data']['playurl']['sources'].keys())) + quality_keys = list( + map(lambda x: (int(x[7:]), x), mooc_orphan_media_data['data']['playurl']['sources'].keys())) quality_keys.sort(key=lambda x: x[0], reverse=True) download_url_list = mooc_orphan_media_data['data']['playurl']['sources'][quality_keys[0][1]] # print(download_url_list) @@ -419,7 +422,8 @@ f"https://{YKT_HOST}/api/open/audiovideo/playurl?video_id={mooc_media_id}&provider=cc&is_single=0&format=json" ).json() - quality_keys = list(map(lambda x: (int(x[7:]), x), mooc_media_data['data']['playurl']['sources'].keys())) + quality_keys = list( + map(lambda x: (int(x[7:]), x), mooc_media_data['data']['playurl']['sources'].keys())) quality_keys.sort(key=lambda x: x[0], reverse=True) download_url_list = mooc_media_data['data']['playurl']['sources'][quality_keys[0][1]] # print(download_url_list) @@ -522,13 +526,13 @@ def download_lesson_video_type2(lesson: dict, name_prefix: str = ""): # "id": 6036907, "courseware_id": "1055476" # https://pro.yuketang.cn/v2/api/web/cards/detlist/1055476?classroom_id=3058049 - + lesson_data = rainclassroom_sess.get( f"https://{YKT_HOST}/v2/api/web/cards/detlist/{lesson['courseware_id']}?classroom_id={lesson['classroom_id']}").json() name_prefix += "-" + lesson_data['data']['Title'].strip() - + name_prefix = option.windows_filesame_sanitizer(name_prefix) - + for slide in lesson_data['data']['Slides']: slide_id = slide['PageIndex'] for shape in slide['Shapes']: @@ -537,10 +541,10 @@ quality_keys = list(map(lambda x: (int(x[7:]), x), shape['playurls'].keys())) quality_keys.sort(key=lambda x: x[0], reverse=True) download_url_list = shape['playurls'][quality_keys[0][1]] - + name_prefix_shape = name_prefix + f" - {slide_id} - {file_title}" name_prefix_shape = option.windows_filesame_sanitizer(name_prefix_shape) - + if idm_flag: name_prefix_shape = re.sub(r'[“”]', '_', name_prefix_shape) @@ -614,6 +618,8 @@ print(f"Failed to download PPT {name_prefix} - {ppt['title']}", file=sys.stderr) + + # --- --- --- Section Main --- --- --- # diff --git a/video_processing.py b/video_processing.py index 18c5157..8985d38 100644 --- a/video_processing.py +++ b/video_processing.py @@ -257,7 +257,7 @@ # If the first command fails, try the fallback if result.returncode != 0: - print(f"First attempt failed. Attempting fallback with software encoding.") + print(f"First attempt failed. Attempting fallback with software decoding.") # Fallback video concatenation command using cuvid acceleration video_concatenating_command_fallback = (