Skip to content

Implement library repository with AppleScript integration #6

@andhijeannot

Description

@andhijeannot

Overview

Implement complete library repository for Music.app integration including track search, playlist management, and metadata retrieval.

Scope

Create LibraryRepository implementation that provides fast and reliable access to Music.app library data.

Implementation Requirements

Library Repository (infrastructure/applescript/library.go)

  • GetAllTracks with pagination support
  • SearchTracks with multiple search criteria
  • GetPlaylists and GetPlaylistTracks
  • GetTracksByArtist, GetTracksByAlbum
  • GetTrackMetadata with full details
  • Performance optimization for large libraries (10K+ tracks)

AppleScript Templates (infrastructure/applescript/scripts/)

  • library_get_all_tracks.scpt - Paginated track retrieval
  • library_search_tracks.scpt - Fast search implementation
  • library_get_playlists.scpt - Playlist enumeration
  • library_get_playlist_tracks.scpt - Playlist content retrieval
  • library_get_track_metadata.scpt - Detailed track information
  • library_get_artists.scpt - Artist enumeration
  • library_get_albums.scpt - Album enumeration

Search Implementation

  • Text search across title, artist, album, genre
  • Fuzzy search support for typos
  • Search result ranking and sorting
  • Search performance optimization
  • Search result pagination

Metadata Handling

  • Complete track metadata extraction
  • Artwork handling (if available via AppleScript)
  • Playlist metadata and properties
  • Library statistics and counts
  • Missing metadata graceful handling

Performance Requirements

  1. Large Library Support - Handle 50,000+ tracks efficiently
  2. Fast Search - <500ms for typical searches
  3. Pagination - Chunked data retrieval to prevent timeouts
  4. Caching Ready - Design for efficient caching integration
  5. Memory Efficient - Streaming data processing where possible

AppleScript Optimization

  • Minimize AppleScript calls through batching
  • Efficient data serialization from AppleScript
  • Timeout handling for slow library operations
  • Progress reporting for long operations
  • Error recovery for corrupted library data

Success Criteria

  • Complete LibraryRepository implementation
  • All AppleScript templates working reliably
  • Search performance <500ms for 10K+ tracks
  • Pagination works for large libraries
  • Metadata extraction comprehensive
  • Error handling robust for all edge cases
  • Integration tests with real Music.app libraries
  • Performance tests demonstrate scalability

Testing Strategy

  • Unit tests with mocked AppleScript executor
  • Integration tests with small and large libraries
  • Performance benchmarking with various library sizes
  • Error scenario testing (corrupted data, missing tracks)
  • Search relevance and ranking testing
  • Memory usage profiling

Integration Points

  • Domain layer: Implements LibraryRepository interface
  • Caching layer: Will be consumed by cache implementation
  • Application layer: Will be used by search and browse commands
  • CLI: Will power search and browse functionality

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestlibraryLibrary operationsv0.3.0Version 0.3.0 milestone issues

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions