Lib-Sync is a collection of tools for managing your music library across different platforms.
- Sync: Synchronize your Rekordbox playlists with Spotify playlists
- Analyze: Analyze your Rekordbox library for insights and statistics
- Identify: Identify songs from recordings or YouTube sets using audio fingerprinting
Please make sure you have Python 3.11 or newer (python --version).
# with uvx (recommended)
uvx lib-sync
# with pipx
pipx install lib-sync
# with pip
python -m pip install lib-sync# with uv (recommended)
uv tool upgrade lib-sync
# with pipx
pipx upgrade lib-sync
# with pip
python -m pip install --upgrade lib-syncAfter installation, the libsync command will be available in your terminal.
Troubleshooting: If libsync command is not found:
- Make sure you're using Python 3.11 or higher
- If your python is installed via uv (or in a virtual environment), try
python -m pip install --force-reinstall --user lib-sync - try running
python -m pip install --upgrade pip wheelfirst
- Python 3.11 or higher
- For YouTube id extraction, you'll need ffmpeg installed and available on PATH
- For Spotify sync functionality, you'll need Spotify API credentials (see Spotify API Setup below)
Create a .env file in your working directory:
cp .env.example .envSupported environment variables:
# Required for Spotify sync
SPOTIPY_CLIENT_ID=your_client_id_here
SPOTIPY_CLIENT_SECRET=your_client_secret_here
SPOTIPY_REDIRECT_URI=http://localhost:8080
# Optional: Default path to Rekordbox XML export
REKORDBOX_XML_PATH=/path/to/rekordbox_export.xml- Go to the Spotify Developers Dashboard
- Click "Create App" to get a Client ID and Client Secret
- Add your credentials to the
.envfile (see above)
- Export your library from Rekordbox (File → Export Collection in XML format)
- Tell libsync where to find the exported XML file - two options:
- CLI flag:
--rekordbox_xml_path /path/to/export.xml(takes precedence) - Environment variable: Set
REKORDBOX_XML_PATHin your.envfile
- CLI flag:
- Run the sync command:
# Describe available flags
libsync sync -h
# Basic sync (using environment variable from .env)
libsync sync
# Basic sync (using CLI flag)
libsync sync --rekordbox_xml_path ~/Documents/rekordbox/rekordbox_export.xml# Describe available flags
libsync analyze -h
# Analyze library (path from CLI or .env)
libsync analyze
# Analyze with explicit path
libsync analyze --rekordbox_xml_path ~/Documents/rekordbox/rekordbox_export.xml# Identify from audio file
libsync id file --recording_audio_file_path ~/Music/unknown_track.mp3
# Identify from YouTube URL
libsync id youtube --youtube_url "https://www.youtube.com/watch?v=VIDEO_ID"In addition to the CLI commands, lib-sync includes standalone scripts for analyzing audio recordings.
Analyzes BPM throughout an audio recording and produces a visualization showing tempo changes over time.
# Basic usage
uv run python scripts/bpm_analysis.py recording.m4a
# Custom window size and BPM range
uv run python scripts/bpm_analysis.py recording.mp3 --window-size 20 --hop-size 10
# Specify BPM range for electronic music
uv run python scripts/bpm_analysis.py recording.wav --min-bpm 100 --max-bpm 150
# Custom output path
uv run python scripts/bpm_analysis.py recording.m4a -o my_analysis.pngFeatures:
- Multi-method tempo detection (tempogram, autocorrelation, beat tracking) for robustness
- Automatic octave error correction (handles half/double tempo detection errors)
- Music vs silence detection to exclude non-music sections
- Outlier filtering with configurable thresholds
- Three-panel visualization: BPM trend, detection confidence, music presence
Output: Generates <filename>_bpm_analysis.png with:
- BPM measurements over time with outliers marked
- Smoothed BPM trend line
- Confidence scores for each measurement
- Music/silence detection timeline
- Summary statistics (median, mean, std dev, range)
Creates a combined visualization showing BPM analysis with Shazam track detections overlaid. Requires running libsync id file first to populate the Shazam cache.
# Basic usage (after running libsync id file on the recording)
uv run python scripts/combined_analysis_viz.py recording.m4a
# Require more matches for higher confidence
uv run python scripts/combined_analysis_viz.py recording.m4a --min-matches 3
# Custom output path
uv run python scripts/combined_analysis_viz.py recording.m4a -o combined.pngFeatures:
- Overlays detected track names on the BPM graph with timestamps
- Color-coded track regions showing where each song was detected
- Match count displayed for each track (e.g.,
[7x]= detected 7 times) - Track detection timeline showing song durations
- Prints tracklist summary with timestamps
Output: Generates <filename>_combined_analysis.png with:
- Top panel: BPM trend with track annotations and shaded regions
- Bottom panel: Track detection timeline with match counts
Logs go to ~/.libsync/data/logs. check there for records of all the libsync commands you run.
Use -v or --verbose flags before the subcommand for more detailed output:
# INFO level logging
libsync -v sync
# DEBUG level logging
libsync -vv syncAfter running sync at least once, Lib-Sync creates a CSV file in the data/ directory with your track mappings. You can manually improve the matches:
- Open the generated CSV file (e.g.,
data/rekordbox_spotify_matches_YYYY-MM-DD.csv) - To manually match a track:
- Paste the Spotify track URL in the
Spotify URL (input)column - For tracks not on Spotify, enter
libsync:NOT_ON_SPOTIFYin theSpotify URIcolumn
- Paste the Spotify track URL in the
- To retry automatic matching:
- Put
1in theRetry auto match (input)column - Use with
--ignore_spotify_search_cacheto force a new search
- Put
The next sync will use your manual corrections.
See CONTRIBUTING.md for development setup and guidelines.
MIT License - see LICENSE file for details.