style: clean up prose

This commit is contained in:
imSp4rky
2026-08-19 13:45:58 -06:00
parent 54adb82746
commit 29d0828c33
40 changed files with 109 additions and 110 deletions
+4 -4
View File
@@ -59,7 +59,7 @@ def measure_real_bitrate(
Single-file tracks are measured exactly. Segmented tracks probe up to
``samples`` segments spread across the track and extrapolate; byte-range
segments need no request. Returns bits/sec, or ``None`` if it cannot be
measured. Never raises — a probe failure must not abort a download.
measured. Never raises; a probe failure must not abort a download.
"""
from unshackle.core.tracks.track import Track
@@ -74,7 +74,7 @@ def measure_real_bitrate(
# Descriptor.URL: a single file. Some services parse a DASH
# manifest then collapse each representation to its single BaseURL and
# flip the descriptor to URL, leaving the manifest (and its duration) in
# track.data — recover the duration from there, else probe the file.
# track.data: recover the duration from there, else probe the file.
segments = extract_url(track, session, log=log)
if not segments:
log.debug(f"{track.id}: cannot measure real bitrate (no known duration)")
@@ -130,7 +130,7 @@ def apply_real_bitrates(
declared-bitrate tracks per group are probed, in parallel. Each group is then
extended downward: while the lowest probed bitrate in a group sits below the
next unprobed track's declared bitrate (so that track could outrank a probed
one), the next track is probed too — until the probed set is safely above the
one), the next track is probed too, until the probed set is safely above the
rest. Unprobed tracks keep their manifest-declared bitrate.
"""
groups: defaultdict[Hashable, list["Track"]] = defaultdict(list)
@@ -182,7 +182,7 @@ def dedupe(segments: list[Segment]) -> list[Segment]:
Collapse segments that address the same bytes so each object is measured once.
Manifests sometimes wrap a single file in several segment entries sharing one
URL — with no byte range (a ``SegmentTemplate`` whose media pattern has no
URL, with no byte range (a ``SegmentTemplate`` whose media pattern has no
``$Number$``) or with the same range. Each resolves to the whole file, so
counting them all would multiply the size by the segment count. Segments
sharing the same ``(url, byte_range)`` are merged into one entry whose duration
+3 -3
View File
@@ -97,7 +97,7 @@ def lookup_session(source: Optional[requests.Session]) -> requests.Session:
Build a plain, retry-free requests session for IP geolocation.
Geolocation needs no TLS fingerprinting, so we skip the impersonated rnet
session and the base session's urllib3 retry loop — both retry 429 internally,
session and the base session's urllib3 retry loop. Both retry 429 internally,
which hides the response and defeats fast provider handover. With a bare session
a 429 comes straight back so we can move to the next provider immediately. Only
the proxy is carried over so proxied lookups still report the proxy's exit IP.
@@ -139,7 +139,7 @@ def fetch_ipinfo(session: requests.Session) -> Optional[dict]:
def fetch_ip_api_in(session: requests.Session) -> Optional[dict]:
"""ip-api.in has no /me endpoint — resolve IP via ipify first, then look it up."""
"""ip-api.in has no /me endpoint, so resolve IP via ipify first, then look it up."""
ip_resp = session.get("https://api.ipify.org", timeout=REQUEST_TIMEOUT)
if ip_resp.status_code == 429:
raise RateLimited()
@@ -198,7 +198,7 @@ def get_ip_info(
returned info reflects the proxy's exit IP. Auth headers for ipinfo
are sent per-request; never mutated onto session.headers.
cached: When True, read/write a 24h Cacher-backed entry. Use only for
local IP lookups — never with a proxied session.
local IP lookups, never with a proxied session.
"""
cache = None
if cached: