mikf / gallery-dl

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

DEVIANTART _ Is there any way to make gallery-dl's file naming include author's_name? #3432

Closed GotoConsol closed 1 year ago

GotoConsol commented 1 year ago

Is there any way to make gallery-dl's file naming include author's_name? Especially starting file naming with author's_name?

Thanks

rautamiekka commented 1 year ago

Since you specify DeviantArt:

{author[username]}

I'd absolutely advice using this setting for DA:

            "filename": "{category}_{index}_{author[username]}_{date:%Y-%m-%d_%H_%M_%S}_{title}.{extension}"

It results in filenames like (24h time, as it's simpler to sort/parse and doesn't get bothered by non-English languages not using am/pm spellings):

deviantart_845233893_AmicaSecretUwU_2020-06-12_11_50_21_Base 1.png
GotoConsol commented 1 year ago

ok, thanks

my config file already includes:

{ "extractor": { "deviantart": { "client-id": "", "client-secret": "" } } }

how to put this other setting into the config file correctly?

for example like this: ?

{ "extractor": { "deviantart": { "client-id": "", "client-secret": "" } } }

"filename": "{category}{index}{author[username]}{date:%Y-%m-%d%H%M%S}_{title}.{extension}"

so leaving existing format and an empty line after it and simply put it in the next line the new setting?

GotoConsol commented 1 year ago

and what is the importance of index number? why is it in the second place before the author's name?

the date in the setting is the upload date of the artwork?

why the index number shouldn't be after author's name and upload date of the artwork?

rautamiekka commented 1 year ago

Replace an existing line inside the DeviantArt category; I dunno if a dupe would be taken in order of appearance (if not in a separate file), to boot.

JSON doesn't care about whitespace, indentation, or otherwise of order of appearance, so it doesn't matter if you have a new line between them. Just be sure that

  1. each setting is separated by a comma, like you can see with your current ones:
        "deviantart": {
            "username": "...",
            "password": "...",
            "client-id": "...",
            "client-secret": "..."
        }

    instead of

        "deviantart": {
            "username": "..."
            "password": "..."
            "client-id": "..."
            "client-secret": "..."
        }
  2. the last line inside a category doesn't end with a comma, like your "client-secret": "" that's the last line:
        "deviantart": {
            "username": "...",
            "password": "...",
            "client-id": "...",
            "client-secret": "..."
        }

    instead of

        "deviantart": {
            "username": "...",
            "password": "...",
            "client-id": "...",
            "client-secret": "...",
        }

You can use a JSON linter such as https://jsonlint.com/ to check the syntax validity. An invalid JSON shouldn't get silently ignored anymore, but better safe than sorry.

The index is the unique upload code on DA, it's the only thing that separates uploads, therefore it increases for every upload but is unaffected by replacing with an updated file. And makes it far easier to find what you look for, whether for finding it again on DA or finding something from DA in your archive, or so that impossibly small changes don't force you to do extensive checking to figure out which is older or a dupe.

The timestamp is there for both knowing when something was uploaded and to tell the updated and the old file apart. However, now that you mention, the timestamp should also be before the username, as it's far more likely the file is updated by the same username than after changing the username, likewise making sorting easier:

            "filename": "{category}_{index}_{date:%Y-%m-%d_%H_%M_%S}_{author[username]}_{title}.{extension}"

I'll need to make scripts to rename my archives to these changes ...

GotoConsol commented 1 year ago

but if you mention sorting: anyway on what base do you sort? just to consider you talk about updated files by author

then maybe this order could be considered:

deviantart_author_artworkTitle_dateindex.extension

for me sorting is based on firstly on author then title and the mentioned update would pop up in the best way if you would see two same titles below each other and you would have date and index after the same titles

if you are after updated artworks I think the easiest way to find them is like above

what do you think?

rautamiekka commented 1 year ago

A-Z filename usually.

Nope, title can be near-empty.

The predictable ones like upload code (which only changes if you upload a whole new thing instead of replace) and a 24h upload timestamp (to know when it was uploaded and tell updates apart. If the site doesn't support such thing, like Derpibooru, then it's only good for knowing when it was uploaded, which will always be after a smaller upload code cuz the upload code is unique) must come 1st in that order cuz the rest of the useful info to include in the filename will be unpredictable (username and title, especially title since it can always change to nearly anything without paying and waiting) or irrelevant (like the file extension, since there can also be a JSON file with all the possible details, or a HTML file that's either a story or a journal post, or a text file containing the description, while the art themselves can be a long list of types, although mostly JPG/PNG/TIFF/GIF/ZIP/7z/RAR).

^ 99.999% sure it can't get better for filename A-Z sorting and parsing than {category}_{index}_{date:%Y-%m-%d_%H_%M_%S}_{author[username]}_{title}.{extension}, I've seen it too many times when browsing my huge archive from my start as an art archivist, when the horrible inconclusive mess of a filename made finding anything more of a wasted effort. If it can get better, the JSON file can be used with a rename script to predictably parse+rename accordingly.

GotoConsol commented 1 year ago

Do you mean this order:

{category}{index}{date:%Y-%m-%d%H%M%S}{author[username]}_{title}.{extension}

for sorting files from a single author and keeping in mind that his/her username could be changed from time to time and besides that there could be file updates ?

rautamiekka commented 1 year ago

Yeah.