{"library":"pyobjc-framework-ituneslibrary","title":"PyObjC iTunesLibrary Framework","description":"This library provides Python bindings for Apple's iTunesLibrary.framework on macOS, allowing Python applications to read and interact with the user's Music or iTunes library database. It's part of the larger PyObjC project, which wraps many macOS frameworks. The library is actively maintained, with frequent releases synchronised with macOS SDK updates and Python version compatibility changes.","language":"python","status":"active","last_verified":"Sat May 16","install":{"commands":["pip install pyobjc-framework-ituneslibrary"],"cli":null},"imports":["from iTunesLibrary import ITLibrary"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom iTunesLibrary import ITLibrary\n\ndef get_itunes_library_info():\n    \"\"\"\n    Retrieves and prints basic information from the user's Music library.\n    Requires 'Full Disk Access' for the Python application in macOS System Settings.\n    \"\"\"\n    try:\n        # API Version 1 is generally current for basic access\n        library = ITLibrary.libraryWithAPIVersion_error_(1, None)\n        if library:\n            print(f\"Library Name: {library.applicationDisplayName()}\")\n            print(f\"Total Tracks: {len(library.allMediaItems())}\")\n            print(f\"Number of Playlists: {len(library.allPlaylists())}\")\n\n            # Example: Iterate through first 3 tracks\n            print(\"\\nFirst 3 Tracks:\")\n            for i, item in enumerate(library.allMediaItems()):\n                if i >= 3:\n                    break\n                title = item.title()\n                artist = item.artist().name() if item.artist() else \"Unknown Artist\"\n                album = item.album().title() if item.album() else \"Unknown Album\"\n                print(f\"- Title: {title}, Artist: {artist}, Album: {album}\")\n                \n                # Get file path if available\n                if item.location():\n                    file_path = os.fspath(item.location()) # Requires PyObjC 10.1+\n                    # print(f\"  Path: {file_path}\") # Uncomment to see paths\n        else:\n            print(\"Failed to load iTunes Library.\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")\n        print(\"\\nNote: Accessing the iTunes/Music Library typically requires 'Full Disk Access' for your Python application (or its parent process like Terminal/IDE) in macOS System Settings > Privacy & Security.\")\n\nif __name__ == \"__main__\":\n    get_itunes_library_info()","lang":"python","description":"This quickstart demonstrates how to load the user's iTunes/Music library and print some basic information about it. It uses the `ITLibrary` class to access media items and playlists. Note the requirement for macOS 'Full Disk Access' to prevent permission errors.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-16","installed_version":null,"pypi_latest":"12.1","is_stale":null,"summary":{"python_range":"3.10–3.9","success_rate":0,"avg_install_s":null,"avg_import_s":null,"wheel_type":null},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pyobjc-framework-ituneslibrary","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pyobjc-framework-ituneslibrary","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3.4,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pyobjc-framework-ituneslibrary","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pyobjc-framework-ituneslibrary","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3.1,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pyobjc-framework-ituneslibrary","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pyobjc-framework-ituneslibrary","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pyobjc-framework-ituneslibrary","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pyobjc-framework-ituneslibrary","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":2.8,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pyobjc-framework-ituneslibrary","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pyobjc-framework-ituneslibrary","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3.9,"import_time_s":null,"mem_mb":null,"disk_size":null}]}}