Files
api/endpoints/constructors.py

250 lines
4.9 KiB
Python
Raw Normal View History

2025-02-11 11:19:52 -05:00
from typing import Optional
2025-08-21 15:35:10 -04:00
from typing import Literal
2025-02-11 11:19:52 -05:00
from pydantic import BaseModel
2025-08-21 15:35:10 -04:00
Station = Literal["main", "rock", "rap", "electronic", "pop"]
2025-02-11 11:19:52 -05:00
"""
Rand Msg
"""
2025-02-11 11:19:52 -05:00
class RandMsgRequest(BaseModel):
"""
2025-09-23 13:17:34 -04:00
Request model for random message.
Attributes:
- **short** (Optional[bool]): Short randmsg?
2025-02-11 11:19:52 -05:00
"""
2025-02-16 14:04:59 -05:00
short: Optional[bool] = False
2025-02-11 11:19:52 -05:00
2025-02-11 11:19:52 -05:00
"""
YT
"""
2025-02-11 11:19:52 -05:00
class ValidYTSearchRequest(BaseModel):
"""
2025-09-23 13:17:34 -04:00
Request model for YouTube search.
Attributes:
- **t** (str): Title to search.
2025-02-11 11:19:52 -05:00
"""
t: str = "rick astley - never gonna give you up"
2025-02-11 11:19:52 -05:00
"""
Transcriptions
"""
2025-02-11 11:19:52 -05:00
class ValidShowEpisodeListRequest(BaseModel):
"""
2025-09-23 13:17:34 -04:00
Request model for show episode list.
Attributes:
- **s** (int): Show ID.
2025-02-11 11:19:52 -05:00
"""
s: int
2025-02-11 11:19:52 -05:00
class ValidShowEpisodeLineRequest(BaseModel):
"""
2025-09-23 13:17:34 -04:00
Request model for show episode lines.
Attributes:
- **s** (int): Show ID.
- **e** (int): Episode ID.
2025-02-11 11:19:52 -05:00
"""
s: int
e: int
2025-02-11 11:19:52 -05:00
"""
Lyric Search
"""
2025-02-11 11:19:52 -05:00
class ValidLyricRequest(BaseModel):
"""
2025-09-23 13:17:34 -04:00
Request model for lyric search.
Attributes:
- **a** (Optional[str]): Artist.
- **s** (Optional[str]): Song.
- **t** (Optional[str]): Track (artist and song combined).
- **extra** (Optional[bool]): Include extra details in response.
- **lrc** (Optional[bool]): Request LRCs?
- **sub** (Optional[str]): Text to search within lyrics.
- **src** (str): The script/utility which initiated the request.
- **excluded_sources** (Optional[list]): Sources to exclude.
2025-02-11 11:19:52 -05:00
"""
a: Optional[str] = None
2025-02-15 21:09:33 -05:00
s: Optional[str] = None
t: Optional[str] = None
sub: Optional[str] = None
extra: Optional[bool] = False
lrc: Optional[bool] = False
2025-02-11 11:19:52 -05:00
src: str
2025-02-15 21:09:33 -05:00
excluded_sources: Optional[list] = None
2025-02-11 11:19:52 -05:00
model_config = {
"json_schema_extra": {
"examples": [
{
"a": "eminem",
"s": "rap god",
"src": "WEB",
"extra": True,
"lrc": False,
"excluded_sources": [],
}
]
2025-02-11 11:19:52 -05:00
}
}
2025-02-11 11:19:52 -05:00
class ValidTypeAheadRequest(BaseModel):
"""
2025-09-23 13:17:34 -04:00
Request model for typeahead query.
Attributes:
- **query** (str): Query string.
2025-02-11 11:19:52 -05:00
"""
2025-02-11 11:19:52 -05:00
query: str
2025-02-11 11:19:52 -05:00
"""
Radio
"""
2025-02-11 11:19:52 -05:00
class RadioException(Exception):
pass
2025-02-11 11:19:52 -05:00
class ValidRadioSongRequest(BaseModel):
"""
2025-09-23 13:17:34 -04:00
Request model for radio song request.
Attributes:
- **key** (str): API Key.
- **artist** (Optional[str]): Artist to search.
- **song** (Optional[str]): Song to search.
- **artistsong** (Optional[str]): Combined artist-song string.
- **alsoSkip** (Optional[bool]): Whether to skip immediately to this track.
- **station** (Station): Station name.
2025-02-11 11:19:52 -05:00
"""
2025-02-11 11:19:52 -05:00
key: str
2025-02-15 21:09:33 -05:00
artist: Optional[str] = None
song: Optional[str] = None
artistsong: Optional[str] = None
alsoSkip: Optional[bool] = False
2025-08-21 15:35:10 -04:00
station: Station = "main"
2025-02-16 13:54:28 -05:00
class ValidRadioTypeaheadRequest(BaseModel):
"""
2025-09-23 13:17:34 -04:00
Request model for radio typeahead.
Attributes:
- **query** (str): Typeahead query.
2025-02-16 13:54:28 -05:00
"""
2025-02-16 13:54:28 -05:00
query: str
2025-02-11 20:49:14 -05:00
class ValidRadioQueueGetRequest(BaseModel):
"""
2025-09-23 13:17:34 -04:00
Request model for radio queue get.
Attributes:
- **key** (Optional[str]): API key.
- **limit** (Optional[int]): Result limit.
2025-02-11 20:49:14 -05:00
"""
2025-02-15 21:09:33 -05:00
key: Optional[str] = None
limit: Optional[int] = 15_000
2025-02-11 11:19:52 -05:00
class ValidRadioNextRequest(BaseModel):
"""
2025-09-23 13:17:34 -04:00
Request model for radio next track.
Attributes:
- **key** (str): API Key.
- **skipTo** (Optional[str]): UUID to skip to.
- **station** (Station): Station name.
2025-02-11 11:19:52 -05:00
"""
2025-02-11 11:19:52 -05:00
key: str
2025-02-15 21:09:33 -05:00
skipTo: Optional[str] = None
2025-08-21 15:35:10 -04:00
station: Station = "main"
2025-02-11 11:19:52 -05:00
class ValidRadioReshuffleRequest(ValidRadioNextRequest):
"""
2025-09-23 13:17:34 -04:00
Request model for radio reshuffle.
Attributes:
- **key** (str): API Key.
- **station** (Station): Station name.
2025-02-11 11:19:52 -05:00
"""
class ValidRadioQueueRequest(BaseModel):
"""
2025-09-23 13:17:34 -04:00
Request model for radio queue.
Attributes:
- **draw** (Optional[int]): DataTables draw count.
- **start** (Optional[int]): Paging start position.
- **search** (Optional[str]): Search query.
- **station** (Station): Station name.
"""
draw: Optional[int] = 1
start: Optional[int] = 0
search: Optional[str] = None
2025-08-21 15:35:10 -04:00
station: Station = "main"
2025-04-26 17:17:42 -04:00
2025-02-11 11:19:52 -05:00
class ValidRadioQueueShiftRequest(BaseModel):
"""
2025-09-23 13:17:34 -04:00
Request model for radio queue shift.
Attributes:
- **key** (str): API Key.
- **uuid** (str): UUID to shift.
- **next** (Optional[bool]): Play next if true.
- **station** (Station): Station name.
2025-02-11 11:19:52 -05:00
"""
2025-02-11 11:19:52 -05:00
key: str
uuid: str
2025-02-15 21:09:33 -05:00
next: Optional[bool] = False
2025-08-21 15:35:10 -04:00
station: Station = "main"
2025-02-11 11:19:52 -05:00
class ValidRadioQueueRemovalRequest(BaseModel):
"""
2025-09-23 13:17:34 -04:00
Request model for radio queue removal.
Attributes:
- **key** (str): API Key.
- **uuid** (str): UUID to remove.
- **station** (Station): Station name.
2025-02-11 11:19:52 -05:00
"""
2025-02-11 11:19:52 -05:00
key: str
2025-04-26 17:17:42 -04:00
uuid: str
2025-08-21 15:35:10 -04:00
station: Station = "main"