sylikc / pyexiftool

PyExifTool (active PyPI project) - A Python library to communicate with an instance of Phil Harvey's ExifTool command-line application. Runs one process with special -stay_open flag, and pipes data to/from. Much more efficient than running a subprocess for each command!
Other
144 stars 17 forks source link

Can output formats be specified using exiftool.ExifToolHelper()? #43

Closed abetomas closed 2 years ago

abetomas commented 2 years ago

Can output formats be specified using exiftool.ExifToolHelper()? I tried the formatting date for CreateDate and it did not work.


Note: using exiftool.ExifTool() applies the date format specified in the common_args list and tagname does not contain groupname.


import exiftool

with exiftool.ExifTool(common_args= ['-r','-s','-d','%Y-%m-%d','-CreateDate']) as et: ... md = et.execute_json("./misc/20190105_153439.mp4") ... print(md) [{'SourceFile': './misc/20190105_153439.mp4', 'CreateDate': '2019-01-21'}]

Thanks again for your help.

sylikc commented 2 years ago

I just pushed out a new release. ExifToolHelper.get_tags() isn't the same as the original get_tag() functionality. I had currently left that functionality in ExifToolAlpha because it can cause some inadvertent behavior.

In v0.4, try doing something like ExifTool.get_tag("*.mp4", "CreateDate") and wonder which is related to which file to get a sense of the problem...

So the functionality you're looking for is ExifToolAlpha.get_tag() . Try that

abetomas commented 2 years ago

Thanks.. I was able to figure this out after a further reading of the documentation. The following worked ok for me:

with exiftool.ExifToolHelper(common_args=['-s',b'-d',b'"%Y-%m-%d %H.%M.%S%z"']) as et:
    metadata = et.get_tags(source_filepath,'CreateDate')