from dataclasses import dataclass
from typing import List, Optional, Protocol


@dataclass
class NowPlaying:
    title: str = ""
    artist: str = ""
    album: str = ""
    duration: float = 0.0
    position: float = 0.0
    playing: bool = False
    artwork_path: Optional[str] = None
    source: str = ""
    unsupported_reason: Optional[str] = None


def unsupported_now_playing(source: str, reason: str) -> NowPlaying:
    return NowPlaying(source=source, unsupported_reason=reason)


class MusicSource(Protocol):
    name: str

    def now_playing(self) -> NowPlaying: ...
    def play(self) -> None: ...
    def pause(self) -> None: ...
    def toggle(self) -> None: ...
    def next(self) -> None: ...
    def prev(self) -> None: ...
    def seek(self, seconds: float) -> None: ...
    def set_volume(self, percent: int) -> None: ...
    def like_current(self) -> bool: ...
    def set_play_mode(self, mode: str) -> bool: ...
    def search(self, query: str, limit: int = 8) -> List[dict]: ...
    def play_query(self, query: str, library_only: bool = False) -> Optional[NowPlaying]: ...
    def list_loved(self, limit: int = 100) -> List[dict]: ...
    def search_loved(self, query: str, limit: int = 8) -> List[dict]: ...
