diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..7a73a41 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/build_hashdict.pickle b/build_hashdict.pickle new file mode 100644 index 0000000..256380e Binary files /dev/null and b/build_hashdict.pickle differ diff --git a/cmp_by_hash.py b/cmp_by_hash.py new file mode 100644 index 0000000..4bbe721 --- /dev/null +++ b/cmp_by_hash.py @@ -0,0 +1,70 @@ +#!python3 +# Created 18 Sep 2019 +# @author: andreas + +""" Module: Main Template """ + +from argparse import ArgumentParser +import logging +import sys +import os +import hashlib +from pathlib import Path +import datetime as dt +import pickle +import shutil + +LOG = logging.getLogger() +PROXY_DIR = "." + + +def cli(argv=None): + # command line interface + if argv is None: + argv = sys.argv + LOG.info("%s %s", os.path.basename(argv[0]), " ".join(argv[1:])) + parser = ArgumentParser(description="Module Template") + parser.add_argument("--src") + parser.add_argument("--dest") + args = parser.parse_args(argv[1:]) + argd = vars(args) + # arguments + for k, v in argd.items(): + print(k, v) + # feature + srcd = build_hashdict(Path(args.src)) + destd = build_hashdict(Path(args.dest)) + srch = set(srcd.keys()) + desth = set(destd.keys()) + xor_hashes = srch ^ desth + for h in xor_hashes: + if h in srcd: + print(srcd[h]) + for h in xor_hashes: + if h in destd: + print(destd[h]) + LOG.info("done") + return 0 + + +def build_hashdict(base): + files_by_hash = dict() + for fp in base.glob("**/*.jpg"): + h = file_hash(fp) + files_by_hash[h] = fp + return files_by_hash + + +def file_hash(filepath): + h = hashlib.sha256() + with filepath.open("rb") as fh: + h.update(fh.read()) + return h.digest() + + +if __name__ == "__main__": + logging.Formatter.default_time_format = '%H:%M:%S' + logging.Formatter.default_msec_format = '%s.%03d' + logging.basicConfig(level=logging.DEBUG, + format='%(asctime)s [%(process)i] %(levelname).4s %(module)s.%(funcName)s: %(message)s') + sys.exit(cli()) diff --git a/ren_triage.py b/ren_triage.py index 85c9cf4..f77384f 100644 --- a/ren_triage.py +++ b/ren_triage.py @@ -1,4 +1,4 @@ -#!python3 +#!python # https://github.com/hMatoba/Piexif # http://ce3wiki.theturninggate.net/doku.php?id=file_name_convention @@ -112,10 +112,10 @@ def rename(old, new): for daydir in Path(SRC).iterdir(): if not daydir.is_dir(): continue - if daydir.name != "Aquaris U Plus": + if daydir.name != "Sony a5100": continue print(f"[{daydir.name}] -------------------------------------------------") mo = re.match("(?P
\S*)\s?(?P.*)", daydir.name) md = mo.groupdict() title = md['title'] - recurse(daydir, md, camera="Aquaris U Plus") + recurse(daydir, md) diff --git a/transcode-ricoh.py b/transcode-ricoh.py new file mode 100644 index 0000000..0bc1070 --- /dev/null +++ b/transcode-ricoh.py @@ -0,0 +1,61 @@ +#!python3 +# Created 5 Jul 2019 Andreas Balogh +# @author: baloan + +""" Module: Main Template """ + +from argparse import ArgumentParser +import logging +import sys +import os +from pathlib import Path + +LOG = logging.getLogger() + + +def transcode_dir(src, dest): + pass + + +def transcode_one(src, dest): + # set DFB="C:\Users\Andreas\AppData\Local\Programs\RicohTheta\resources\tools\dualfishblender\win\DualfishBlender.exe" + # %DFB% "%~1.MP4" "er\%~1_er.mp4" + pass + + +def gui(): + pass + + +def cli(argv=None): + # command line interface + if argv is None: + argv = sys.argv + LOG.info("%s %s", os.path.basename(argv[0]), " ".join(argv[1:])) + parser = ArgumentParser(description="Module Template") + parser.add_argument("--action", help="mock action verb") + parser.add_argument("--database", help="database connection") + parser.add_argument("--config_file", help="json filepath, not used by mock") + args = parser.parse_args(argv[1:]) + argd = vars(args) + # source directory tree root + # destination directory tree root + # location of dualfishblender + + # arguments + for k, v in argd.items(): + print(k, v) + # enviroment + for k, v in os.environ.items(): + print(k, v) + # feature + LOG.info("done") + return 0 + + +if __name__ == "__main__": + logging.Formatter.default_time_format = '%H:%M:%S' + logging.Formatter.default_msec_format = '%s.%03d' + logging.basicConfig(level=logging.DEBUG, + format='%(asctime)s [%(process)i] %(levelname).4s %(module)s.%(funcName)s: %(message)s') + sys.exit(cli())