style: apply ruff formatting fixes

This commit is contained in:
Andy
2025-10-23 18:11:30 +00:00
parent bdd219d90c
commit 3571c5eb3c
8 changed files with 19 additions and 12 deletions

1
.gitignore vendored
View File

@@ -218,6 +218,7 @@ cython_debug/
# you could uncomment the following to ignore the entire vscode folder # you could uncomment the following to ignore the entire vscode folder
.vscode/ .vscode/
.github/copilot-instructions.md .github/copilot-instructions.md
CLAUDE.md
# Ruff stuff: # Ruff stuff:
.ruff_cache/ .ruff_cache/

View File

@@ -15,10 +15,7 @@ def find(*names: str) -> Optional[Path]:
for name in names: for name in names:
if local_binaries_dir.exists(): if local_binaries_dir.exists():
candidate_paths = [ candidate_paths = [local_binaries_dir / f"{name}{ext}", local_binaries_dir / name / f"{name}{ext}"]
local_binaries_dir / f"{name}{ext}",
local_binaries_dir / name / f"{name}{ext}"
]
for path in candidate_paths: for path in candidate_paths:
if path.is_file(): if path.is_file():

View File

@@ -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_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 LANGUAGE_EXACT_DISTANCE = 0 # exact match only, no variants
VIDEO_CODEC_MAP = {"AVC": "H.264", "HEVC": "H.265"} 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"} AUDIO_CODEC_MAP = {"E-AC-3": "DDP", "AC-3": "DD"}
context_settings = dict( context_settings = dict(

View File

@@ -48,6 +48,7 @@ class CurlSession(Session):
self.allowed_methods = allowed_methods or {"GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "TRACE"} self.allowed_methods = allowed_methods or {"GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "TRACE"}
self.catch_exceptions = catch_exceptions or ( self.catch_exceptions = catch_exceptions or (
exceptions.ConnectionError, exceptions.ConnectionError,
exceptions.ProxyError,
exceptions.SSLError, exceptions.SSLError,
exceptions.Timeout, exceptions.Timeout,
) )
@@ -137,7 +138,7 @@ def session(browser: str | None = None, **kwargs) -> CurlSession:
- max_backoff: Maximum backoff time (float, default 60.0) - 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]) - 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"}) - 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: Returns:
curl_cffi.requests.Session configured with browser impersonation, common headers, curl_cffi.requests.Session configured with browser impersonation, common headers,

View File

@@ -95,9 +95,9 @@ class Episode(Title):
media_info.audio_tracks, media_info.audio_tracks,
key=lambda x: ( key=lambda x: (
float(x.bit_rate) if x.bit_rate else 0, 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] primary_audio_track = sorted_audio[0]
unique_audio_languages = len({x.language.split("-")[0] for x in media_info.audio_tracks if x.language}) unique_audio_languages = len({x.language.split("-")[0] for x in media_info.audio_tracks if x.language})

View File

@@ -58,9 +58,9 @@ class Movie(Title):
media_info.audio_tracks, media_info.audio_tracks,
key=lambda x: ( key=lambda x: (
float(x.bit_rate) if x.bit_rate else 0, 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] primary_audio_track = sorted_audio[0]
unique_audio_languages = len({x.language.split("-")[0] for x in media_info.audio_tracks if x.language}) unique_audio_languages = len({x.language.split("-")[0] for x in media_info.audio_tracks if x.language})

View File

@@ -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 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. Scan a byte array for a wanted MP4/ISOBMFF box, then parse and yield each find.

View File

@@ -37,7 +37,9 @@ class SQLite(Vault):
if not self.has_table(service_name): if not self.has_table(service_name):
continue 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() cek = cursor.fetchone()
if cek: if cek:
return cek[1] return cek[1]