mirror of
https://github.com/Glitchy-Sheep/boosty-downloader.git
synced 2026-10-14 21:33:23 +00:00
[PR #187] [MERGED] [downloader] Move media downloads into PostMediaDownloader #185
Labels
No labels
api-drift
bug
ci
documentation
enhancement
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Glitchy-Sheep/boosty-downloader#185
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Glitchy-Sheep/boosty-downloader/pull/187
Author: @Glitchy-Sheep
Created: 9/13/2026
Status: ✅ Merged
Merged: 9/13/2026
Merged by: @Glitchy-Sheep
Base:
main← Head:refactor/post-media-downloader📝 Commits (2)
4111774[downloader] Add PostMediaDownloader with one progress and error contract9d2d9b4[downloader] Drive media downloads through PostMediaDownloader📊 Changes
10 files changed (+904 additions, -593 deletions)
View changed files
📝
boosty_downloader/application/use_cases/download_single_post.py(+128 -272)➕
boosty_downloader/infrastructure/post_media_downloader.py(+258 -0)📝
test/unit/file_downloader/extension_guessing_test.py(+5 -76)📝
test/unit/file_downloader/filename_truncation_test.py(+4 -4)➕
test/unit/post_media_downloader/__init__.py(+0 -0)➕
test/unit/post_media_downloader/post_media_downloader_test.py(+331 -0)➕
test/unit/use_cases/chunk_error_translation_test.py(+172 -0)➖
test/unit/use_cases/ext_video_errors_test.py(+0 -97)➖
test/unit/use_cases/ext_video_threading_test.py(+0 -138)📝
test/unit/use_cases/video_filename_test.py(+6 -6)📄 Description
📝 Summary
Audit stage 4, part 1 of 3: the I/O half of
DownloadSinglePostUseCasemoves to infrastructure. Pure refactoring: the on-disk tree,post.htmland the cache rows do not change.🔧 What changes
infrastructure/post_media_downloader.pysaves the media of one post: images, files, audio, Boosty videos and external videos (yt-dlp off the event loop). It owns the subfolder layout and the filename policy per kind, and speaks one language outward: progress asMediaProgress(same shape for aiohttp and yt-dlp), a failure asMediaDownloadErrorwith the transport error as its cause, cancellation asCancelledErrorwith the partial file removed.DownloadSinglePostUseCaseshrinks from 568 to 424 lines and keeps orchestration only: map, cache lookup, parallel chunks,post.html, cache write, statistics. Chunk dispatch checksCHUNK_TO_FILTERonce and matches on the chunk kind; thenoqa: C901, PLR0911markers are gone.MediaDownloadErrorbecomes a loggedApplicationFailedDownloadError. The cause chain is kept, so the expired-link refresh and the path-too-long hint still see the transport error underneath.Wording
Failure messages are unified:
Couldn't download resource: <reason>with the file name or the URL as the resource. Reasons are the same texts as before.🧪 Tests
test/unit/post_media_downloader: layout and relative paths, extension policy (#75), progress shape, transport failure and cancellation contracts, yt-dlp off the loop and cancellable, everyExtVideoErrormapped.chunk_error_translation_test: the use case's two branches, including the 400 visible through the cause chain.ext_video_threading_testandext_video_errors_testretired: the media downloader tests pin the same behaviour.task cigreen locally: ruff, pyright strict, import-linter, 255 tests + e2e (the e2e tree assertions are the oracle for this refactoring).--dry-run -f post_content -f audiopromised 11 images and 2 audio files, the real run saved exactly that, a rerun served everything from the cache.⏭️ Next
PR 2: when one chunk fails, finish the others and cache the content types that completed (audit 19.1). PR 3:
--post-urlthrough the post retrier, URL parsing up front, 429 retries.✅ Checklist
--helpand README if neededdocs/if the download flow or dev process changed## Unreleasedin CHANGELOG.md (or theci/skip-changeloglabel if not user-facing)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.