gallery-dl icon indicating copy to clipboard operation
gallery-dl copied to clipboard

Support negative indices with --range and --chapter-range (#5402)

Open thatDudo opened this issue 10 months ago • 2 comments

It seems it wasnt possible to download just the last pages of each chapter. I have looked through the code and the main difficulty is that _kwdict["count"] is not always defined if the chapter extractor is returning an iterator rather than a list. If that is the case, it will treat -n:-m as (0,sys.maxsize).

If you want I can cache some of the results rather than recalculating them on each call.

Fixes #5402

thatDudo avatar May 30 '25 21:05 thatDudo

I suppose it might have been possible to do this with filter predicates by using page and count.

thatDudo avatar May 30 '25 22:05 thatDudo

Another problem is that count does not always represent the total number of files. For other sites, e.g. Twitter / Instagram / anything with posts, it is used for the number of files per post.

It also doesn't work for --chapter-range, as it might represent the count value of the current chapter and not the total number of chapters.

We should introduce a new field that either holds the total number of files / items (total, count_total ?) or a boolean value indicating if count can be used as total number of items.

mikf avatar Jun 02 '25 09:06 mikf