Skip to content

Support negative indexes in --range slices #5402

@bradenhilton

Description

@bradenhilton

I often find myself wanting to download, for example, all the but the last n files from a URL. Currently, using a negative index results in a NOP:

gallery-dl --range 2:-1 -- https://imgur.com/a/TcBmP
<nothing>

Working around this requires one of the following:

  1. Run gallery-dl -K <URL> and check for count, then run gallery-dl --range <RANGE> <URL> with this newly discovered count. This requires at least 2 requests for information that gallery-dl already knows with a single request.
  2. Run something like gallery-dl --filter "2 <= num <= count-1" <URL>. This requires each file to have a num equivalent, which I'm not sure is the case for all extractors.
  3. Manually count the number of files and use this with --range.

Ideally, a range slice should support negative indexes. If that is non-trivial to implement, providing such a range slice should result in an error instead of a NOP.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions