mikf / gallery-dl

Command-line program to download image galleries and collections from several image hosting sites
GNU General Public License v2.0
11.93k stars 975 forks source link

Question: How can i filter width directlink url #1690

Closed peammm closed 3 years ago

peammm commented 3 years ago

python3 version: 1.18.1 platform: Ubuntu 20.04 LTS

I try below command line but not working.

gallery-dl "r:https://xxx.net/373/373381" --filter "width >= 450"

gallery-dl "r:https://xxx.net/373/373381" --filter "image_width >= 450"

[directlink][error] FilterError: Evaluating filter expression failed (NameError: name 'image_width' is not defined)

mikf commented 3 years ago

Not possible. --filter can only access the metadata provided by the extractor and that doesn't (and can't) have information about image dimensions for arbitrary URLs. It is sometimes available on specific, supported sites, but even that is not required to be the actual image width/height.

What you could do is write a script that reads image dimensions with identify, ffprobe, etc and deletes the files that don't fit your criteria, and run said script with gallery-dl's --exec. It is, however, in general impossible to know an image's width/height before downloading it.