mirror of https://github.com/devine-dl/devine.git
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.
This commit is contained in:
parent
86322159b6
commit
630832e434
|
@ -16,6 +16,7 @@ from urllib.parse import urlparse
|
||||||
|
|
||||||
import pproxy
|
import pproxy
|
||||||
import requests
|
import requests
|
||||||
|
from construct import ConstError
|
||||||
from langcodes import Language, closest_match
|
from langcodes import Language, closest_match
|
||||||
from pymp4.parser import Box
|
from pymp4.parser import Box
|
||||||
from unidecode import unidecode
|
from unidecode import unidecode
|
||||||
|
@ -146,6 +147,12 @@ def get_boxes(data: bytes, box_type: bytes, as_bytes: bool = False) -> Box:
|
||||||
except IOError:
|
except IOError:
|
||||||
# TODO: Does this miss any data we may need?
|
# TODO: Does this miss any data we may need?
|
||||||
break
|
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:
|
if as_bytes:
|
||||||
box = Box.build(box)
|
box = Box.build(box)
|
||||||
yield box
|
yield box
|
||||||
|
|
Loading…
Reference in New Issue