fix(downloads): address code-review findings on the R2.5 mini-epic
- redownload: never clobber a co-held (deduped) asset. Drop the force-reset-to-pending; _release_asset already deletes+recreates a solo asset (genuine re-fetch), while a shared ready asset is left intact and the re-queued job re-points to it via _finish_from_cache — so one user's re-download can't delete another's file mid-serve (finding #1). - redownload: reset queue_pos to the tail so a re-download doesn't front-run newer queued jobs on the worker's `ORDER BY queue_pos` claim (finding #3). Made service.next_queue_pos public. - formats: video-only mp4 selector prefers every video-only option before any progressive `best`, so a "Video only" download stays audio-free whenever a video-only stream exists (#2). - titles: a title that is only the engagement prefix no longer resurrects the stripped stats (return the stripped text / empty, not the raw) (#4). - worker: probe the file's duration when yt-dlp gave none, so a long re-encode shows real progress instead of a frozen 0% (#5); tighten the ensure_browser_playable docstring to its actual mp4-profile scope (#6).
This commit is contained in:
@@ -58,8 +58,9 @@ def normalize_title(raw: str | None) -> str | None:
|
||||
return raw
|
||||
t = unicodedata.normalize("NFKC", raw)
|
||||
t = "".join(ch for ch in t if unicodedata.category(ch) not in _DROP_CATEGORIES)
|
||||
t = _ENGAGEMENT_PREFIX.sub("", t)
|
||||
t = _TRAILING_HASHTAGS.sub("", t)
|
||||
stripped = _ENGAGEMENT_PREFIX.sub("", t)
|
||||
prefix_removed = stripped != t
|
||||
t = _TRAILING_HASHTAGS.sub("", stripped)
|
||||
|
||||
multi = [r for r in _LETTER_RUN.findall(t) if len(r) >= 2]
|
||||
caps = [r for r in multi if r.isupper()]
|
||||
@@ -87,4 +88,7 @@ def normalize_title(raw: str | None) -> str | None:
|
||||
if ch.isalpha():
|
||||
t = t[:i] + ch.upper() + t[i + 1:]
|
||||
break
|
||||
return t or raw
|
||||
# Nothing survived cleaning: fall back to the engagement-stripped text (never resurrect a
|
||||
# stats prefix). Only use the untouched raw when no prefix was there to strip — e.g. an
|
||||
# all-emoji title whose glyphs were dropped, where returning the original is the lesser evil.
|
||||
return t or stripped.strip() or ("" if prefix_removed else raw)
|
||||
|
||||
Reference in New Issue
Block a user