Skip to main content

metaindex

metaindex 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:1200x

The 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 by Pillow)
  • audio (mp3, m4a, ogg, etc.; whatever is supported by mutagen)
  • OpenDocument (odt, ods, etc.)
  • Office Open XML (docx, pptx, xlsx)
  • pdf
  • html
  • epub
  • abc music notation
  • cbz (through ComicInfo.xml)
  • gpx
  • filetags in the style of Karl Voit's filetags

Installation

To install metaindex either install it directly through pypi:

pip install metaindex

Or 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 with audio),
  • 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 specify fuse as an additional module:

pip install .[all,fuse]

Server dependencies

If you just want to connect to another instance of the metaindex server, you are ready to go.
More likely though you will have to install Xapian and its Python3 bindings. Please follow the usual way of your OS to install both.

For example, on Archlinux you'd pacman -S xapian python-xapian. On debian-likes it would be apt install python3-xapian.

Usage

Before 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 ~/Pictures

Afterwards you can start searching for files by metadata, like this:

metaindex find

Searching

Search queries for use with metaindex find allow you to search

  • for 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 Python

To use the metaindex infrastructure from Python, you should instantiate a Cache and run queries against it (with find).

Cache.find will return an iterable of CacheEntry instances, consisting of

  • path, the location in the file system where that file was last seen
  • metadata, a multidict of all metadata
  • last_modified, the timestamp when the file was last modified on disk (to the knowledge of the cache)

You can just iterate over the CacheEntry instances to get their tag, value tuples.

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:

    from metaindex.configuration import load
    from metaindex import Cache

    config = load()
    cache = Cache(config)

    searchquery = 'mimetype:image'

    for entry in cache.find(searchquery):
        print(entry.path)

Release files for metaindex 2.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for metaindex 2.3.0
File Size Uploaded
metaindex-2.3.0.tar.gz 417.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for metaindex 2.3.0
File Interpreter ABI Platform
metaindex-2.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 538.8 kB

Release files / metaindex-2.3.0.tar.gz

Download URL metaindex-2.3.0.tar.gz
Size 417.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ec6007f74559017747a2003d26134c3cfab02de76c7ba7a02123b0e9818b6f13
BLAKE2b-256 checksum
How to use checksums
9bdf91e6261ab10134d62e221fa72f39e0c5699b0fe6858d7340a49f22f91725
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / metaindex-2.3.0-py3-none-any.whl

Download URL metaindex-2.3.0-py3-none-any.whl
Size 121.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f250d9e0e44c612493ad603c5fb01b4fa79deae68cc3e49359822bbd7f6433c0
BLAKE2b-256 checksum
How to use checksums
f364fd2bb11812da24ae9fc01e3e602f30bfad43ecb13c9e5659962cc09131fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release history Release notifications | RSS feed

This release

2.3.0 This release

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page