Public Access
Play albums by their Music Assistant URI
Names can match near-duplicate library albums that differ only in capitals (Let the/The Tribe Increase), and Music Assistant picked the unplayable one. Assignments now store the album's library URI, scans return it after checking it's still in the library (re-finding it by name, exact spelling first, if not), and HA plays by it. sync-library (formerly fetch-covers) links existing assignments. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+14
-4
@@ -1,9 +1,10 @@
|
||||
import httpx
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from tag_albums.app import create_app
|
||||
from tag_albums.config import Settings
|
||||
from tag_albums.library import Album
|
||||
from tag_albums.library import Album, MusicLibrary, _best_match
|
||||
from tag_albums.store import Store
|
||||
|
||||
TOKEN = "test-token"
|
||||
@@ -14,15 +15,24 @@ class FakeLibrary:
|
||||
def __init__(self):
|
||||
self.queries = []
|
||||
self.fetched = []
|
||||
self.fail_search = False
|
||||
self.library = [Album(artist="Tool", album="Lateralus", image="http://img/1", uri="library://album/1868")]
|
||||
self.images = {"http://img/1": (b"\x89PNG-lateralus", "image/png")}
|
||||
|
||||
def search_albums(self, query, limit=12):
|
||||
self.queries.append(query)
|
||||
return [Album(artist="Tool", album="Lateralus", image="http://img/1")]
|
||||
return list(self.library)
|
||||
|
||||
def find_album(self, artist, album):
|
||||
found = self.search_albums(album)[0]
|
||||
return found if (found.artist, found.album) == (artist, album) else None
|
||||
return _best_match(self.search_albums(album), artist, album)
|
||||
|
||||
def current_uri(self, uri, artist, album):
|
||||
if self.fail_search:
|
||||
raise httpx.ConnectError("HA down")
|
||||
return MusicLibrary.current_uri(self, uri, artist, album)
|
||||
|
||||
def image_download_url(self, url):
|
||||
return url
|
||||
|
||||
def fetch_image(self, url):
|
||||
self.fetched.append(url)
|
||||
|
||||
Reference in New Issue
Block a user