๐ซ๐ท 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...
- ๐ต 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
The project follows a layered architecture with separation between business logic and interface:
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.Abstractions10.0.1Microsoft.Extensions.Logging.Abstractions10.0.1SharpZipLib1.4.2 (zlib decompression)
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.Cli0.53.1Serilog4.3.0 + extensionsdotenv.net4.0.0
- .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...
cd MusicParser
dotnet build-
Copy the
.env.examplefile to.env:cp .env.example .env
-
Edit
.envand add the 16-character AES decryption key:MUSICDB_AES_KEY=ABCDEFGHUILDFK
Note: This key is used by Apple Music to encrypt
Library.musicdbfiles.
Display general library information:
dotnet run --project MusicParser.App -- info
dotnet run --project MusicParser.App -- info /path/to/Library.musicdbExample 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 โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
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 20Options:
--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 โ
โ ...โ โ โ โ
โฐโโโโดโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโดโโโโโโโโโโฏ
Display ratings distribution and track examples by star level:
dotnet run --project MusicParser.App -- ratings
dotnet run --project MusicParser.App -- ratings --count 20Options:
--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 โ
โ ...โ โ โ โ
โฐโโโโดโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโดโโโโโโโโโโโฏ
Display like/dislike statistics with distinction between different states:
dotnet run --project MusicParser.App -- likes
dotnet run --project MusicParser.App -- likes --examples 20Options:
--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 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 two decrypted MusicDB files byte by byte, useful for analyzing format differences:
dotnet run --project MusicParser.App -- compare file1.musicdb file2.musicdbUsage:
- Analyze differences between two library versions
- Display offsets where bytes differ
- Show context around differences
- Useful for reverse engineering the format
Dump decrypted content at a specific offset (debug tool):
dotnet run --project MusicParser.App -- dump-offset /path/to/Library.musicdb 0x2214Usage:
- 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 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();The Library.musicdb file format is a proprietary binary format used by Apple Music (formerly iTunes). It consists of:
- Unencrypted header (hfma) containing metadata
- Encrypted payload with AES-128 ECB
- Compressed data with zlib
The format is partially documented:
Detailed documentation is available in the docs/ folder:
- MUSICDB_FORMAT_FR.md - French documentation
- MUSICDB_FORMAT_EN.md - English documentation
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
dotnet testThe 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.
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
Contributions are welcome! Feel free to:
- Fork the project
- Create a branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
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.
- 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)
- Format documentation: Gary Vollink
- iTunes ITL reference: jeanthom/libitlp
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