mirror of
https://git.gay/ready-dl/pyplayready.git
synced 2025-10-27 00:34:50 +00:00
+ Updated RemoteCdm/Serve to support RevLists + Added Storage class for RevList persistence + Added support for ExtData objects in BCerts + signature verification + Added an Xml Builder class (instead of xmltodict) + Added a SOAP Builder/Parser class (instead of xmltodict) + Refactored WRMHeader class to use ET (instead of xmltodict) + Upgraded ServerException detection + Removed dependencies: xmltodict, lxml + Added Util class + Minor Crypto/ElGamal class changes
36 lines
906 B
Python
36 lines
906 B
Python
import os
|
|
from pathlib import Path
|
|
from typing import Optional
|
|
|
|
from platformdirs import user_data_dir
|
|
|
|
|
|
class Storage:
|
|
|
|
@staticmethod
|
|
def _get_initialized_path() -> Path:
|
|
storage_path = Path(user_data_dir("pyplayready", "DevLARLEY"))
|
|
storage_path.mkdir(parents=True, exist_ok=True)
|
|
return storage_path
|
|
|
|
@staticmethod
|
|
def write_file(file_name: str, data: bytes) -> bool:
|
|
storage_path = Storage._get_initialized_path()
|
|
storage_file = storage_path / file_name
|
|
|
|
new_file = not storage_file.exists()
|
|
|
|
storage_file.write_bytes(data)
|
|
|
|
return new_file
|
|
|
|
@staticmethod
|
|
def read_file(file_name: str) -> Optional[bytes]:
|
|
storage_path = Storage._get_initialized_path()
|
|
storage_file = storage_path / file_name
|
|
|
|
if not storage_file.exists():
|
|
return None
|
|
|
|
return storage_file.read_bytes()
|