Skip to main content

A directory scanning tool

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lysergic-0.2.0.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lysergic-0.2.0-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file lysergic-0.2.0.tar.gz.

File metadata

  • Download URL: lysergic-0.2.0.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for lysergic-0.2.0.tar.gz
Algorithm Hash digest
SHA256 dfeae3d2d2d4ff4a9e2a483ed908d44c49907dc26bfab68230537ba0edc6fdfd
MD5 59c242934b0b5cd508d305ec6df41009
BLAKE2b-256 0ed709b4739e278c46a6fbb9ff96b924c300e4fd86807a742034002c5798ba1c

See more details on using hashes here.

File details

Details for the file lysergic-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: lysergic-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for lysergic-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 36f4dcf948fd08288b25f2d49cf14c5976439661cef4ddb522759e86fb8795e2
MD5 bdcadba0277a81add16a0f9207c2e58b
BLAKE2b-256 c51a87083c126892d3910b641262538c1ec5f8d770479087c5fcd88a4bb9143e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page