commit f3a699cfc798a0ad2ff1842e6e9797bf81177a16 Author: Andrew Davidson Date: Sat Oct 2 21:15:22 2021 -0700 initial commit diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..d5196f9 --- /dev/null +++ b/Pipfile @@ -0,0 +1,12 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +pickledb = "*" + +[dev-packages] + +[requires] +python_version = "3.9" diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000..6ec1021 --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,28 @@ +{ + "_meta": { + "hash": { + "sha256": "84bbdcbaa4485132637e33fc1537e6010cc822a1faeb127116aeb7cd78ea59d0" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.9" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "pickledb": { + "hashes": [ + "sha256:ec6973e65d7d112849e78ce522840aa908efb2523470bb8ce5c7942310192240" + ], + "index": "pypi", + "version": "==0.9.2" + } + }, + "develop": {} +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..c43e092 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +#par2_photos.py diff --git a/lib/par2 b/lib/par2 new file mode 100755 index 0000000..e04cd8a Binary files /dev/null and b/lib/par2 differ diff --git a/par2_photos.py b/par2_photos.py new file mode 100644 index 0000000..8c679e3 --- /dev/null +++ b/par2_photos.py @@ -0,0 +1,38 @@ +from pathlib import Path +import pickledb +import subprocess + +PATH = Path("/data/backup/Photos") +PAR2_DB = PATH.joinpath(".par2.db") + +db = pickledb.load(PAR2_DB, False) + +extensions = { + ".gif", + ".jpg", + ".jpeg", + ".dng", + ".cr2", + ".orf", + ".nef", + ".psd", + ".png", + ".heic", + ".heif", + ".hevc", + ".mp4", +} + +files = list(PATH.rglob("*")) + +for file in files: + if file.suffix.lower() in extensions: + rel = str(file.relative_to(PATH)) + if not db.exists(rel): + result = subprocess.call(["lib/par2", "create", str(file)]) + if result == 0: + db.set(rel, "done") + else: + continue + +db.dump()