Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 42 lines 1.4 kB view raw
1"""03 — Search the library. 2 3Search the library, print a summary, start playing the first matching album. 4 5 uv run python examples/03_library_search.py "pink floyd" 6""" 7 8from __future__ import annotations 9 10import asyncio 11import sys 12 13from _client import create_client # type: ignore[import-not-found] 14 15 16async def main(term: str) -> None: 17 async with create_client() as client: 18 results = await client.library.search(term) 19 20 print(f'Search: "{term}"') 21 print(f" Artists : {len(results.artists)}") 22 print(f" Albums : {len(results.albums)}") 23 print(f" Tracks : {len(results.tracks)}") 24 print(f" Liked albums : {len(results.liked_albums)}") 25 print(f" Liked tracks : {len(results.liked_tracks)}\n") 26 27 print("Top albums:") 28 for a in results.albums[:5]: 29 copyright = f" © {a.copyright_message}" if a.copyright_message else "" 30 print(f"{a.title}{a.artist} ({a.year}){copyright}") 31 32 if results.albums: 33 first = results.albums[0] 34 print(f"\nPlaying: {first.title}") 35 await client.playback.play_album(first.id, shuffle=False) 36 37 38if __name__ == "__main__": 39 if len(sys.argv) < 2: 40 print("usage: python examples/03_library_search.py <search term>") 41 sys.exit(1) 42 asyncio.run(main(sys.argv[1]))