Skip to main content

decryptune

Fast, native M4A (fMP4/CENC) decryptor + MP4 sanitizer + iTunes tagger in one lightweight, self-contained call — a Rust core with a sync/async Python API that replaces the usual chain of external tools (no subprocesses, no ffmpeg, no dependencies) and runs fully GIL-free, so async callers can fan out without blocking the event loop.

Install

pip install decryptune

Standalone (no install) — keep decryptune.py next to the extension binary and pass its path: DecrypTune("./libdecryptune.so")

From source (needs Rust 1.85+ and Python 3.12+): pip install maturin && maturin build --release — this is also the macOS path (it builds and runs the same; prebuilt wheels and zips ship for Linux and Windows).

Usage

from decryptune import DecrypTune, TuneMeta

# bundled native module (wheel) — or DecrypTune("./libdecryptune.so")
sp = DecrypTune()

sp.proc(
    input="track.m4a",           # bytes / bytearray / memoryview / path
    out="out.m4a",               # destination path; None → the processed bytes are returned
    key="<32 hex>",              # None → fix-only pass (headers sanitized, payload untouched)
    kid="<32 hex>",              # verified against the file's tenc; ignored without key
    meta=TuneMeta(
        title="Song",
        artists=["A"],
        isrc="...",
        cover="cover.jpg",       # bytes or path — JPEG/PNG; oversized JPEGs shrink to ≤1000px
        # date=..., album=..., genre=..., lyrics=..., composer=...,
        # track=..., track_total=..., disc=..., disc_total=...
    ),
    strict=True                  # raise (code 8, per-fragment chi² evidence) when a fragment
)                                # decrypts to statistical noise — a wrong/fake key

# async twin — same options, same result:
out_bytes = await sp.aproc(...)

Rules that hold for both proc and aproc:

  • Every parameter is keyword-only.
  • out is a path → the file is written atomically (tmp + rename) and None is returned; out is None → the processed bytes are returned.
  • key=None → fix-only pass: headers sanitized, audio payload untouched.
  • A meta wipes the existing tag block and rebuilds it solely from the given fields — None / 0 / empty values are skipped; without meta the original metadata passes through untouched.
  • Any problem raises DecrypTuneError with a stable numeric code (1–13) and a message authored in the native core: 1 invalid key · 2 invalid kid · 3 input not found · 4 not an MP4 · 6 write failed · 7 KID mismatch · 8 corrupt audio detected · 9 bad input type · 10 bad out type · 11 tags need a fragmented file · 12 bad cover · 13 cover file not found.

Benchmark

Real 3.0MB fragmented track, Intel i7-11800H (8C/16T), WSL2, v1.1.0:

scenario result
decrypt + fix, strict (bytes in/out) 3.7 ms median — ~0.8 GB/s
fix-only pass (no key) 1.7 ms
full tags + cover resize (877KB JPEG) 101 ms
32 calls: sequential → asyncio.gather 74 ms → 29 ms (×2.5)
event-loop max lag under 8 concurrent heavy calls < 4 ms

License

MIT — see LICENSE.

Metadata

Release files for decryptune 1.1.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 decryptune 1.1.0
File Size Uploaded
decryptune-1.1.0.tar.gz 361.3 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for decryptune 1.1.0
File
decryptune-1.1.0-cp312-abi3-win_arm64.whl CPython 3.12 abi3 Windows ARM64 Details
decryptune-1.1.0-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details
decryptune-1.1.0-cp312-abi3-manylinux_2_28_x86_64.whl CPython 3.12 abi3 Linux glibc 2.28+ x86-64 Details
decryptune-1.1.0-cp312-abi3-manylinux_2_28_aarch64.whl CPython 3.12 abi3 Linux glibc 2.28+ ARM64 Details

Total release size: 2.2 MB

Release files / decryptune-1.1.0.tar.gz

Download URL decryptune-1.1.0.tar.gz
Size 361.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5e1aae2d1b968c184248e9440ece915c239e5a8476c2eebdbb54f7462b727194
BLAKE2b-256 checksum
How to use checksums
84628bc7321ebb6e6d10e4b617e741bc4c809a667aad23b87f1bff0ba05cbdea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Release files / decryptune-1.1.0-cp312-abi3-win_arm64.whl

Download URL decryptune-1.1.0-cp312-abi3-win_arm64.whl
Size 408.1 kB
Tags CPython 3.12 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
22f07b8eb10e29adf4c9c328a847302cf0422b1e28899eacd246a5fa0497b590
BLAKE2b-256 checksum
How to use checksums
250a13e83c1fc5a95beb8c21ce9c6d134445d1b07a75fcf938e1ed79f6b2c9ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Release files / decryptune-1.1.0-cp312-abi3-win_amd64.whl

Download URL decryptune-1.1.0-cp312-abi3-win_amd64.whl
Size 435.0 kB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
ab40a027e9001212b373a4e4afa631a1eb6a77f381eacce44dd37f08245a8474
BLAKE2b-256 checksum
How to use checksums
8406481e61015bad2db03b0e21456309cd1831ee77a955d7264d24a9d811558f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Release files / decryptune-1.1.0-cp312-abi3-manylinux_2_28_x86_64.whl

Download URL decryptune-1.1.0-cp312-abi3-manylinux_2_28_x86_64.whl
Size 501.3 kB
Tags CPython 3.12 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
1d9b53bba03fc9cae68869acd0cb79e66ceeadf6f44e266c41f08ffc84251830
BLAKE2b-256 checksum
How to use checksums
0fe1bcfa2e3b61243009a2bdce9294acd4bd515ffe4859832a12c99f5e74eea7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Release files / decryptune-1.1.0-cp312-abi3-manylinux_2_28_aarch64.whl

Download URL decryptune-1.1.0-cp312-abi3-manylinux_2_28_aarch64.whl
Size 475.2 kB
Tags CPython 3.12 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
1657b1f22f675b2d5433d7bec3e1be2de4aaccc66d7cac5a5354e16cd8549902
BLAKE2b-256 checksum
How to use checksums
69022846b53f8e583f8a737278b1a7d0a49b8aee6a4e2ea7ab15c732e5ad7053
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.

Transparency log

Release history Release notifications | RSS feed

1.1.2

5 release files

1.1.1

5 release files

This release

1.1.0 This release

5 release files

1.0.0

5 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