Exemplo n.º 1
0
    def update(self, tags):
        tag_opts = []
        for tag, content in tags.items():
            content = '' if content is None else unicode(content)
            tag_opt = u"-{tag}={content}".format(tag=tag, content=content)
            tag_opts.append(tag_opt)

        if tag_opts:
            exiftool(self.filename, '-charset', 'iptc=UTF8',
                     '-overwrite_original_in_place', *tag_opts)
Exemplo n.º 2
0
    def __setitem__(self, tag, content):
        if content:
            if isinstance(content, datetime):
                content = self._from_datetime(content)
            else:
                content = unicode(content)
        else:
            content = ''

        tag_opt = u"-{tag}={content}".format(tag=tag, content=content)

        exiftool(self.filename, '-charset', 'iptc=UTF8',
                 '-overwrite_original_in_place', tag_opt)
Exemplo n.º 3
0
def copy_time(src, *dst):
    """Copy create, modify date time and extra tags from src to dst.

    macOS convert video service changes video create, modify date time and drops
    some other tags. Use this to copy these tags from original video file.
    """
    TIME_TAGS = [
        "TrackCreateDate", "TrackModifyDate", "MediaCreateDate",
        "MediaModifyDate", "ModifyDate", "DateTimeOriginal", "CreateDate"
    ]

    tag_values = read_exif_tag(src,
                               TIME_TAGS + list(EXIF_CAMERA_MODEL_TAGS.keys()))
    _canonic_camera_model_tag(tag_values)

    sh.exiftool(_exiftool_tag_option(tag_values),
                dst,
                _out=sys.stdout,
                _err=sys.stderr)
Exemplo n.º 4
0
    def __getitem__(self, tag):
        tag_opt = '-' + tag
        try:
            # try IPTC first
            output = str(exiftool(self.filename, '-charset', 'iptc=UTF8',
                         tag_opt))
            if re.match('Warning', output):
                return None
            output = unicode(output, 'utf8')

        except UnicodeDecodeError:
            output = str(exiftool(self.filename, tag_opt))
            if re.match('Warning', output):
                return None
            output = unicode(output, 'utf8')

        tag = self._tag_re.sub('', output).strip() or None

        if tag and self._datetime_re.match(tag):
            return self._to_datetime(tag)
        return tag
Exemplo n.º 5
0
def get(path):
    """Extract the metadata from a file using exiftool.

    All available groups and fields will be extracted.

    Args:
        file_path (string): File path from which to extract metadata.

    Returns:
        dictonary: False otherwise.

    """
    print('metadata, from: {}'.format(path))
    if os.path.isfile(path):
        output = exiftool('-m', '-G', '-struct', '-s', '-s', '-g', '-json',
                          path).replace('\\u0000', '')
        return json.loads(output)[0]
    else:
        return None
Exemplo n.º 6
0
# s = check_output(['mediainfo', filename])
# print("s = " + str(s))

info = list(sh.mediainfo(filename).split('\n'))

info_dict = {}
print(info)

for item in info:
    #print(item)
    if "Encoded date" in item:
        print(item)
        key, value = item.split(': ')
        info_dict[key.strip()] = value.strip()
        print("Dátum:", value[4:14])

print(info_dict['Encoded date'])

#print(sh.mediainfo('--Inform="Video;%DisplayAspectRatio%"',filename))

info = list(sh.exiftool(filename).split('\n'))
print(info)

process = os.popen('exiftool ' + filename + ' | grep "Create Date"', 'r', 1)

for item in process:
    egysor = item.split(":", 1)[1]
    print("sor:", type(egysor), egysor)

sor = "Media Create Date               : 2017:02:09 08:25:01"
print(sor.split(": ", 1)[1].replace(":", "_").replace(" ", "_"))
Exemplo n.º 7
0
 def get_metadata(self):
     if self.path is not None:
         et_out = exiftool('-struct', '-g', '-J', self.path)
         self.metadata = json.loads(et_out.encode("utf-8", "strict"))[0]
         self.map_metadata()
         self.get_people()