Package: metaindex
metaindexmetaindex allows you to find files based on metadata information.For example, if you want to find all pictures that are have a certain width,
you could do this:metaindex find mimetype:image resolution:1200xThe following file formats are supported out of the box (although they might
need additional python packages, see <#Installation>):images (png, jpg, etc.; whatever is supported byPillow)audio (mp3, m4a, ogg, etc.; whatever is supported bymutagen)OpenDocument (odt, ods, etc.)Office Open XML (docx, pptx, xlsx)pdfhtmlepubabcmusic notationcbz (throughComicInfo.xml)gpxfiletags in the style ofKarl Voit's filetagsInstallationTo install metaindex either install it directly through pypi:pip install metaindexOr clone the repository and install that then through pip:git clone https://codeberg.org/vonshednob/metaindex
cd metaindex
pip install .Most modules are optional. If you, for example, want to use metaindex for audio
files and PDFs, you will have to install it like this:pip install metaindex[pdf,audio]or, for the cloned repository:pip install .[pdf,audio]These modules exist for indexing:pdf, for PDF files,audio, any type of audio/music file,image, any type of image file,video, any type of video file (overlaps somewhat withaudio),ebook, ebooks and comic book formats,xdg, support for XDG (if you use Linux, just add it),yaml, extra metadata in YAML format,ocr, find and extract text from images with tesseract (you must have
tesseract installed for this to work).In case you just want everything, this is your install command:pip install .[all]There is also an experimental FuseFS filesystem. To be able to use it, you
will have to specifyfuseas an additional module:pip install .[all,fuse]Server dependenciesIf you just want to connect to another instance of the metaindex server,
you are ready to go.More likely though you will have to installXapianand its Python3 bindings. Please follow the usual way of your OS to install
both.For example, on Archlinux you'dpacman -S xapian python-xapian. On
debian-likes it would beapt install python3-xapian.UsageBefore you can use metaindex to search for files, you have to initialize the
cache by telling it where your files to index are, for example:metaindex index --recursive --index ~/PicturesAfterwards you can start searching for files by metadata, like this:metaindex findSearchingSearch queries for use withmetaindex findallow you to searchfor files that have a metadata tag:metaindex find resolution:for files that have a metadata tag with a certain value:metaindex find title:"dude, where is my car"for files that have any metadata tag with a certain value:metaindex find "just anything"Each value that you provide is actually a case insensitive regular expression.Usage from PythonTo use the metaindex infrastructure from Python, you should instantiate aCacheand run queries against it (withfind).Cache.findwill return an iterable ofCacheEntryinstances, consisting ofpath, the location in the file system where that file was last seenmetadata, a multidict of all metadatalast_modified, the timestamp when the file was last modified on disk (to
the knowledge of the cache)You can just iterate over theCacheEntryinstances to get theirtag, valuetuples.To use the user's preferences, it's a good idea to load their configuration.
Here's an example snippet that'll do both things:frommetaindex.configurationimportloadfrommetaindeximportCacheconfig=load()cache=Cache(config)searchquery='mimetype:image'forentryincache.find(searchquery):print(entry.path)