From 3571c5eb3c634265579afc1df831a3b8f141b9cf Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 23 Oct 2025 18:11:30 +0000 Subject: [PATCH] style: apply ruff formatting fixes --- .gitignore | 1 + unshackle/core/binaries.py | 5 +---- unshackle/core/constants.py | 8 +++++++- unshackle/core/session.py | 3 ++- unshackle/core/titles/episode.py | 4 ++-- unshackle/core/titles/movie.py | 4 ++-- unshackle/core/utilities.py | 2 +- unshackle/vaults/SQLite.py | 4 +++- 8 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index a7e3fe3..36a3190 100644 --- a/.gitignore +++ b/.gitignore @@ -218,6 +218,7 @@ cython_debug/ # you could uncomment the following to ignore the entire vscode folder .vscode/ .github/copilot-instructions.md +CLAUDE.md # Ruff stuff: .ruff_cache/ diff --git a/unshackle/core/binaries.py b/unshackle/core/binaries.py index 7dc6109..f846256 100644 --- a/unshackle/core/binaries.py +++ b/unshackle/core/binaries.py @@ -15,10 +15,7 @@ def find(*names: str) -> Optional[Path]: for name in names: if local_binaries_dir.exists(): - candidate_paths = [ - local_binaries_dir / f"{name}{ext}", - local_binaries_dir / name / f"{name}{ext}" - ] + candidate_paths = [local_binaries_dir / f"{name}{ext}", local_binaries_dir / name / f"{name}{ext}"] for path in candidate_paths: if path.is_file(): diff --git a/unshackle/core/constants.py b/unshackle/core/constants.py index 6a14f7d..65c6681 100644 --- a/unshackle/core/constants.py +++ b/unshackle/core/constants.py @@ -8,7 +8,13 @@ DRM_SORT_MAP = ["ClearKey", "Widevine"] LANGUAGE_MAX_DISTANCE = 5 # this is max to be considered "same", e.g., en, en-US, en-AU LANGUAGE_EXACT_DISTANCE = 0 # exact match only, no variants VIDEO_CODEC_MAP = {"AVC": "H.264", "HEVC": "H.265"} -DYNAMIC_RANGE_MAP = {"HDR10": "HDR", "HDR10+": "HDR10P", "Dolby Vision": "DV", "HDR10 / HDR10+": "HDR10P", "HDR10 / HDR10": "HDR"} +DYNAMIC_RANGE_MAP = { + "HDR10": "HDR", + "HDR10+": "HDR10P", + "Dolby Vision": "DV", + "HDR10 / HDR10+": "HDR10P", + "HDR10 / HDR10": "HDR", +} AUDIO_CODEC_MAP = {"E-AC-3": "DDP", "AC-3": "DD"} context_settings = dict( diff --git a/unshackle/core/session.py b/unshackle/core/session.py index bb08ca2..a935752 100644 --- a/unshackle/core/session.py +++ b/unshackle/core/session.py @@ -48,6 +48,7 @@ class CurlSession(Session): self.allowed_methods = allowed_methods or {"GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "TRACE"} self.catch_exceptions = catch_exceptions or ( exceptions.ConnectionError, + exceptions.ProxyError, exceptions.SSLError, exceptions.Timeout, ) @@ -137,7 +138,7 @@ def session(browser: str | None = None, **kwargs) -> CurlSession: - max_backoff: Maximum backoff time (float, default 60.0) - status_forcelist: List of status codes to force retry (list, default [429, 500, 502, 503, 504]) - allowed_methods: List of allowed HTTP methods (set, default {"GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "TRACE"}) - - catch_exceptions: List of exceptions to catch (tuple, default (exceptions.ConnectionError, exceptions.SSLError, exceptions.Timeout)) + - catch_exceptions: List of exceptions to catch (tuple, default (exceptions.ConnectionError, exceptions.ProxyError, exceptions.SSLError, exceptions.Timeout)) Returns: curl_cffi.requests.Session configured with browser impersonation, common headers, diff --git a/unshackle/core/titles/episode.py b/unshackle/core/titles/episode.py index 16ecab6..85ad7ac 100644 --- a/unshackle/core/titles/episode.py +++ b/unshackle/core/titles/episode.py @@ -95,9 +95,9 @@ class Episode(Title): media_info.audio_tracks, key=lambda x: ( float(x.bit_rate) if x.bit_rate else 0, - bool(x.format_additionalfeatures and "JOC" in x.format_additionalfeatures) + bool(x.format_additionalfeatures and "JOC" in x.format_additionalfeatures), ), - reverse=True + reverse=True, ) primary_audio_track = sorted_audio[0] unique_audio_languages = len({x.language.split("-")[0] for x in media_info.audio_tracks if x.language}) diff --git a/unshackle/core/titles/movie.py b/unshackle/core/titles/movie.py index 2e1d8bb..cd153b6 100644 --- a/unshackle/core/titles/movie.py +++ b/unshackle/core/titles/movie.py @@ -58,9 +58,9 @@ class Movie(Title): media_info.audio_tracks, key=lambda x: ( float(x.bit_rate) if x.bit_rate else 0, - bool(x.format_additionalfeatures and "JOC" in x.format_additionalfeatures) + bool(x.format_additionalfeatures and "JOC" in x.format_additionalfeatures), ), - reverse=True + reverse=True, ) primary_audio_track = sorted_audio[0] unique_audio_languages = len({x.language.split("-")[0] for x in media_info.audio_tracks if x.language}) diff --git a/unshackle/core/utilities.py b/unshackle/core/utilities.py index d97e9bd..7a5e10b 100644 --- a/unshackle/core/utilities.py +++ b/unshackle/core/utilities.py @@ -125,7 +125,7 @@ def is_exact_match(language: Union[str, Language], languages: Sequence[Union[str return closest_match(language, list(map(str, languages)))[1] <= LANGUAGE_EXACT_DISTANCE -def get_boxes(data: bytes, box_type: bytes, as_bytes: bool = False) -> Box: # type: ignore +def get_boxes(data: bytes, box_type: bytes, as_bytes: bool = False) -> Box: # type: ignore """ Scan a byte array for a wanted MP4/ISOBMFF box, then parse and yield each find. diff --git a/unshackle/vaults/SQLite.py b/unshackle/vaults/SQLite.py index ac89fec..f1922d7 100644 --- a/unshackle/vaults/SQLite.py +++ b/unshackle/vaults/SQLite.py @@ -37,7 +37,9 @@ class SQLite(Vault): if not self.has_table(service_name): continue - cursor.execute(f"SELECT `id`, `key_` FROM `{service_name}` WHERE `kid`=? AND `key_`!=?", (kid, "0" * 32)) + cursor.execute( + f"SELECT `id`, `key_` FROM `{service_name}` WHERE `kid`=? AND `key_`!=?", (kid, "0" * 32) + ) cek = cursor.fetchone() if cek: return cek[1]