mirror of
https://cdm-project.com/Download-Tools/udemy-downloader.git
synced 2025-04-30 02:14:25 +02:00
fix: KID extraction error handling
+ extract_kid method will raise an error if the file does not exist + If KID extraction fails, the lecture will be skipped instead of causing the program to exit
This commit is contained in:
parent
59538b24ce
commit
0719800145
16
main.py
16
main.py
@ -918,11 +918,19 @@ def handle_segments(url, format_id, video_title,
|
||||
print("Return code from the downloader was non-0 (error), skipping!")
|
||||
return
|
||||
|
||||
video_kid = extract_kid(video_filepath_enc)
|
||||
print("KID for video file is: " + video_kid)
|
||||
try:
|
||||
video_kid = extract_kid(video_filepath_enc)
|
||||
print("KID for video file is: " + video_kid)
|
||||
except Exception as e:
|
||||
print(f"Error extracting video kid: {e}")
|
||||
return
|
||||
|
||||
audio_kid = extract_kid(audio_filepath_enc)
|
||||
print("KID for audio file is: " + audio_kid)
|
||||
try:
|
||||
audio_kid = extract_kid(audio_filepath_enc)
|
||||
print("KID for audio file is: " + audio_kid)
|
||||
except Exception as e:
|
||||
print(f"Error extracting audio kid: {e}")
|
||||
return
|
||||
|
||||
try:
|
||||
decrypt(video_kid, video_filepath_enc, video_filepath_dec)
|
||||
|
3
utils.py
3
utils.py
@ -2,6 +2,7 @@ import mp4parse
|
||||
import codecs
|
||||
import widevine_pssh_pb2
|
||||
import base64
|
||||
import os
|
||||
|
||||
def extract_kid(mp4_file):
|
||||
"""
|
||||
@ -18,6 +19,8 @@ def extract_kid(mp4_file):
|
||||
"""
|
||||
|
||||
boxes = mp4parse.F4VParser.parse(filename=mp4_file)
|
||||
if not os.path.exists(mp4_file):
|
||||
raise Exception("File does not exist")
|
||||
for box in boxes:
|
||||
if box.header.box_type == 'moov':
|
||||
pssh_box = next(x for x in box.pssh if x.system_id == "edef8ba979d64acea3c827dcd51d21ed")
|
||||
|
Loading…
x
Reference in New Issue
Block a user