mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-29 04:15:09 +00:00
refactor(core)!: drop leading underscores from internal definitions
Renames 314 defs and 41 module/class-level constants. Keeps 11 names underscored where the stripped form collides in scope, plus 5.5.0 shims for the three symbols external service repos call.
This commit is contained in:
@@ -115,7 +115,7 @@ class DASH:
|
||||
if period_id := period.get("id"):
|
||||
filtered_period_ids.append(period_id)
|
||||
continue
|
||||
if not DASH._is_content_period(period, []):
|
||||
if not DASH.is_content_period(period, []):
|
||||
if period_id := period.get("id"):
|
||||
filtered_period_ids.append(period_id)
|
||||
continue
|
||||
@@ -126,8 +126,8 @@ class DASH:
|
||||
continue
|
||||
|
||||
for rep in adaptation_set.findall("Representation"):
|
||||
get = partial(self._get, adaptation_set=adaptation_set, representation=rep)
|
||||
findall = partial(self._findall, adaptation_set=adaptation_set, representation=rep, both=True)
|
||||
get = partial(self.get_attr, adaptation_set=adaptation_set, representation=rep)
|
||||
findall = partial(self.find_elements, adaptation_set=adaptation_set, representation=rep, both=True)
|
||||
segment_base = rep.find("SegmentBase")
|
||||
|
||||
codecs = get("codecs")
|
||||
@@ -343,7 +343,7 @@ class DASH:
|
||||
init_data: Optional[bytes] = None
|
||||
track_kid: Optional[UUID] = None
|
||||
|
||||
content_periods = [p for p in all_periods if DASH._is_content_period(p, filtered_period_ids)]
|
||||
content_periods = [p for p in all_periods if DASH.is_content_period(p, filtered_period_ids)]
|
||||
period_count = len(content_periods)
|
||||
|
||||
if period_count > 1:
|
||||
@@ -365,7 +365,7 @@ class DASH:
|
||||
log.warning(f"Representation '{rep_id}' not found in period '{period_id}', skipping")
|
||||
continue
|
||||
|
||||
p_init, p_segments, p_timescale, p_durations, p_kid = DASH._get_period_segments(
|
||||
p_init, p_segments, p_timescale, p_durations, p_kid = DASH.get_period_segments(
|
||||
period=content_period,
|
||||
adaptation_set=matched_as,
|
||||
representation=matched_rep,
|
||||
@@ -583,7 +583,7 @@ class DASH:
|
||||
progress(downloaded="Downloaded")
|
||||
|
||||
@staticmethod
|
||||
def _is_content_period(period: Element, filtered_period_ids: list[str]) -> bool:
|
||||
def is_content_period(period: Element, filtered_period_ids: list[str]) -> bool:
|
||||
"""Check if a period is a valid content period (not an ad, not filtered, not trick mode)."""
|
||||
period_id = period.get("id")
|
||||
if period_id and period_id in filtered_period_ids:
|
||||
@@ -597,7 +597,7 @@ class DASH:
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def _merge_segment_templates(adaptation_set: Element, representation: Element) -> Optional[Element]:
|
||||
def merge_segment_templates(adaptation_set: Element, representation: Element) -> Optional[Element]:
|
||||
"""
|
||||
Build the effective SegmentTemplate for a Representation by cascading the
|
||||
AdaptationSet > Representation levels (ISO/IEC 23009-1 5.3.9.1).
|
||||
@@ -623,7 +623,7 @@ class DASH:
|
||||
return merged
|
||||
|
||||
@staticmethod
|
||||
def _get_period_segments(
|
||||
def get_period_segments(
|
||||
period: Element,
|
||||
adaptation_set: Element,
|
||||
representation: Element,
|
||||
@@ -656,7 +656,7 @@ class DASH:
|
||||
period_duration = period.get("duration") or manifest.get("mediaPresentationDuration")
|
||||
init_data: Optional[bytes] = None
|
||||
|
||||
segment_template = DASH._merge_segment_templates(adaptation_set, representation)
|
||||
segment_template = DASH.merge_segment_templates(adaptation_set, representation)
|
||||
|
||||
segment_list = representation.find("SegmentList")
|
||||
if segment_list is None:
|
||||
@@ -811,8 +811,12 @@ class DASH:
|
||||
|
||||
return init_data, segments, segment_timescale, segment_durations, track_kid
|
||||
|
||||
# Deprecated 5.5.0 shims for service repos still on the old underscored names; drop once they migrate.
|
||||
_is_content_period = is_content_period
|
||||
_get_period_segments = get_period_segments
|
||||
|
||||
@staticmethod
|
||||
def _get(item: str, adaptation_set: Element, representation: Optional[Element] = None) -> Optional[Any]:
|
||||
def get_attr(item: str, adaptation_set: Element, representation: Optional[Element] = None) -> Optional[Any]:
|
||||
"""Helper to get a requested item from the Representation, otherwise from the AdaptationSet."""
|
||||
adaptation_set_item = adaptation_set.get(item)
|
||||
if representation is None:
|
||||
@@ -825,7 +829,7 @@ class DASH:
|
||||
return adaptation_set_item
|
||||
|
||||
@staticmethod
|
||||
def _findall(
|
||||
def find_elements(
|
||||
item: str, adaptation_set: Element, representation: Optional[Element] = None, both: bool = False
|
||||
) -> list[Any]:
|
||||
"""
|
||||
@@ -1018,7 +1022,7 @@ class DASH:
|
||||
return next(
|
||||
(
|
||||
int(x.get("value"))
|
||||
for x in DASH._findall("SupplementalProperty", adaptation_set, representation, both=True)
|
||||
for x in DASH.find_elements("SupplementalProperty", adaptation_set, representation, both=True)
|
||||
if x.get("schemeIdUri") == "tag:dolby.com,2018:dash:EC3_ExtensionComplexityIndex:2018"
|
||||
),
|
||||
None,
|
||||
@@ -1080,7 +1084,7 @@ class DASH:
|
||||
if kid_b64:
|
||||
try:
|
||||
kid = UUID(bytes=base64.b64decode(kid_b64))
|
||||
except Exception:
|
||||
except ValueError:
|
||||
kid = None
|
||||
|
||||
drm.append(PlayReady(pssh=pr_pssh, kid=kid, pssh_b64=pr_pssh_b64))
|
||||
@@ -1096,7 +1100,7 @@ class DASH:
|
||||
except ValueError:
|
||||
try:
|
||||
kid = UUID(bytes=base64.b64decode(kid_attr))
|
||||
except Exception:
|
||||
except ValueError:
|
||||
kid = None
|
||||
|
||||
if not kid:
|
||||
@@ -1151,7 +1155,7 @@ class DASH:
|
||||
|
||||
@staticmethod
|
||||
@lru_cache(maxsize=None)
|
||||
def _field_format_pattern(field: str) -> re.Pattern:
|
||||
def field_format_pattern(field: str) -> re.Pattern:
|
||||
# printf-style `$Field%fmt$` matcher, compiled once per field name
|
||||
return re.compile(rf"\${re.escape(field)}%([a-z0-9]+)\$", flags=re.I)
|
||||
|
||||
@@ -1161,7 +1165,7 @@ class DASH:
|
||||
return url
|
||||
for field, value in kwargs.items():
|
||||
url = url.replace(f"${field}$", str(value))
|
||||
m = DASH._field_format_pattern(field).search(url)
|
||||
m = DASH.field_format_pattern(field).search(url)
|
||||
if m:
|
||||
url = url.replace(m.group(), f"{value:{m.group(1)}}")
|
||||
return url
|
||||
|
||||
Reference in New Issue
Block a user