Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--write-metadata shouldn't override metadata options in configuration file #678

Closed
Vrihub opened this issue Apr 6, 2020 · 6 comments
Closed

Comments

@Vrihub
Copy link
Contributor

Vrihub commented Apr 6, 2020

I have set metadata options in my configuration file so that gallery-dl always downloads metadata in a custom directory, and it works OK.

However, if by mistake I also add --write-metadata on the command line, it seems that options in the configuration files are ignored; especially: metadata are not written anymore in my custom directory but in the default directory (=the same where images are saved).

@Hrxn
Copy link
Contributor

Hrxn commented Apr 7, 2020

Uh, no, that's basically how all CLI programs behave. If you have set the same option (i.e. write-metadata) in both your config file and on the command-line, the command-line always overwrites the config file.

@Vrihub
Copy link
Contributor Author

Vrihub commented Apr 7, 2020

Uh, no, that's basically how all CLI programs behave...

Of course, but this holds if the option on CL and the one in the config file are the same.

The problem here is that --write-metadata, which is (should be ?) just a switch to decide whether to write metadata or not, overrides another option, i.e. metadata.directory in config. It shouldn't have any effect here (since metadata writing is already configured in the file) and it shouldn't reset other metadata options to the default value.

@mikf
Copy link
Owner

mikf commented Apr 8, 2020

which is (should be ?) just a switch to decide whether to write metadata or not

Well, it's not, or at least that's not how it's implemented. --write-metadata sets a global postprocessors setting, overriding all other post-processor settings in the process.

What you could do is define your metadata settings in a secondary config file and only load it with -c/--config if you want to enable writing metadata:

metadata.conf
-------------

{ "postprocessors": [
    {
        "name": "metadata",
        "other": "settings"
    }
] }
$ gallery-dl -c metadata.conf URL

@Vrihub
Copy link
Contributor Author

Vrihub commented Apr 28, 2020

Well, it's not, or at least that's not how it's implemented. --write-metadata sets a global postprocessors setting, overriding all other post-processor settings in the process.

Uhm, are there other global "switch" options that behave in this way?
At first glance, I would check --write-tags and --zip.

If --write-metadata is the only one, I would insist that it should be fixed (i.e. have no effect if the config file already contains any postprocessors.metadata options).

If you want to keep this behaviour instead, I think it should be documented in docs/configuration.rst and in the man page (I can try to come up with a patch).

@mikf
Copy link
Owner

mikf commented Apr 30, 2020

Uhm, are there other global "switch" options that behave in this way?

Yes, almost all of them.
Most command-line switches are implemented by setting a global config setting at the base level that "overwrites" all config options with the same name.

It usually makes sense for "simple" values like HTTP timeouts, proxy servers, etc. that a command-line switch takes precedence over a config setting, but for complex/composite stuff like a list of post processor objects it does seem weird, I agree.

I'll see if I can improve the current documentation, but I'd also gladly accept a patch from you.

Vrihub added a commit to Vrihub/gallery-dl that referenced this issue May 10, 2020
mikf pushed a commit that referenced this issue May 10, 2020
* Link configuration examples in the intro, see #712

* Clarify overriding conf files by options, see #678
@Vrihub
Copy link
Contributor Author

Vrihub commented Nov 30, 2020

I guess this issue can be closed

@Vrihub Vrihub closed this as completed Nov 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants