-
-
Notifications
You must be signed in to change notification settings - Fork 991
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
Fix --write-metadata
option to support extractors with datetime
metadata
#251
Conversation
Introduce a GalleryDLJSONEncoder to encode datetime.datetime as ISO 8601 strings.
JFTR, the test failures/errors seems unrelated to this change. Here relevant output:
|
Simplified universal serialization support in json.dump() can be achieved by passing 'default=str', which was already the case in DataJob.run() for -j/--dump-json, but not for the 'metadata' post-processor. This commit introduces util.dump_json() that (more or less) unifies the JSON output procedure of both --write-metadata and --dump-json. (#251, #252)
Thanks for your quick fix, but I'd rather solve this in a slightly different way. Adding a whole JSONEncoder subclass is kind of overkill when passing |
Hello Mike,
Mike Fährmann writes:
Thanks for your quick fix, but I'd rather solve this in a slightly different way.
Adding a whole JSONEncoder subclass is kind of overkill when passing `default=str` to json.dump() does pretty much the some thing. This was already done in the other place where JSON output happens, but for some reason not in the `metadata` post-processor. I've now added a function that gets used in both places, so they should behave the same (523ebc9).
Yes, I agree, that's better and simpler, thank you!
|
When using
--write-metadata
option with extractors that havedatetime
metadatagallery-dl
fails to encode JSON because json.dump() cannot serialize them, e.g.:
This pull request introduce a GalleryDLJSONEncoder that serialize
datetime.datetime objects as ISO 8601 strings.
In the future - if needed - this can be extended to support more
non-basic types.