Fix from https://github.com/zorbaTheRainy for images throwing segfaults on has_audio
This commit is contained in:
11
subgen.py
11
subgen.py
@@ -223,6 +223,15 @@ def appendLine(result):
|
||||
# Append the new segment to the result's segments
|
||||
result.segments.append(newSegment)
|
||||
|
||||
def has_image_extension(file_path):
|
||||
valid_extensions = ['.rgb', '.gif', '.pbm', '.pgm', '.ppm', '.tiff', '.rast', '.xbm', '.jpg', '.jpeg', '.bmp', '.png', '.webp', '.exr', '.bif'] # taken from the extensions detected by the imghdr module & added Emby's '.bif' files
|
||||
|
||||
if os.path.exists(file_path):
|
||||
file_extension = os.path.splitext(file_path)[1].lower()
|
||||
return file_extension in valid_extensions
|
||||
else:
|
||||
return True # return a value that causes the file to be skipped.
|
||||
|
||||
@app.get("/plex")
|
||||
@app.get("/webhook")
|
||||
@app.get("/jellyfin")
|
||||
@@ -772,6 +781,8 @@ def get_jellyfin_admin(users):
|
||||
def has_audio(file_path):
|
||||
try:
|
||||
with av.open(file_path) as container:
|
||||
if has_image_extension(file_path):
|
||||
return False
|
||||
return any(stream.type == 'audio' for stream in container.streams)
|
||||
except (av.AVError, UnicodeDecodeError):
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user