mirror of
				https://github.com/devine-dl/pywidevine.git
				synced 2025-11-04 03:44:50 +00:00 
			
		
		
		
	serve: Improve error handling on /get_license_challenge
This commit is contained in:
		
							parent
							
								
									f2ed83205b
								
							
						
					
					
						commit
						11a2358002
					
				@ -20,7 +20,8 @@ except ImportError:
 | 
			
		||||
from pywidevine import __version__
 | 
			
		||||
from pywidevine.cdm import Cdm
 | 
			
		||||
from pywidevine.device import Device
 | 
			
		||||
from pywidevine.exceptions import TooManySessions, InvalidSession, SignatureMismatch
 | 
			
		||||
from pywidevine.exceptions import TooManySessions, InvalidSession, SignatureMismatch, InvalidInitData, \
 | 
			
		||||
    InvalidLicenseType
 | 
			
		||||
from pywidevine.license_protocol_pb2 import License
 | 
			
		||||
 | 
			
		||||
routes = web.RouteTableDef()
 | 
			
		||||
@ -225,6 +226,16 @@ async def get_license_challenge(request: web.Request) -> web.Response:
 | 
			
		||||
            "status": 400,
 | 
			
		||||
            "message": f"Invalid Session ID '{session_id.hex()}', it may have expired."
 | 
			
		||||
        }, status=400)
 | 
			
		||||
    except InvalidInitData as e:
 | 
			
		||||
        return web.json_response({
 | 
			
		||||
            "status": 400,
 | 
			
		||||
            "message": f"Invalid Init Data, {e}"
 | 
			
		||||
        }, status=400)
 | 
			
		||||
    except InvalidLicenseType:
 | 
			
		||||
        return web.json_response({
 | 
			
		||||
            "status": 400,
 | 
			
		||||
            "message": f"Invalid License Type '{license_type}'"
 | 
			
		||||
        }, status=400)
 | 
			
		||||
 | 
			
		||||
    return web.json_response({
 | 
			
		||||
        "status": 200,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user