Commit cab57b31 authored by Aryan Noshirvnai's avatar Aryan Noshirvnai

Add shared-library search: /library/shared/search + /library/shared/claim

Every library query was scoped to the caller's own songs - there was no
way to search what other users have already tagged. New search endpoint
matches title/artist/genre across every user's library (same matching as
the existing owner-scoped search), deduped by (title, artist) so a song
several users separately uploaded doesn't show up once per owner, and
excludes anything the caller already has by that same identity - the
point is surfacing music that's new to them, not re-offering their own
library back at them.

Claiming a result reuses give_from_shared_library - the exact mechanism
already backing Discovery's "identified something someone else has, give
me a copy" flow - moved out of discovery.py into a new shared services
module so both routers call the same code instead of one importing the
other's private function. Picked up a drive-by fix in the move: it wasn't
copying track_number, so a claimed song silently lost its real album
order.

Also fixed two unrelated pre-existing test collisions surfaced while
adding these tests: the session-scoped test DB (no per-test rollback)
meant test_music.py, test_discovery.py, and this file's own new tests all
used identical "Shared Song"/"Shared Artist"-style literals, and a global
(no user_id) title/artist lookup could resolve to the wrong test's
leftover row depending on run order.
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
parent d7dddc8e
Pipeline #1179 passed with stage
in 23 minutes and 12 seconds