summaryrefslogtreecommitdiff
path: root/src/ampache/models.py
blob: 452b1c58560a558bc14265fcab199b735de2c256 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""
The data structures of the ampache API (songs, artists, albums, etc).
"""
from dataclasses import dataclass
import datetime


@dataclass
class AuthToken:
    expires: datetime.datetime
    auth: str

    def __str__(self):
        return f"Expires: {self.expires}\nToken: {self.auth}"


@dataclass
class Song:
    song_id: str
    title: str
    album: str
    artist: str

    def __str__(self):
        return f"{self.title} by {self.artist}"


@dataclass
class Album:
    album_id: str
    title: str
    artist: str
    songs: list[Song]

    def __str__(self):
        return f"{self.title} by {self.artist}"


@dataclass
class Error:
    code: int
    message: str

    def __str__(self):
        return f"{self.message} with code {self.code}"