This system enables personal audio extraction and playback from YouTube Music sources through a client-server architecture.
- Separation of Concerns: Python handles extraction/complexity, iOS handles playback/UI
- Local-First: All processing happens on local network, no cloud dependencies
- Modular: Components can be replaced/swapped independently
iOS Search Query → HTTP POST /search → ytmusicapi.search() → YouTube Music API
↓
iOS Display Results ← JSON Track Metadata ← Response Processing
iOS Play Request → HTTP GET /stream/{id} → ytmusicapi.get_song()
↓
Extract adaptiveFormats
↓
iOS AVPlayer ← Direct Stream URL ← Best Audio Format Selected
iOS Download Request → HTTP POST /download → yt-dlp extraction
↓
FFmpeg transcoding to M4A
↓
iOS Play Local ← HTTP GET /local-play/{file} ← File Saved Locally
- ytmusicapi and yt-dlp are Python-native
- Easier to maintain extraction logic outside iOS sandbox
- Can run on Raspberry Pi, NAS, or Mac always-on
- Native iOS support (no third-party codecs needed)
- AAC codec is efficient and compatible
- Metadata embedding (ID3 tags) works well
- HTTP/REST for simplicity
- Local network only (no TLS needed for LAN)
- Stream URLs passed directly to AVPlayer (efficient)
iOS AVAudioSession configured with:
- Category:
.playback - Mode:
.default - Options:
[.allowAirPlay]
Remote transport controls implemented via MPNowPlayingInfoCenter for Control Center integration.
- Downloads stored in
~/Music/YTAudio/by default - Organized by filename pattern:
{Title} - {Artist}.m4a - No database - filesystem is source of truth
- No local storage (streaming only)
- Metadata cached in memory during session
- OAuth credentials stored only on backend
- No API keys in iOS client
- Local network isolation
- No external network calls from iOS (except to backend)