Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions metaSave
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ import os
import re
import sys
import fnmatch
import traceback
from picasa3meta import thumbindex, pmpinfo, iniinfo, exiv2meta, contacts

from codecs import open


def locatedir(pattern,start):
Expand Down Expand Up @@ -124,7 +125,7 @@ def main():
"photo tree and Picasa3 files to another system or have them "\
"remotely mounted with a different path you can use --tweak to "\
"adjust the path. \nexample:\n\t"\
"--tweak '/my/path/Pictures':'/thumbindex/path/Pictures'" )
"--tweak '/my/path/Pictures'::'/thumbindex/path/Pictures'" )
args = parser.parse_args()


Expand Down Expand Up @@ -155,7 +156,7 @@ def main():
os.path.join(args.dest,os.path.basename(source)+".meta"))

if args.tweak != "":
myPath, thumbPath = args.tweak.split(':')
myPath, thumbPath = args.tweak.split('::') # double colon for windows compatability (C:\bla split otherwise)
else:
myPath = ""
thumbPath = ""
Expand Down Expand Up @@ -228,6 +229,7 @@ def main():
iniDir = os.path.dirname(img)
if myPath != "":
pmpDir = iniDir.replace(myPath,thumbPath)
else: pmpDir = iniDir
outDir = iniDir.replace(source,dest)
outBase = os.path.basename(img)
outFile = os.path.join(outDir,outBase+".meta")
Expand All @@ -237,10 +239,10 @@ def main():
except:
pass

oF = open(outFile,"w")
oF = open(outFile,"w", "utf-8")
# pmp index
index = picasaDb.indexOfFile(os.path.join(pmpDir,outBase))
oF.write("pmp.index:%d\n"%index)
oF.write("pmp.index:%d\n"%index)
# pmp info
for K,V in pmpDB.getEntry(index):
oF.write("pmp.%s:%s\n"%(K,V))
Expand Down Expand Up @@ -300,12 +302,16 @@ def main():

# and finally, exiv2 data
for K,V in exiv2meta.EXIV2Meta(img):
V = V or "" # replace NoneType with empty string (avoid NoneType error)
if not isinstance(V, str):
V=", ".join(V) # join lists (like face data)
V = V.encode('string_escape') # escape invalid bytes
oF.write("%s:%s\n"%(K,V))
oF.close()

print "%d files"%count
except:
print "error: ",sys.exc_info()[0],":",sys.exc_info()[1]
traceback.print_exc(file=sys.stdout) # print a full stack trace
return 3

if __name__ == "__main__":
Expand Down