Overview
========
This is just a very simple inotify monitor for "dropbox" style folders. What it
does is you give it a JSON config file and some directories and it will go and
find all the files in the directories and execute ``shutil`` operations on them
(by default ``copy2`` which means the file is copied along with the metadata)
to the configured location.
Installing
==========
* Option 1: Clone this repo and ``pip install .`` (bleeding edge)
* Option 2: Run ``pip install shotfirst`` (released)
Configuration
=============
With the following configuration file ``shotfirst.json``::
{
"image/jpeg, image/gif, image/png": {
"mask": "%Y/%m/%d",
"target": "/tmp/foo/pics",
"handler": "shotfirst.handlers.exif_image_handler"
},
"video/webm": {
"target": "/tmp/foo/videos",
"operation": "move",
"mask": "%Y/%m/%d",
"handler": "shotfirst.handlers.video_handler"
},
"application/pdf": {
"target": "/tmp/foo/docs",
"operation": "movereplace",
"handler": "shotfirst.handlers.pdf_handler",
"mask": "%Y/%m"
}
}
``shotfirst shotfirst.json /tmp/inbox`` will:
#. Monitor the ``/tmp/inbox`` folder for files
#. Copy all GIF, JPEG, and PNG images found to a directory ``/tmp/foo/pics``
and use the EXIF metadata from the image to figure out the sub-folder
structure (which is year/month/day)
#. Move all the WebM videos to a directory named ``/tmp/foo/videos`` based on
the video metadata, if available. Otherwise will fall back to the file
system meta data.
#. Copy all PDF files to a directory ``/tmp/foo/docs`` based on the PDF
metadata if available. If the file was somehow imported previously,
overwrite with the newly discovered file
Running in a container
======================
There's a published container image, to run you will have to mount your
configuration file and your input and output folders, for example::
podman run --rm -it -v `pwd`/myconfig:/etc/shotfirst.json -v `pwd`/input:/inbox:rw -v `pwd`/output:/outbox:rw thekad/shotfirst:latest
And adjust your configuration appropriately to output the files to
subdirectories under ``/outbox``.
.. NOTE::
Write permissions on the monitored volumes is only needed if you will be
moving files instead of just copying
If you want to monitor multiple directories, you can mount them as volumes and
then set the ``SDIRS`` environment variable, like this::
podman run --rm -it -v /opt/dropbox1:/inbox1 -v /opt/dropbox2:/inbox2 -e SDIRS="/inbox1 /inbox2" thekad/shotfirst:latest
Raw data
{
"_id": null,
"home_page": "https://gitlab.com/kad/shotfirst",
"name": "shotfirst",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": "inotify, backup",
"author": "Jorge Gallegos",
"author_email": "kad@blegh.net",
"download_url": "https://files.pythonhosted.org/packages/a0/a2/c41fc9cc40f0b25c5984566f5d51ef1cea47357e518cc4613c9e482eb169/shotfirst-0.12.3.tar.gz",
"platform": null,
"description": "Overview\n========\n\nThis is just a very simple inotify monitor for \"dropbox\" style folders. What it\ndoes is you give it a JSON config file and some directories and it will go and\nfind all the files in the directories and execute ``shutil`` operations on them\n(by default ``copy2`` which means the file is copied along with the metadata)\nto the configured location.\n\n\nInstalling\n==========\n\n* Option 1: Clone this repo and ``pip install .`` (bleeding edge)\n* Option 2: Run ``pip install shotfirst`` (released)\n\n\nConfiguration\n=============\n\nWith the following configuration file ``shotfirst.json``::\n\n {\n \"image/jpeg, image/gif, image/png\": {\n \"mask\": \"%Y/%m/%d\",\n \"target\": \"/tmp/foo/pics\",\n \"handler\": \"shotfirst.handlers.exif_image_handler\"\n },\n \"video/webm\": {\n \"target\": \"/tmp/foo/videos\",\n \"operation\": \"move\",\n \"mask\": \"%Y/%m/%d\",\n \"handler\": \"shotfirst.handlers.video_handler\"\n },\n \"application/pdf\": {\n \"target\": \"/tmp/foo/docs\",\n \"operation\": \"movereplace\",\n \"handler\": \"shotfirst.handlers.pdf_handler\",\n \"mask\": \"%Y/%m\"\n }\n }\n\n``shotfirst shotfirst.json /tmp/inbox`` will:\n\n#. Monitor the ``/tmp/inbox`` folder for files\n#. Copy all GIF, JPEG, and PNG images found to a directory ``/tmp/foo/pics``\n and use the EXIF metadata from the image to figure out the sub-folder\n structure (which is year/month/day)\n#. Move all the WebM videos to a directory named ``/tmp/foo/videos`` based on\n the video metadata, if available. Otherwise will fall back to the file\n system meta data.\n#. Copy all PDF files to a directory ``/tmp/foo/docs`` based on the PDF\n metadata if available. If the file was somehow imported previously,\n overwrite with the newly discovered file\n\nRunning in a container\n======================\n\nThere's a published container image, to run you will have to mount your\nconfiguration file and your input and output folders, for example::\n\n podman run --rm -it -v `pwd`/myconfig:/etc/shotfirst.json -v `pwd`/input:/inbox:rw -v `pwd`/output:/outbox:rw thekad/shotfirst:latest\n\nAnd adjust your configuration appropriately to output the files to\nsubdirectories under ``/outbox``.\n\n.. NOTE::\n Write permissions on the monitored volumes is only needed if you will be\n moving files instead of just copying\n\nIf you want to monitor multiple directories, you can mount them as volumes and\nthen set the ``SDIRS`` environment variable, like this::\n\n podman run --rm -it -v /opt/dropbox1:/inbox1 -v /opt/dropbox2:/inbox2 -e SDIRS=\"/inbox1 /inbox2\" thekad/shotfirst:latest\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Monitor a number of directories for files and copy/move them",
"version": "0.12.3",
"project_urls": {
"Homepage": "https://gitlab.com/kad/shotfirst"
},
"split_keywords": [
"inotify",
" backup"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d00203a692af197234db54c2fd9f7bef5c9cce0dd378523cf455a31f93e4f664",
"md5": "3c027b1f9c30f28af3540435ee0a27e3",
"sha256": "d8817f0d14b65f7c5b15f2a82ac143c13c62e7a9e9d9d4572efa30fa11b498e4"
},
"downloads": -1,
"filename": "shotfirst-0.12.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3c027b1f9c30f28af3540435ee0a27e3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 7392,
"upload_time": "2024-03-27T00:20:50",
"upload_time_iso_8601": "2024-03-27T00:20:50.893457Z",
"url": "https://files.pythonhosted.org/packages/d0/02/03a692af197234db54c2fd9f7bef5c9cce0dd378523cf455a31f93e4f664/shotfirst-0.12.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a0a2c41fc9cc40f0b25c5984566f5d51ef1cea47357e518cc4613c9e482eb169",
"md5": "318b470f3664caee09dfe2c31f20fc74",
"sha256": "6fafdd0e00841df2dece5eb34c8ff8a7ed68143741f0bf3851f2fee0d0ff3b6a"
},
"downloads": -1,
"filename": "shotfirst-0.12.3.tar.gz",
"has_sig": false,
"md5_digest": "318b470f3664caee09dfe2c31f20fc74",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 6421,
"upload_time": "2024-03-27T00:20:52",
"upload_time_iso_8601": "2024-03-27T00:20:52.483017Z",
"url": "https://files.pythonhosted.org/packages/a0/a2/c41fc9cc40f0b25c5984566f5d51ef1cea47357e518cc4613c9e482eb169/shotfirst-0.12.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-27 00:20:52",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "kad",
"gitlab_project": "shotfirst",
"lcname": "shotfirst"
}