Debian Codegraph @

beetsplug/discogs/types.py

raw
1 from __future__ import annotations
2
3 from typing import TYPE_CHECKING, Literal
4
5 from typing_extensions import NotRequired, TypedDict
6
7 if TYPE_CHECKING:
8 from beets.autotag import TrackInfo
9
10
11 class ReleaseFormat(TypedDict):
12 name: str
13 qty: int
14 descriptions: list[str] | None
15
16
17 class Artist(TypedDict):
18 name: str
19 anv: str
20 join: str
21 role: str
22 tracks: str
23 id: str
24 resource_url: str
25
26
27 class AudioTrack(TypedDict):
28 """Represent an audio item or logical segment in a Discogs tracklist.
29
30 Discogs uses this shape both for independently addressable media tracks and
31 for pieces rolled into one physical track. Position syntax and surrounding
32 index structure determine which interpretation applies.
33 """
34
35 type_: Literal["track"]
36 position: str
37 title: str
38 duration: str
39 artists: NotRequired[list[Artist]]
40 extraartists: NotRequired[list[Artist]]
41
42
43 class IndexTrack(TypedDict):
44 """Represent a titled musical work containing related subtracks.
45
46 The contained entries may be movements stored as separate physical tracks
47 or logical divisions of one track. Their position syntax determines whether
48 they remain separate or are coalesced under the work's metadata.
49 """
50
51 type_: Literal["index"]
52 position: Literal[""]
53 title: str
54 duration: str
55 sub_tracks: list[AudioTrack]
56 artists: NotRequired[list[Artist]]
57 extraartists: NotRequired[list[Artist]]
58
59
60 class HeadingTrack(TypedDict):
61 """Represent descriptive tracklist structure rather than an audio item.
62
63 A heading labels the following block but is not the title of a musical work.
64 It must remain structural instead of being treated as an index container.
65 """
66
67 type_: Literal["heading"]
68 position: Literal[""]
69 title: str
70 duration: str
71
72
73 Track = AudioTrack | IndexTrack | HeadingTrack
74
75
76 class ArtistInfo(TypedDict):
77 artist: str
78 artists: list[str]
79 artist_credit: str
80 artists_credit: list[str]
81 artist_id: str
82 artists_ids: list[str]
83 arrangers: list[str] | None
84 composers: list[str] | None
85 remixers: list[str] | None
86 lyricists: list[str] | None
87
88
89 class TracklistInfo(TypedDict):
90 index: int
91 index_tracks: dict[int, str]
92 tracks: list[TrackInfo]
93 divisions: list[str]
94 next_divisions: list[str]
95 mediums: list[str | None]
96 medium_indices: list[str | None]