AppMusicLibParser 1.0.1
dotnet add package AppMusicLibParser --version 1.0.1
NuGet\Install-Package AppMusicLibParser -Version 1.0.1
<PackageReference Include="AppMusicLibParser" Version="1.0.1" />
<PackageVersion Include="AppMusicLibParser" Version="1.0.1" />
<PackageReference Include="AppMusicLibParser" />
paket add AppMusicLibParser --version 1.0.1
#r "nuget: AppMusicLibParser, 1.0.1"
#:package AppMusicLibParser@1.0.1
#addin nuget:?package=AppMusicLibParser&version=1.0.1
#tool nuget:?package=AppMusicLibParser&version=1.0.1
MusicParser
๐ซ๐ท 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.Abstractions10.0.1Microsoft.Extensions.Logging.Abstractions10.0.1SharpZipLib1.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.Cli0.53.1Serilog4.3.0 + extensionsdotenv.net4.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
Copy the
.env.examplefile to.env:cp .env.example .envEdit
.envand add the 16-character AES decryption key:MUSICDB_AES_KEY=ABCDEFGHUILDFKNote: This key is used by Apple Music to encrypt
Library.musicdbfiles.
๐ 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:
- 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
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:
- 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
๐ 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
- Format documentation: Gary Vollink
- iTunes ITL reference: jeanthom/libitlp
๐ 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.
๐ Useful Links
Made with โค๏ธ for Apple Music lovers and reverse engineering enthusiasts
| Product | Versions 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. |
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.1)
- SharpZipLib (>= 1.4.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release with full MusicDB parsing support.