MediaSort is a Python3 web UI that helps you sort media items into folders. The classic use case is to take the many photos and videos produced by a smartphone, and makes sense of them. It also works well for a DSLR.
The workflow is like this, assuming you keep the defaults:
- First, all the files in the input directory are scanned. Each file will be automatically placed into a set. A set is a group of photos, seperated by 3 hours. This means that photos taken relatively close together (in terms of time) will be in the same set. The time is taken from the EXIF of the photo. If there isn't any EXIF, the file is ignored.
- This is then shown in the UI. Six items in each set are shown (the first three and the last three), with each item showing a location (pulled from the EXIF of the photo, and geolocated), plus the date and time. You can then decide what to do with the set.
- You can save with date. This will create a directory in the output folder called
yyyy/yyyy-mm/yyyy-mm-ddd <name>
. It'll then move all the files in the set there. - You can save without date. This will create a directory in the output folder called
<name>
. It'll then move all the files in the set there. - You can delete. This doesn't really delete the files in the set, but instead moves them to the deleted folder.
- Additionally, for each item in a set, you can remove from set. This will detach it, and create a new set. This is useful if you want to split some sets up.
- You can save with date. This will create a directory in the output folder called
- When you save a set with a name, the name is cached. This powers the typeahead, and lets you select the same name again. Note that using the same name multiple times is super common. It will effectively merge a set, assuming they have the same date.
- And as you scrolling, more sets are loaded. If you want to load more photos for a set than the six, you can.
The easiest way is to take the Docker Compose file, modify some of the config, and then execute it. It will start the required Redis server too. Note that the config is very conservative by default. No folders are mapped, and it runs in "dry-run" mode by default.
docker-compose -f docker-compose.yml up
It will then be available at port 8000 by default. If you are running it on your local machine, it is http://localhost:8000
See some configuration options in default_config.py
. Override them with the FLASK_
prefix.
Python 3, plus the modules in requirements.txt
Note you should also have exiftool installed seperately. If you do not, fewer files will be processed - and tests will fail!
The minimum version of exiftool is 12.15. If the correct version is not installed, it will fail silently. (Not sure why...)
For Ubuntu, the minimum version is in 22.04 (jammy) and later. You can download the package directly and install it on earlier versions.
Assumption is a Ubuntu machine. 22.04 will "just work".
Install the dependancies (exiftool may need some help):
pip3 install -r requirements.txt
sudo apt install exiftool
Set the variables:
export FLASK_REDIS_URL="redis://<ip>:<port>/0"
export FLASK_DEBUG=true
Execute:
python3 -m flask --app web_app run
or to have it listen across the network:
python3 -m flask --app web_app run --host=0.0.0.0
If you run Flask in debug mode (via the --debug parameter or using the environment variable like above, then the default_config_dev.py
file is used to set some parameters. Otherwise, default_config.py
is used.
pytest is used. Invoke:
python3 -m pytest
Coverage (and a nice HTML report) is determined:
python3 -m pytest --cov . --cov-branch --cov-report html
Auto-formatting is achieved using Black:
python3 -m black .
And making sure you follow PEP 8 is done with Flake8, with the adjustments that Black recommend.
python3 -m flake8