mikf / gallery-dl

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

[Nozomi] preserving image order for multi-image posts #1239

Closed oxi7589 closed 3 years ago

oxi7589 commented 3 years ago

There seems to be no way to easily preserve image order in nozomi.la's posts which contain several images.

Here is a decent enough (NSFW) example demonstrating the issue: https://nozomi.la/post/16456253.html

>gallery-dl.exe https://nozomi.la/post/16456253.html
* .\gallery-dl\nozomi\16456253 b28b8da6d48af73ebef7c9043567be3ef4566faf90745f3b4394308510c5b955.jpg
* .\gallery-dl\nozomi\16456253 7f6e1d65fe9ef2d9969643afbfaf0a87857542cc68e22a9dc647b4dbfe4bdf17.jpg
* .\gallery-dl\nozomi\16456253 62a6983eef0b1711e966a9b9508235d34a2464b20d9ff72871e1a4cc6d18c45f.jpg
* .\gallery-dl\nozomi\16456253 31c6abf815db94a554aae3d0324b907e3b409fc27c61388599b9875597e50578.jpg
* .\gallery-dl\nozomi\16456253 dfcd79bb860cd041d58bbbf869bb5579fec9f3839b289493783224ce61959ebf.jpg

The download order corresponds to the best viewing order (hopefully, this is by design and is not an implementation detail that may break any time).

But, obliviously, when filenames are sorted alphanumerically, it's all messed up. Sorting by date makes even less sense, since gallery-dl messes with modification dates so they are all the same.

Running >gallery-dl -K https://nozomi.la/post/16456253.html results in nothing that looks like image number within the post. --write-metadata doesn't help either -- the jsons are identical except for "dataid", "filename" and "url" (all being variations of the same thing), so cannot be used to restore the order.

So my question is, is there a better way to preserve the sequence order, other than hacky and hard to automate "copy gallery-dl's output and build a rename script from that"?

mikf commented 3 years ago

Would adding an enumeration index work for you, so you could have 16456253_01.jpg, 16456253_02.jpg, etc as filenames? Is it OK if those are there even if a post only has one file?

since gallery-dl messes with modification dates so they are all the same

Can be disabled with downloader.mtime or --no-mtime.

oxi7589 commented 3 years ago

Would adding an enumeration index work for you, so you could have 16456253_01.jpg, 16456253_02.jpg, etc as filenames? Is it OK if those are there even if a post only has one file?

Yes, that sounds like a good solution. An extra index wouldn't hurt for single-page posts, and it will make sorting multi-image ones a lot easier.

mikf commented 3 years ago

Add {num} (or e.g. {num:>02}) to the filename format string and you'll have ordered images in multi-file posts