A .NET 8 console application to synchronize "liked" tracks from your Apple Music library to iBroadcast.
- π΅ Unidirectional sync: Apple Music β iBroadcast
- β€οΈ Smart "liked" detection: A track is considered "liked" if it has a "Liked" status OR at least 1 star rating
- π― Intelligent matching: Levenshtein distance algorithm with quality scores (title 60% + artist 40%)
- π OAuth2 authentication: Secure Device Code Flow with automatic token refresh
- π Preview mode: See all changes before synchronization (--preview-only)
- π Interactive mode: Confirm uncertain matches (score < 80%)
- β‘ Optimized matching: Artist indexing and caching for fast processing
- πΎ Auto-detection: Automatically finds your iTunes XML or Apple Music library
β οΈ Rate limiting: Built-in delays to respect iBroadcast API limits
Apple Music library parsing is powered by AppMusicLibParser.
Unidirectional synchronization: Apple Music β iBroadcast
A track is considered "liked" on Apple Music if:
LikeStatus == LikedORRating >= 1 star(β₯ 20 on the 0-100 scale)
If liked β ThumbsUp on iBroadcast
Otherwise β NoThumb on iBroadcast
The matcher uses:
- Levenshtein distance for string similarity
- Score: Title (60%) + Artist (40%)
- Quality levels:
- Perfect: 100%
- Excellent: 90-99%
- Good: 80-89%
- Uncertain: < 80% (requires confirmation in interactive mode)
- Artist-based indexing to reduce search space
- String normalization caching
- Early exit on perfect matches
- 500ms delay between API calls to respect rate limits
- .NET 8 SDK
- An iBroadcast account
- iTunes library (XML) or macOS Apple Music app
- Go to media.ibroadcast.com
- Open sidebar > Apps > developer
- Create a new application
- Note your
client_idandclient_secret - If using Apple Music library: obtain the AES decryption key for MusicDB files (not provided here for legal reasons, but findable with some research...)
dotnet buildCopy the example file and fill in your credentials:
cp .env.example .envEdit .env and add your credentials:
IBROADCAST_CLIENT_ID=your_client_id_here
IBROADCAST_CLIENT_SECRET=your_client_secret_here
# Optional if using Apple Music app
MUSICDB_AES_KEY=the_aes_key_here
# Optional: custom library path
# LIBRARY_PATH=/path/to/iTunes Library.xml# Sync command (default)
dotnet run --project IBroadcastStars.App sync [options]
# Info command - Display library information
dotnet run --project IBroadcastStars.App info [options]
# Stats command - Show detailed statistics
dotnet run --project IBroadcastStars.App stats [options]Once .env is configured, simply run:
dotnet run --project IBroadcastStars.App syncexport IBROADCAST_CLIENT_ID=your_id
export IBROADCAST_CLIENT_SECRET=your_secret
export MUSICDB_AES_KEY=the_aes_key_here
dotnet run --project IBroadcastStars.App syncdotnet run --project IBroadcastStars.App sync -- \
--client-id YOUR_CLIENT_ID \
--client-secret YOUR_CLIENT_SECRETOn first run, the app will:
- Display a code and URL
- Ask you to open the URL in your browser
- Enter the displayed code
- Token will be saved in
~/.ibroadcast_token.json
Once authenticated, tokens are automatically refreshed when running the app.
--client-id <id> iBroadcast app Client ID
--client-secret <secret> iBroadcast app Client Secret
--library <path> Path to your music library
(auto-detection if not specified)
--interactive, -i Interactive mode to confirm uncertain matches
--reset-unrated, -r Reset unrated tracks on iBroadcast to NoThumb
--preview-only, -p Preview mode only (no synchronization)Preview changes without syncing:
dotnet run --project IBroadcastStars.App sync --preview-onlyWith .env file (simplest):
# Configure .env once, then:
dotnet run --project IBroadcastStars.App syncInteractive mode:
dotnet run --project IBroadcastStars.App sync --interactiveReset unrated tracks:
dotnet run --project IBroadcastStars.App sync --reset-unratedCustom library path (overrides .env):
dotnet run --project IBroadcastStars.App sync --library ~/Music/iTunes/iTunes\ Library.xmlWithout .env file (direct arguments):
dotnet run --project IBroadcastStars.App sync -- \
--client-id abc123 \
--client-secret xyz789 \
--reset-unratedIBroadcastStars/
βββ IBroadcastStars.App/
β βββ Program.cs # Entry point and CLI setup
β βββ Commands/
β β βββ SyncCommand.cs # Sync command implementation
β β βββ InfoCommand.cs # Info command
β β βββ StatsCommand.cs # Stats command
β βββ IBroadcastApi/
β β βββ IBroadcastApiClient.cs # HTTP client for iBroadcast API
β β βββ IIBroadcastApiClient.cs # Client interface
β β βββ ApiModels.cs # API data models
β β βββ OAuth/
β β βββ OAuth2Service.cs # OAuth2 Device Code Flow
β β βββ TokenResponse.cs # OAuth response models
β βββ Sync/
β β βββ SyncServices.cs # Synchronization service
β β βββ TrackMatcher.cs # Intelligent matching algorithm
β β βββ SyncPreview.cs # Preview and statistics
β βββ LocalLibraryParsers/
β β βββ ITunesLibraryParser.cs # iTunes XML parser
β β βββ AppleMusicLibraryParser.cs # Apple Music SQLite parser
β β βββ IMusicLibraryParser.cs # Parser interface
β β βββ MusicLibraryParserFactory.cs # Factory with auto-detection
β β βββ Models/ # Library data models
β βββ Infrastructure/
β β βββ TypeRegistrar.cs # DI registrar for Spectre.Console
β β βββ TypeResolver.cs # DI resolver
β βββ Extensions/
β βββ IBroadcastOptions.cs # Configuration options
βββ IBroadcastStars.Tests/
βββ (Unit tests)
dotnet testPress F5 to debug, or use tasks:
- Build - Compile the solution
- Test - Run tests
- Run - Execute the application
- OAuth2 tokens are stored in
~/.ibroadcast_token.jsonwith 600 permissions (user read/write only) - Client secrets can be passed via command line (consider using environment variables for better security)
- Tokens are automatically refreshed when they expire
For a library with ~700 liked tracks:
- Matching: < 1 second (with optimizations)
- Synchronization: ~6 minutes (500ms delay between API calls to respect rate limits)
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
Copyright (C) 2026 IBroadcastStars 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.
- Apple Music library parsing powered by AppMusicLibParser
- CLI framework: Spectre.Console