Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AppleMusicDL

AppleMusicDL

Rip Apple Music tracks in lossless ALAC — straight to your drive.

Python Frida License Format Stars Issues


⚠️ Personal use only. This tool is for music you have the right to access. Downloading copyrighted content may violate Apple's ToS and local copyright laws.


✨ What it does

AppleMusicDL downloads tracks from Apple Music in ALAC (Apple Lossless Audio Codec) format — the same lossless quality Apple streams — with complete iTunes metadata embedded. No lossy compression, no missing tags, no manual work.

Apple Music  →  Frida (FairPlay decrypt)  →  .m4a (ALAC + metadata)

What you get:

  • Lossless ALAC audio, exactly as streamed
  • Full metadata — title, artist, album, year, composer, ISRC, UPC
  • Album artwork embedded + saved separately
  • Automatically organized folder structure

🔬 How it works

Step What happens
1 Extracts bearer token from Apple Music web interface
2 Fetches album + track metadata via Apple Music API
3 Parses M3U8 playlists to locate ALAC streams
4 Downloads encrypted fragmented MP4 segments
5 Sends encrypted samples to Frida agent on Android emulator
6 Frida hooks FairPlay, decrypts and returns raw audio
7 Reconstructs complete .m4a with audio + metadata

📋 Requirements

Requirement Details
Python 3.8 or higher
Android Studio With Android Emulator (no Google APIs image)
ADB Android Debug Bridge
Frida frida + frida-tools matching versions
Apple Music Active subscription required
APK Apple Music 3.6.0 Beta (APKMirror)

🚀 Setup

1 · Clone and install

git clone https://github.com/w3Abhishek/AppleMusicDL.git
cd AppleMusicDL
pip install -r requirements.txt

2 · Set up Android emulator

  1. Open Android Studio → create a virtual device
    • Use an image without Google APIs (required for Frida)
    • Recommended: Android 10 (API 29) or Android 11 (API 30)
  2. Install SAI (Split APKs Installer) on the emulator
  3. Use SAI to install the Apple Music 3.6.0 Beta APK
  4. Sign in with your Apple ID (subscription required)

3 · Set up Frida

# Check your installed version
frida --version

# Download matching frida-server for x86_64 emulator
# Replace <version> with your frida version
wget https://github.com/frida/frida/releases/download/<version>/frida-server-<version>-android-x86_64.xz
unxz frida-server-<version>-android-x86_64.xz

# Push to emulator and start
adb root
adb push frida-server-<version>-android-x86_64 /data/local/tmp/frida-server
adb shell "chmod 755 /data/local/tmp/frida-server"
adb shell "/data/local/tmp/frida-server &"

# Confirm it's running
frida-ps -U

4 · Port forwarding

adb forward tcp:10020 tcp:10020

🎵 Usage

Step 1 — Start the Frida agent and keep it running:

frida -U -l agent.js -f com.apple.android.music

Step 2 — Download an album:

python main.py https://music.apple.com/us/album/album-name/1624945511

Multiple albums at once:

python main.py \
  https://music.apple.com/us/album/album1/123456 \
  https://music.apple.com/us/album/album2/789012

Output:

AM-DL downloads/
└── Artist Name - Album Name/
    ├── cover.jpg
    ├── 01. Track Name.m4a
    ├── 02. Track Name.m4a
    └── ...

🗂 Project structure

AppleMusicDL/
├── apple_music_dl/
│   ├── api.py           # Apple Music API client + auth
│   ├── m3u8_parser.py   # Stream URL + encryption key extraction
│   ├── mp4_handler.py   # Fragmented MP4 parsing + ALAC params
│   ├── decryptor.py     # Frida socket communication
│   ├── metadata.py      # iTunes metadata + M4A reconstruction
│   ├── models.py        # Data models
│   └── utils.py         # Helpers
├── agent.js             # Frida agent (JavaScript, runs on emulator)
├── main.py              # Entry point
└── requirements.txt

🔧 Troubleshooting

Failed to connect to Frida agent
adb shell ps | grep frida        # verify server is running
adb forward tcp:10020 tcp:10020  # re-apply port forward
frida-ps -U                      # list processes, confirm ADB sees emulator
Unavailable in ALAC

Some tracks are not available in lossless in all regions. Try switching your Apple Music storefront or check if the album has a lossless badge in the app.

Failed to get token

Apple occasionally changes their web interface structure. Open an issue with your full error log and Python version.

Decryption size mismatch

The encryption key list doesn't match the sample count. Re-run the download. If it persists, check Frida agent output for errors.


🤝 Contributing

  1. Fork the repo
  2. Create a feature branch (git checkout -b feat/your-feature)
  3. Write tests for your changes
  4. Open a pull request

Bug reports with full logs and Python version are always welcome.


📄 License

Mozilla Public License 2.0 — open source, share-alike for modifications.


Built with 🎵 for audiophiles who hate lossy compression

About

Download Apple Music tracks in ALAC (Apple Lossless) format using Python and Frida. For personal use only.

Topics

Resources

Stars

16 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages