From 630832e434707ec84db6dcda305f00119022559d Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Sun, 23 Apr 2023 17:38:12 +0100 Subject: [PATCH] Ignore failed parsing of tenc boxes Some services accidentally (? I presume) mix up the `tenc` box's data with that of an `avc1` box or similar. This causes total failure and crashing. However, in these scenarios there's usually a 2nd box further down the stream that is not an error and will parse correctly. So just skip these errors and continue. --- devine/core/utilities.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/devine/core/utilities.py b/devine/core/utilities.py index 9c5a236..541b054 100644 --- a/devine/core/utilities.py +++ b/devine/core/utilities.py @@ -16,6 +16,7 @@ from urllib.parse import urlparse import pproxy import requests +from construct import ConstError from langcodes import Language, closest_match from pymp4.parser import Box from unidecode import unidecode @@ -146,6 +147,12 @@ def get_boxes(data: bytes, box_type: bytes, as_bytes: bool = False) -> Box: except IOError: # TODO: Does this miss any data we may need? break + except ConstError as e: + if box_type == b"tenc": + # ignore this error on tenc boxes as the tenc definition isn't consistent + # some services don't even put valid data and mix it up with avc1... + continue + raise e if as_bytes: box = Box.build(box) yield box