Commit d9ddfe88 authored by Halley Pacheco de Oliveira's avatar Halley Pacheco de Oliveira 😊

Darktable XMP

parent ffe862e0
......@@ -60,22 +60,46 @@ for xmpfile in file_list:
try:
L = doc['x:xmpmeta']['rdf:RDF']['rdf:Description']['dc:subject']['rdf:Seq']['rdf:li']
Subject = ",".join(str(x) for x in L)
T = type(L).__name__
if T == 'list':
Subject = ",".join(str(x) for x in L)
elif T == 'str':
Subject = L
else:
Subject = "-"
except:
Subject = "-"
# XMP Lightroom Tag
try:
L = doc['x:xmpmeta']['rdf:RDF']['rdf:Description']['lr:hierarchicalSubject']['rdf:Seq']['rdf:li']
HierarchicalSubject = ",".join(str(x) for x in L)
T = type(L).__name__
if T == 'list':
HierarchicalSubject = ",".join(str(x) for x in L)
elif T == 'str':
HierarchicalSubject = L
else:
HierarchicalSubject = "-"
except:
HierarchicalSubject = "-"
try:
Publisher = doc['x:xmpmeta']['rdf:RDF']['rdf:Description']['dc:publisher']['rdf:Bag']['rdf:li']
except:
Publisher = "-"
try:
Rights = doc['x:xmpmeta']['rdf:RDF']['rdf:Description']['dc:rights']['rdf:Alt']['rdf:li']['#text']
except:
Rights = "-"
(head, tail) = os.path.split(xmpfile)
outfile.write(head + '\t' + tail + '\t' + DerivedFrom + '\t' + Creator + '\t' + \
Title + '\t' + Description + '\t' + \
Subject + '\t' + HierarchicalSubject + '\n')
Subject + '\t' + HierarchicalSubject + '\t' + \
Publisher + '\t' + Rights + '\n')
print('Number of files read:', len(file_list))
outfile.close()
......@@ -13,6 +13,8 @@ CREATE TABLE IF NOT EXISTS `myimgcoll`.`dtxmp` (
`Description` VARCHAR(255) CHARACTER SET utf8,
`Subject` VARCHAR(255) CHARACTER SET utf8, -- Keywords
`HierarchicalSubject` VARCHAR(255) CHARACTER SET utf8,
`Publisher` VARCHAR(255) CHARACTER SET utf8,
`Rights` VARCHAR(255) CHARACTER SET utf8,
UNIQUE (`Directory`, `FileName`)
);
-- **************************************
......@@ -20,7 +22,7 @@ CREATE TABLE IF NOT EXISTS `myimgcoll`.`dtxmp` (
-- Trigger `dtxmp_before_insert` creation
-- **************************************
DELIMITER ;;
CREATE TRIGGER `myimgcoll`.`dtxmp_before_insert`
CREATE TRIGGER `myimgcoll`.`dtxmp_before_insert`
BEFORE INSERT ON `myimgcoll`.`dtxmp`
FOR EACH ROW SET new.Id = UUID_SHORT();;
DELIMITER ;
......@@ -15,12 +15,16 @@ LOAD DATA LOCAL
@Title,
@Description,
@Subject,
@HierarchicalSubject
@HierarchicalSubject,
@Publisher,
@Rights
)
SET
Creator = nullif(@Creator,"-"),
Title = nullif(@Title,"-"),
Description = nullif(@Description,"-"),
Subject = nullif(@Subject,"-"),
HierarchicalSubject = nullif(@HierarchicalSubject,"-")
HierarchicalSubject = nullif(@HierarchicalSubject,"-"),
Publisher = nullif(@Publisher,"-"),
Rights = nullif(@Rights,"-")
;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment