tinytag is a small, fast, and feature-rich Python library for reading audio file metadata from various formats including MP3, OGG, FLAC, M4A, WAV, and WMA. It supports ID3v1, ID3v2, OGG Vorbis, OGG Opus, M4A/MP4, and more. The current version is 2.2.1, and it maintains an active release cadence with regular updates.
pip install tinytagVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to read metadata from an audio file using TinyTag. It creates a minimal dummy file to ensure the example is runnable, then attempts to extract common tags like artist, title, duration, and bitrate. In a real application, you would replace `dummy_audio_file` with the path to your actual audio file.
Update your code to expect and handle integer values for `tag.disc`, `tag.disc_total`, `tag.track`, and `tag.track_total`.
Adjust your parsing logic for `as_dict()` results to expect list values, e.g., `tag.as_dict()['artist'][0]` instead of `tag.as_dict()['artist']` for single values.
Instead of `TinyTag.get(filepath, ignore_errors=True)`, use a `try...except TinyTagException` block to explicitly handle parsing errors, for example: `from tinytag import TinyTag, TinyTagException; try: tag = TinyTag.get(filepath) except TinyTagException as e: print(f'Error: {e}')`.Upgrade to TinyTag version 2.2.1 or newer to ensure robustness against malformed SYLT data.
Update to TinyTag version 2.1.1 or later to correctly decode ID3 string fields and prevent data corruption.
pip install tinytag
Ensure the audio file is valid and of a supported format (MP3, OGG, FLAC, M4A, WAV, WMA). Wrap TinyTag.get() in a try-except tinytag.TinyTagException block for robust error handling.
Check if the attribute is None before attempting to use it, or provide a default value. Example: artist = tag.artist if tag.artist else 'Unknown Artist'
Verify the file path is correct and that the audio file exists. Use absolute paths or ensure the file is relative to your script's execution directory.
No dependency data recorded yet.