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:
@@ -26,6 +26,9 @@ def test_video_only_mp4_selects_avc1():
|
||||
fmt = _opts({"mode": "v", "container": "mp4"})["format"]
|
||||
assert fmt.startswith("bestvideo[vcodec^=avc1]")
|
||||
assert "+bestaudio" not in fmt # video-only never merges audio
|
||||
# A video-only download stays audio-free: every `bestvideo` (video-only) option is preferred
|
||||
# over any `best` (progressive, audio-bearing) fallback.
|
||||
assert fmt.index("bestvideo") < fmt.index("best[vcodec^=avc1]") < fmt.rindex("/best")
|
||||
|
||||
|
||||
def test_max_height_caps_every_branch():
|
||||
|
||||
@@ -61,3 +61,10 @@ def test_engagement_prefix_does_not_touch_normal_titles():
|
||||
# A pipe that isn't an engagement prefix must survive.
|
||||
assert normalize_title("Vlog 12 | A nagy nap") == "Vlog 12 | A nagy nap"
|
||||
assert normalize_title("How I built a boat") == "How I built a boat"
|
||||
|
||||
|
||||
def test_engagement_only_title_does_not_resurrect_the_stats():
|
||||
# A title that is ONLY the stats prefix must not fall back to the raw (stats-bearing) string.
|
||||
out = normalize_title("1.6M views · 66K reactions |")
|
||||
assert out == ""
|
||||
assert "views" not in (out or "") and "reactions" not in (out or "")
|
||||
|
||||
Reference in New Issue
Block a user