-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.py
221 lines (174 loc) · 5.44 KB
/
model.py
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
import datetime
from enum import Enum, IntEnum
from typing import Optional, Annotated, Union, Literal
from pydantic import BaseModel, Field
class Connection(BaseModel):
lane: float
beat: float
hidden: Optional[bool] = None
flick: Optional[bool] = None
charge: Optional[bool] = None
skill: Optional[bool] = None
class NoteType(str, Enum):
BPM = 'BPM'
System = 'System'
Single = 'Single'
Long = 'Long'
Directional = 'Directional'
Slide = 'Slide'
class Direction(str, Enum):
Left = 'Left'
Right = 'Right'
class DifficultyInt(IntEnum):
Easy = 0
Normal = 1
Hard = 2
Expert = 3
Special = 4
class Language(IntEnum):
Japanese = 0
English = 1
ChineseTraditional = 2
ChineseSimplified = 3
Korean = 4
class BPM(BaseModel):
type: Literal[NoteType.BPM] = NoteType.BPM
bpm: int
beat: float
class Command(BaseModel):
type: Literal[NoteType.System] = NoteType.System
data: str
beat: float
class Single(BaseModel):
type: Literal[NoteType.Single] = NoteType.Single
lane: int
beat: float
skill: Optional[bool] = None
flick: Optional[bool] = None
charge: Optional[bool] = None
class Directional(BaseModel):
type: Literal[NoteType.Directional] = NoteType.Directional
beat: float
lane: int
direction: Direction
width: int
class Slide(BaseModel):
type: Literal[NoteType.Slide, NoteType.Long]
connections: list[Connection]
NoteBase = Annotated[Union[BPM, Command, Single, Directional, Slide], Field(discriminator='type')]
LaneLocated = Union[Single, Connection, Directional]
class ChartMeta(BaseModel):
id: int # song_id or post_id
title: str
level: int
difficulty: DifficultyInt
release: datetime.datetime
is_official: bool
artist: Optional[str] = None # band or singer
chart_designer: Optional[str] = None # only for user post
lyricist: Optional[str] = None # only for official
composer: Optional[str] = None # only for official
arranger: Optional[str] = None # only for official
class Chart(BaseModel):
__root__: list[NoteBase]
class UserPost(BaseModel):
class Post(BaseModel):
class Content(BaseModel):
data: Optional[str] = None
type: str
class Author(BaseModel):
class Title(BaseModel):
id: int
type: str
server: int
username: str
nickname: Optional[str]
titles: Optional[list[Title]]
class Tag(BaseModel):
type: str
data: str
class Song(BaseModel):
type: str
audio: Optional[str]
cover: Optional[str]
categoryName: str
categoryId: str
title: str
song: Song
artists: str
diff: int
level: int
chart: Chart
content: list[Content]
time: int
author: Author
likes: int
liked: bool
tags: list[Tag]
result: bool
post: Post
class BestdoriSongMeta(BaseModel):
"""
https://bestdori.com/api/songs/359.json
copied from package bestdori
"""
class Tag(str, Enum):
Normal = 'normal'
Anime = 'anime'
TieUp = 'tie_up'
class BPM(BaseModel):
bpm: float
start: float
end: float
class Achievement(BaseModel):
musicId: int # 359
achievementType: str # "score_rank_b"
rewardType: str # "practice_ticket"
rewardId: Optional[int] # 2
quantity: int # 1
class Difficulty(BaseModel):
class MultiLiveScoreMap(BaseModel):
musicId: int # 359
musicDifficulty: str # "easy"
multiLiveDifficultyId: int # 2001
multiLiveDifficultyType: str # "daredemo"
scoreS: int # 3321000
scoreA: int # 2214000
scoreB: int # 1107000
scoreC: int # 184500
scoreSS: int # 4428000
scoreSSS: Optional[int] # 0
playLevel: int # 11
multiLiveScoreMap: dict[int, MultiLiveScoreMap]
notesQuantity: int # 1000
scoreC: int # 36900
scoreB: int # 221400
scoreA: int # 442800
scoreS: int # 664200
scoreSS: int # 885600
bgmId: str # "bgm359"
bgmFile: str # "359_hell_or_hell"
tag: Tag # "normal"
bandId: int # 18
achievements: list[Achievement]
jacketImage: list[str] # ["359_hell_or_hell"]
seq: int # 712
musicTitle: list[Optional[str]] # ["HELL! or HELL?", ...]
lyricist: list[Optional[str]] # ["織田あすか(Elements Garden)", ...]
composer: list[Optional[str]] # ["菊田大介(Elements Garden)", ...]
arranger: list[Optional[str]] # ["菊田大介(Elements Garden)", ...]
howToGet: list[Optional[str]] # ["楽曲プレゼントを受け取る", ...]
publishedAt: list[Optional[datetime.datetime]] # ["1632031200000", ...]
closedAt: list[Optional[datetime.datetime]] # ["4121982000000", ...]
difficulty: dict[DifficultyInt, Difficulty]
length: float # 108.504
notes: dict[DifficultyInt, int] # {"0": 196, "1": 338, "2": 598, "3": 999, "4": 1196}
bpm: dict[DifficultyInt, list[BPM]]
class Bands(BaseModel):
"""
https://bestdori.com/api/bands/all.1.json
copied from package bestdori
"""
class BandName(BaseModel):
bandName: list[Optional[str]]
__root__: dict[int, BandName]