{"id":3295,"library":"tinytag","title":"TinyTag Audio Metadata Reader","description":"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.","status":"active","version":"2.2.1","language":"en","source_language":"en","source_url":"https://github.com/tinytag/tinytag","tags":["audio","metadata","id3","mp3","flac","ogg","m4a","wav"],"install":[{"cmd":"pip install tinytag","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"TinyTag","correct":"from tinytag import TinyTag"}],"quickstart":{"code":"import os\nfrom tinytag import TinyTag\n\n# Create a dummy audio file for demonstration\ndummy_audio_file = 'example.mp3'\nwith open(dummy_audio_file, 'wb') as f:\n    f.write(b'RIFF\\x00\\x00\\x00\\x00WAVEfmt \\x10\\x00\\x00\\x00\\x01\\x00\\x01\\x00\\x44\\xAC\\x00\\x00\\x88\\x58\\x01\\x00\\x02\\x00\\x10\\x00data\\x00\\x00\\x00\\x00')\n\ntry:\n    # In a real scenario, replace 'example.mp3' with your actual audio file path\n    tag = TinyTag.get(dummy_audio_file)\n    print(f\"File: {dummy_audio_file}\")\n    print(f\"Artist: {tag.artist}\")\n    print(f\"Title: {tag.title}\")\n    print(f\"Duration: {tag.duration} seconds\")\n    print(f\"Audio offset: {tag.audio_offset}\")\n    print(f\"Filesize: {tag.filesize} bytes\")\n    print(f\"Bitrate: {tag.bitrate} kBit/s\")\n    print(f\"Genre: {tag.genre}\")\n    print(f\"Year: {tag.year}\")\nexcept Exception as e:\n    print(f\"Error reading tag: {e}\")\nfinally:\n    # Clean up the dummy file\n    if os.path.exists(dummy_audio_file):\n        os.remove(dummy_audio_file)","lang":"python","description":"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."},"warnings":[{"fix":"Update your code to expect and handle integer values for `tag.disc`, `tag.disc_total`, `tag.track`, and `tag.track_total`.","message":"In version 2.0.0, the `disc`, `disc_total`, `track`, and `track_total` fields changed from `str` to `int`. Code expecting string values for these fields will fail.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"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.","message":"Version 2.0.0 changed the behavior of the `as_dict()` method. Values for fields are now returned as lists, even if they contain only a single item.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"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}')`.","message":"The `ignore_errors` parameter for `TinyTag.get()` was deprecated in version 2.0.0. Using this parameter is no longer recommended.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Upgrade to TinyTag version 2.2.1 or newer to ensure robustness against malformed SYLT data.","message":"Prior to version 2.2.1, malformed ID3v2 Synchronized Lyrics (SYLT) strings could cause an infinite loop during tag parsing, leading to application hangs or crashes.","severity":"gotcha","affected_versions":"<2.2.1"},{"fix":"Update to TinyTag version 2.1.1 or later to correctly decode ID3 string fields and prevent data corruption.","message":"Before version 2.1.1, the library incorrectly removed the 'b' character from ID3 string data, leading to corrupted metadata values for certain fields.","severity":"gotcha","affected_versions":"<2.1.1"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}