Skip to main content

Lysergic

Lysergic is a directory scanning tool. It allows you to analyze file systems, compute file hashes, and extract metadata. It includes support for multi-threading and optional Magika integration for file type detection, plus basic embedded media metadata extraction.

Installation

You can install Lysergic using pip:

pip install lysergic

For Magika support, install with the 'magika' extra:

pip install lysergic[magika]

Optional metadata extractors

Lysergic can extract some embedded metadata from media files. Install extras to enable:

pip install lysergic[media]       # mutagen: MP3/ID3, MP4/M4A/M4B, FLAC/OGG/Opus, APE, WAV
pip install lysergic[video]       # pymediainfo: MKV (and enrich MP4/MOV)
pip install lysergic[ebooks]      # ebooklib: EPUB

Or install all media support at once:

pip install lysergic[media,video,ebooks]

Then run with --metadata to include both filesystem metadata and embedded media tags:

lsd ~/media --metadata

Example output with media tags:

{
  "relative_path": "song.mp3",
  "size": 5242880,
  "extension": "mp3",
  "metadata": { ... },
  "media_tags": {
    "container": "mp3",
    "tag_format": "id3",
    "duration_ms": 213045,
    "has_cover_art": true,
    "fields": {
      "title": "Song Title",
      "artist": "Artist Name",
      "album": "Album Name",
      "track": 1,
      "track_total": 12,
      "date": "2024"
    }
  }
}

Command Line Usage

After installation, you can use Lysergic from the command line with the lsd command:

lsd /path/to/directory

Optional arguments:

  • -o, --output FILE: Specify output file (default: stdout)
  • -c, --compress: Compress output with gzip
  • -m, --metadata: Include filesystem metadata and (if optional deps are installed) embedded media tags
  • -t, --threads N: Number of threads to use (default: 1)
  • --magika: Use Magika for file type detection
  • --eta: Estimate processing time
  • --no-progress: Disable progress bars
  • --salt STRING: Salt to prepend to file contents before hashing

Example:

lsd /home/user/documents -o output.jsonl -c -m -t 4 --magika

This command will scan the /home/user/documents directory, include metadata, use 4 threads, enable Magika, and save the compressed output to output.jsonl.gz.

Python Module Usage

You can also use Lysergic as a Python module in your scripts:

from lysergic import LSD

# Initialize LSD
lsd = LSD("/path/to/directory", include_metadata=True, num_threads=4, use_magika=True)

# Process the directory and iterate over results
for file_info in lsd.process_directory():
    print(file_info)

# Or process and save to a file
lsd.process_and_save("output.jsonl", compress=True)

# Estimate processing time
estimate = lsd.estimate_processing_time()
print(f"Estimated time: {LSD.format_time(estimate['total_estimated_time'])}")

License

This project is licensed under the Creative Commons Zero v1.0 Universal (CC0-1.0) License. This means you can copy, modify, distribute, and perform the work, even for commercial purposes, all without asking permission.

Release files for lysergic 0.2.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 lysergic 0.2.0
File Size Uploaded
lysergic-0.2.0.tar.gz 15.5 kB Details

Built distribution (wheel)

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

Total release size: 30.9 kB

Release files / lysergic-0.2.0.tar.gz

Download URL lysergic-0.2.0.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
dfeae3d2d2d4ff4a9e2a483ed908d44c49907dc26bfab68230537ba0edc6fdfd
BLAKE2b-256 checksum
How to use checksums
0ed709b4739e278c46a6fbb9ff96b924c300e4fd86807a742034002c5798ba1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / lysergic-0.2.0-py3-none-any.whl

Download URL lysergic-0.2.0-py3-none-any.whl
Size 15.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
36f4dcf948fd08288b25f2d49cf14c5976439661cef4ddb522759e86fb8795e2
BLAKE2b-256 checksum
How to use checksums
c51a87083c126892d3910b641262538c1ec5f8d770479087c5fcd88a4bb9143e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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