From 838df7c22be843b6430360528a7568b4f44efde1 Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Sun, 21 Aug 2022 22:37:28 +0100 Subject: [PATCH] Set a unique number to each Session of each Cdm --- pywidevine/cdm.py | 2 +- pywidevine/session.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pywidevine/cdm.py b/pywidevine/cdm.py index 08dcfc0..eab5231 100644 --- a/pywidevine/cdm.py +++ b/pywidevine/cdm.py @@ -131,7 +131,7 @@ class Cdm: if len(self.__sessions) > self.MAX_NUM_OF_SESSIONS: raise TooManySessions(f"Too many Sessions open ({self.MAX_NUM_OF_SESSIONS}).") - session = Session() + session = Session(len(self.__sessions) + 1) self.__sessions[session.id] = session return session.id diff --git a/pywidevine/session.py b/pywidevine/session.py index cc123df..2bfcdaf 100644 --- a/pywidevine/session.py +++ b/pywidevine/session.py @@ -7,7 +7,8 @@ from pywidevine.license_protocol_pb2 import SignedMessage class Session: - def __init__(self): + def __init__(self, number: int): + self.number = number self.id = get_random_bytes(16) self.service_certificate: Optional[SignedMessage] = None self.context: dict[bytes, tuple[bytes, bytes]] = {}