AppMusicLibParser 1.0.1

dotnet add package AppMusicLibParser --version 1.0.1
                    
NuGet\Install-Package AppMusicLibParser -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AppMusicLibParser" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AppMusicLibParser" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="AppMusicLibParser" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AppMusicLibParser --version 1.0.1
                    
#r "nuget: AppMusicLibParser, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AppMusicLibParser@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AppMusicLibParser&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=AppMusicLibParser&version=1.0.1
                    
Install as a Cake Tool

MusicParser

.NET License: GPL v3

๐Ÿ‡ซ๐Ÿ‡ท Version franรงaise : README.md

A .NET 8 library and console application to parse Apple Music Library.musicdb files.

MusicParser extracts complete metadata from tracks, albums, artists and playlists from Apple Music's proprietary binary format, including playback statistics, ratings and file paths.

Why this project? The Apple Music application no longer automatically exports the library to XML, making it difficult to develop applications that leverage the music library. AppleScripts being too slow for large libraries, another solution was needed...

โœจ Features

  • ๐ŸŽต Complete parsing: Tracks, albums, artists, playlists
  • ๐Ÿ“Š Playback statistics: Play count, last played date
  • โญ Ratings: Extract star ratings (1-5 stars)
  • ๐Ÿ”— Relationships: Albums โ†’ Artists, Tracks โ†’ Albums/Artists
  • ๐Ÿ“ File paths: Decoded URL extraction
  • ๐Ÿ” AES-128 ECB decryption: Native support for encrypted format
  • ๐Ÿ“ฆ zlib decompression: Automatic extraction of compressed data
  • ๐ŸŽจ Rich CLI: Colorful console interface with Spectre.Console

๐Ÿ—๏ธ Architecture

The project follows a layered architecture with separation between business logic and interface:

MusicParser (Library)

Reusable library containing all parsing logic:

MusicParser/
โ”œโ”€โ”€ Models/              # Data models
โ”‚   โ”œโ”€โ”€ MusicTrack.cs
โ”‚   โ”œโ”€โ”€ Album.cs
โ”‚   โ”œโ”€โ”€ Artist.cs
โ”‚   โ”œโ”€โ”€ Playlist.cs
โ”‚   โ””โ”€โ”€ MusicLibrary.cs
โ”œโ”€โ”€ Parsers/
โ”‚   โ””โ”€โ”€ MusicDbParser.cs # Main binary format parser
โ”œโ”€โ”€ Crypto/
โ”‚   โ””โ”€โ”€ MusicDbDecryptor.cs # AES-128 ECB decryption + zlib
โ”œโ”€โ”€ Services/
โ”‚   โ”œโ”€โ”€ IMusicLibraryService.cs
โ”‚   โ””โ”€โ”€ MusicLibraryService.cs
โ””โ”€โ”€ ServiceCollectionExtensions.cs

Dependencies:

  • Microsoft.Extensions.DependencyInjection.Abstractions 10.0.1
  • Microsoft.Extensions.Logging.Abstractions 10.0.1
  • SharpZipLib 1.4.2 (zlib decompression)

MusicParser.App (Console Application)

Professional CLI application with interactive commands:

MusicParser.App/
โ”œโ”€โ”€ Commands/
โ”‚   โ”œโ”€โ”€ InfoCommand.cs         # Library general information
โ”‚   โ”œโ”€โ”€ StatsCommand.cs        # Detailed statistics with top tracks
โ”‚   โ”œโ”€โ”€ RatingsCommand.cs      # Ratings distribution (stars)
โ”‚   โ”œโ”€โ”€ LikesCommand.cs        # Like/dislike statistics
โ”‚   โ”œโ”€โ”€ SearchCommand.cs       # Track search by title
โ”‚   โ”œโ”€โ”€ CompareCommand.cs      # Byte-by-byte file comparison
โ”‚   โ””โ”€โ”€ DumpOffsetCommand.cs   # Hexadecimal dump at offset (debug)
โ”œโ”€โ”€ Infrastructure/
โ”‚   โ”œโ”€โ”€ TypeRegistrar.cs
โ”‚   โ””โ”€โ”€ TypeResolver.cs
โ””โ”€โ”€ Program.cs

Dependencies:

  • Spectre.Console.Cli 0.53.1
  • Serilog 4.3.0 + extensions
  • dotenv.net 4.0.0

๐Ÿš€ Installation

Prerequisites

  • .NET 8.0 SDK
  • AES decryption key: Not provided with the code for legal reasons. It can be found on the internet with some research...

Build

cd MusicParser
dotnet build

Configuration

  1. Copy the .env.example file to .env:

    cp .env.example .env
    
  2. Edit .env and add the 16-character AES decryption key:

    MUSICDB_AES_KEY=ABCDEFGHUILDFK
    

    Note: This key is used by Apple Music to encrypt Library.musicdb files.

๐Ÿ“– Usage

Console Application

info Command

Display general library information:

dotnet run --project MusicParser.App -- info
dotnet run --project MusicParser.App -- info /path/to/Library.musicdb

Example output:

โ•ญโ”€๐Ÿ“š Apple Music Libraryโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ File: Library.musicdb                         โ”‚
โ”‚ Size: 7,113,718 bytes (6.78 MB)               โ”‚
โ”‚ Last modified: 2026-01-04 11:30:50            โ”‚
โ”‚                                               โ”‚
โ”‚ ๐Ÿ“€ Tracks: 13,162                             โ”‚
โ”‚ ๐Ÿ’ฟ Albums: 1,017                              โ”‚
โ”‚ ๐ŸŽค Artists: 649                               โ”‚
โ”‚ ๐Ÿ“‹ Playlists: 41                              โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
stats Command

Display detailed statistics with most played tracks:

dotnet run --project MusicParser.App -- stats
dotnet run --project MusicParser.App -- stats --top 10
dotnet run --project MusicParser.App -- stats /path/to/Library.musicdb --top 20

Options:

  • --top <COUNT>: Number of most played tracks to display (default: 5)

Example output:

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Category              โ”‚ Value  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Total tracks          โ”‚ 13,162 โ”‚
โ”‚ Albums                โ”‚  1,017 โ”‚
โ”‚ Artists               โ”‚    649 โ”‚
โ”‚ Playlists             โ”‚     41 โ”‚
โ”‚                       โ”‚        โ”‚
โ”‚ Tracks with plays     โ”‚  8,234 โ”‚
โ”‚ Total plays           โ”‚ 45,678 โ”‚
โ”‚ Average plays/track   โ”‚    5.5 โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

๐ŸŽต Top 5 most played tracks
โ•ญโ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ # โ”‚ Title              โ”‚ Artist      โ”‚ Plays   โ”‚
โ”œโ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 1 โ”‚ Song Title         โ”‚ Artist Name โ”‚     123 โ”‚
โ”‚ ...โ”‚                    โ”‚             โ”‚         โ”‚
โ•ฐโ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
ratings Command

Display ratings distribution and track examples by star level:

dotnet run --project MusicParser.App -- ratings
dotnet run --project MusicParser.App -- ratings --count 20

Options:

  • --count <COUNT>: Number of tracks to display per star level (default: 10)

Example output:

โญ Ratings distribution

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Rating        โ”‚ Tracks โ”‚ Percentage  โ”‚ Bar      โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ โญโญโญโญโญ   โ”‚  1,234 โ”‚      15.2%  โ”‚ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ”‚
โ”‚ โญโญโญโญ     โ”‚  2,456 โ”‚      30.3%  โ”‚ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ”‚
โ”‚ โญโญโญ       โ”‚  3,123 โ”‚      38.5%  โ”‚ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ”‚
โ”‚ โญโญ         โ”‚    987 โ”‚      12.2%  โ”‚ โ–ˆโ–ˆโ–ˆโ–ˆ     โ”‚
โ”‚ โญ           โ”‚    312 โ”‚       3.8%  โ”‚ โ–ˆ        โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

โญโญโญโญโญ Examples (10/1,234)
โ•ญโ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ # โ”‚ Title           โ”‚ Artist        โ”‚ Album    โ”‚
โ”œโ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 1 โ”‚ Great Song      โ”‚ Awesome Band  โ”‚ Album X  โ”‚
โ”‚ ...โ”‚                 โ”‚               โ”‚          โ”‚
โ•ฐโ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
likes Command

Display like/dislike statistics with distinction between different states:

dotnet run --project MusicParser.App -- likes
dotnet run --project MusicParser.App -- likes --examples 20

Options:

  • --examples <COUNT>: Number of track examples to display per category (default: 10)

Supported states:

  • โค๏ธ Liked (value 2): Tracks marked as liked
  • ๐Ÿ’” Unliked (value 1): Transitional state after removing a like
  • ๐Ÿ‘Ž Explicitly disliked (value 3): Active dislike
  • โšช Neutral (value 0): Default, no opinion
search Command

Search for a track by title and display complete metadata:

dotnet run --project MusicParser.App -- search "track name"
dotnet run --project MusicParser.App -- search /path/to/Library.musicdb "track name"

Display:

  • Complete metadata (ID, title, artist, album)
  • Rating with star display
  • LikeStatus with emoji and numeric value
  • Playback statistics
  • Audio file path
compare Command

Compare two decrypted MusicDB files byte by byte, useful for analyzing format differences:

dotnet run --project MusicParser.App -- compare file1.musicdb file2.musicdb

Usage:

  • Analyze differences between two library versions
  • Display offsets where bytes differ
  • Show context around differences
  • Useful for reverse engineering the format
dump-offset Command

Dump decrypted content at a specific offset (debug tool):

dotnet run --project MusicParser.App -- dump-offset /path/to/Library.musicdb 0x2214

Usage:

  • Display 128 bytes context around the specified offset
  • Hexadecimal + ASCII format
  • Highlight the exact byte at the offset
  • Essential for debugging parsing and analyzing binary format

Using the Library in Your Code

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using MusicParser;
using MusicParser.Services;

// Configuration with DI
var host = Host.CreateDefaultBuilder()
    .ConfigureServices((context, services) =>
    {
        services.AddMusicParser();
    })
    .Build();

// Using the service
var musicService = host.Services.GetRequiredService<IMusicLibraryService>();
var library = musicService.ParseLibrary("/path/to/Library.musicdb");

// Accessing data
Console.WriteLine($"Tracks: {library.Tracks.Count}");
Console.WriteLine($"Albums: {library.Albums.Count}");
Console.WriteLine($"Artists: {library.Artists.Count}");

// Filter tracks by artist
var beatlesTracks = library.Tracks
    .Where(t => t.Artist?.Contains("Beatles", StringComparison.OrdinalIgnoreCase) == true)
    .ToList();

// Find most played tracks
var topTracks = library.Tracks
    .Where(t => t.PlayCount.HasValue)
    .OrderByDescending(t => t.PlayCount)
    .Take(10)
    .ToList();

๐Ÿ“„ MusicDB Format

The Library.musicdb file format is a proprietary binary format used by Apple Music (formerly iTunes). It consists of:

  1. Unencrypted header (hfma) containing metadata
  2. Encrypted payload with AES-128 ECB
  3. Compressed data with zlib

The format is partially documented:

Detailed documentation is available in the docs/ folder:

Parsed Sections

The parser supports the following sections:

  • ltma: Tracks (itma)

    • Metadata: title, artist, album, duration, genre, year...
    • Statistics: play count, last played, date added...
    • Ratings: star ratings
    • References: links to album/artist
  • ltka: Albums (itka)

    • Title, artist(s), number of tracks
    • Artist references
  • ltra: Artists (itra)

    • Artist name
  • ltpa: Playlists (itpa)

    • Name, type (normal/smart/folder)
    • Parent/child hierarchy
    • Track list

๐Ÿงช Tests

dotnet test

๐Ÿ” Locating the Library.musicdb File

The Library.musicdb file is typically located at:

  • macOS: ~/Music/Music/Music Library.musiclibrary/Library.musicdb
  • Windows: %USERPROFILE%\Music\iTunes\iTunes Library.musiclibrary\Library.musicdb

Note: The exact path may vary depending on your configuration and Apple Music version.

๐Ÿ› ๏ธ Development

Project Structure

MusicParser/
โ”œโ”€โ”€ .github/
โ”‚   โ””โ”€โ”€ copilot-instructions.md
โ”œโ”€โ”€ docs/                       # Format documentation
โ”œโ”€โ”€ libraries-music-samples/    # Test files
โ”œโ”€โ”€ MusicParser/                # Main library
โ”œโ”€โ”€ MusicParser.App/            # Console application
โ”œโ”€โ”€ MusicParser.Tests/          # Unit tests (coming soon)
โ”œโ”€โ”€ .env.example                # Configuration template
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ LICENSE                     # GPLv3 License
โ””โ”€โ”€ README.md

Contributing

Contributions are welcome! Feel free to:

  1. Fork the project
  2. Create a branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“ Logging

The library uses ILogger<T> from Microsoft.Extensions.Logging for flexible logging.

All internal logs (parsing, decryption) are at Debug level for clean console output.

The console application uses Serilog with default configuration at Information level.

โš ๏ธ Known Limitations

  • Parsing is read-only (no writing to Library.musicdb)
  • Some binary fields are not yet decoded
  • Smart playlists (queries) are not interpreted
  • Mainly tested on macOS with Apple Music (recent versions)

๐Ÿ™ Credits

๐Ÿ“œ License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.

Copyright (C) 2026 MusicParser Contributors

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

Made with โค๏ธ for Apple Music lovers and reverse engineering enthusiasts

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 105 1/6/2026
1.0.0 102 1/6/2026

Initial release with full MusicDB parsing support.