Skip to content

[options] add --stop-after to limit download size #9044

Open
NecRaul wants to merge 7876 commits intomikf:masterfrom
NecRaul:args/stop-after
Open

[options] add --stop-after to limit download size #9044
NecRaul wants to merge 7876 commits intomikf:masterfrom
NecRaul:args/stop-after

Conversation

@NecRaul
Copy link
Copy Markdown
Contributor

@NecRaul NecRaul commented Feb 12, 2026

This PR introduces a new --stop-after option to stop extraction after a specified total number of downloaded bytes. The limit is shared across all DownloadJob instances so nested extractors and child jobs respect the same global cap.

Changes

  • Add --stop-after SIZE CLI argument
  • Track cumulative downloaded bytes via a shared capacity dict
  • Stop extraction once the limit is exceeded via exception.StopExtraction
  • Add text.format_bytes() helper for human-readable logging of downloaded bytes

Notes

text.format_bytes() is intended as the inverse of text.parse_bytes() and currently only used for logging, but may be useful elsewhere. If this helper is not desired, it could be inlined or moved to where it's currently being used.

mikf and others added 30 commits January 3, 2026 21:07
support using a 'User-Agent' header preset, e.g. "+firefox"
regular division is slightly faster than floor division
and a float timestamp value is treated the same as an integer one
mikf#8803 (comment)
mikf#8803 (comment)

- add 'recursive' option, remove 'zip'
- recurse into subdirectories
- add 'path' metadata
- remove 'count' & 'num' metadata
- update default directory & archive format
allow remuxing bgm audio into a different format/container
fixes regression introduced in a28fbbc
add 'media-user' and 'media-item' extractors
TODO: 'media-category' extractor (?)
* bilibili: add support for live photo downloads
* fix: resolve flake8 linting errors (whitespace and line length)
* fix: resolve flake8 E302 and W293 linting errors
* fix: resolve flake8 W293 and E302 linting errors

* simplify syntax
* add 'livephoto' option
* add tests
implement generic access of
* list items        (L[1]   -> L.1)
* dict vslues       (D[key] -> D.key)
* object attributes (O.attr -> O.attr)
in standard format strings
mikf and others added 27 commits February 9, 2026 18:57
e.g. USER/submitted or USER/comments
fixes regression introduced in c16892a
use '[^/?#]+' for names
- filter posts manually
- don't use lists for 'in' checks against constant values
Introduce a new --stop-after option to limit the total number of bytes
downloaded. DownloadJob now tracks cumulative downloaded size using a
shared capacity dictionary. Extraction stops once the limit is reached.

- Add capacity parameter to DownloadJob and propagate it in main()
- Track _capacity["used"] and compare against _capacity["limit"]
- Parse --stop-after value and convert to bytes
Add text.format_bytes() to convert integers to human-readable
byte strings (e.g., 2.50M). This is conceptually the reverse
of text.parse_bytes(). Currently only used in DownloadJob to
log --stop-after limits, but could be moved or inlined where
it is used if preferred.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.