mirror of
				https://github.com/devine-dl/devine.git
				synced 2025-11-03 19:34:49 +00:00 
			
		
		
		
	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 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
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user