diff --git a/pyproject.toml b/pyproject.toml index 389d50e..e9a8dae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,3 +43,7 @@ serve = ["aiohttp", "PyYAML"] [tool.poetry.scripts] pywidevine = "pywidevine.main:main" + +[tool.isort] +line_length = 118 +extend_skip_glob = ["*_pb2.py", "*_pb2.pyi"] diff --git a/pywidevine/__init__.py b/pywidevine/__init__.py index 760fa4d..6ea25ac 100644 --- a/pywidevine/__init__.py +++ b/pywidevine/__init__.py @@ -5,5 +5,4 @@ from .pssh import * from .remotecdm import * from .session import * - __version__ = "1.5.3" diff --git a/pywidevine/cdm.py b/pywidevine/cdm.py index 70daa32..37dc99e 100644 --- a/pywidevine/cdm.py +++ b/pywidevine/cdm.py @@ -7,11 +7,11 @@ import subprocess import sys import time from pathlib import Path -from typing import Union, Optional +from typing import Optional, Union from uuid import UUID from Crypto.Cipher import AES, PKCS1_OAEP -from Crypto.Hash import SHA1, HMAC, SHA256, CMAC +from Crypto.Hash import CMAC, HMAC, SHA1, SHA256 from Crypto.PublicKey import RSA from Crypto.Random import get_random_bytes from Crypto.Signature import pss @@ -19,11 +19,12 @@ from Crypto.Util import Padding from google.protobuf.message import DecodeError from pywidevine.device import Device -from pywidevine.exceptions import TooManySessions, InvalidSession, InvalidLicenseType, SignatureMismatch, \ - InvalidInitData, InvalidLicenseMessage, NoKeysLoaded, InvalidContext +from pywidevine.exceptions import (InvalidContext, InvalidInitData, InvalidLicenseMessage, InvalidLicenseType, + InvalidSession, NoKeysLoaded, SignatureMismatch, TooManySessions) from pywidevine.key import Key -from pywidevine.license_protocol_pb2 import DrmCertificate, SignedMessage, SignedDrmCertificate, LicenseType, \ - LicenseRequest, ProtocolVersion, ClientIdentification, EncryptedClientIdentification, License +from pywidevine.license_protocol_pb2 import (ClientIdentification, DrmCertificate, EncryptedClientIdentification, + License, LicenseRequest, LicenseType, ProtocolVersion, + SignedDrmCertificate, SignedMessage) from pywidevine.pssh import PSSH from pywidevine.session import Session from pywidevine.utils import get_binary_path diff --git a/pywidevine/device.py b/pywidevine/device.py index e238514..09ce83f 100644 --- a/pywidevine/device.py +++ b/pywidevine/device.py @@ -14,7 +14,7 @@ from construct import Padded, Padding, Struct, this from Crypto.PublicKey import RSA from google.protobuf.message import DecodeError -from pywidevine.license_protocol_pb2 import ClientIdentification, FileHashes, SignedDrmCertificate, DrmCertificate +from pywidevine.license_protocol_pb2 import ClientIdentification, DrmCertificate, FileHashes, SignedDrmCertificate class _Types(Enum): diff --git a/pywidevine/main.py b/pywidevine/main.py index a0c4117..f6a52c4 100644 --- a/pywidevine/main.py +++ b/pywidevine/main.py @@ -6,15 +6,15 @@ from zlib import crc32 import click import requests -from construct import ConstructError -from unidecode import unidecode, UnidecodeError import yaml +from construct import ConstructError from google.protobuf.json_format import MessageToDict +from unidecode import UnidecodeError, unidecode from pywidevine import __version__ from pywidevine.cdm import Cdm from pywidevine.device import Device -from pywidevine.license_protocol_pb2 import LicenseType, FileHashes +from pywidevine.license_protocol_pb2 import FileHashes, LicenseType from pywidevine.pssh import PSSH @@ -397,8 +397,8 @@ def serve_(config: Path, host: str, port: int): Host as 127.0.0.1 may block remote access even if port-forwarded. Instead, use 0.0.0.0 and ensure the TCP port you choose is forwarded. """ - from pywidevine import serve - import yaml + from pywidevine import serve # isort:skip + import yaml # isort:skip config = yaml.safe_load(config.read_text(encoding="utf8")) serve.run(config, host, port) diff --git a/pywidevine/pssh.py b/pywidevine/pssh.py index 77708e8..7f8a977 100644 --- a/pywidevine/pssh.py +++ b/pywidevine/pssh.py @@ -4,7 +4,7 @@ import base64 import binascii import string from io import BytesIO -from typing import Union, Optional +from typing import Optional, Union from uuid import UUID import construct diff --git a/pywidevine/remotecdm.py b/pywidevine/remotecdm.py index 96cf56b..6c9254a 100644 --- a/pywidevine/remotecdm.py +++ b/pywidevine/remotecdm.py @@ -3,21 +3,21 @@ from __future__ import annotations import base64 import binascii import re -from typing import Union, Optional +from typing import Optional, Union import requests from Crypto.Hash import SHA1 from Crypto.PublicKey import RSA from Crypto.Signature import pss from google.protobuf.message import DecodeError + from pywidevine.cdm import Cdm from pywidevine.device import Device -from pywidevine.exceptions import InvalidInitData, InvalidLicenseType, InvalidLicenseMessage, DeviceMismatch, \ - SignatureMismatch +from pywidevine.exceptions import (DeviceMismatch, InvalidInitData, InvalidLicenseMessage, InvalidLicenseType, + SignatureMismatch) from pywidevine.key import Key - -from pywidevine.license_protocol_pb2 import LicenseType, SignedMessage, License, ClientIdentification, \ - SignedDrmCertificate +from pywidevine.license_protocol_pb2 import (ClientIdentification, License, LicenseType, SignedDrmCertificate, + SignedMessage) from pywidevine.pssh import PSSH diff --git a/pywidevine/serve.py b/pywidevine/serve.py index 91e2a44..b09f9e7 100644 --- a/pywidevine/serve.py +++ b/pywidevine/serve.py @@ -20,8 +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, InvalidInitData, \ - InvalidLicenseType, InvalidLicenseMessage, InvalidContext +from pywidevine.exceptions import (InvalidContext, InvalidInitData, InvalidLicenseMessage, InvalidLicenseType, + InvalidSession, SignatureMismatch, TooManySessions) routes = web.RouteTableDef()