misc/version bump
This commit is contained in:
@ -64,22 +64,22 @@ class LastFM(FastAPI):
|
||||
self.lastfm = importlib.import_module("lastfm_wrapper").LastFM()
|
||||
|
||||
self.endpoints = {
|
||||
"get_artist_by_name": self.artist_by_name_handler,
|
||||
"get_artist_albums": self.artist_album_handler,
|
||||
"get_release": self.release_detail_handler,
|
||||
"get_release_tracklist": self.release_tracklist_handler,
|
||||
"get_track_info": self.track_info_handler,
|
||||
"lastfm/get_artist_by_name": self.artist_by_name_handler,
|
||||
"lastfm/get_artist_albums": self.artist_album_handler,
|
||||
"lastfm/get_release": self.release_detail_handler,
|
||||
"lastfm/get_release_tracklist": self.release_tracklist_handler,
|
||||
"lastfm/get_track_info": self.track_info_handler,
|
||||
#tbd
|
||||
}
|
||||
|
||||
for endpoint, handler in self.endpoints.items():
|
||||
app.add_api_route(f"/{endpoint}", handler, methods=["POST"],
|
||||
include_in_schema=False)
|
||||
include_in_schema=True)
|
||||
|
||||
async def artist_by_name_handler(self, data: ValidArtistSearchRequest):
|
||||
"""
|
||||
/get_artist_by_name/
|
||||
Get artist info
|
||||
- **a**: Artist to search
|
||||
"""
|
||||
artist = data.a.strip()
|
||||
if not artist:
|
||||
@ -102,8 +102,8 @@ class LastFM(FastAPI):
|
||||
|
||||
async def artist_album_handler(self, data: ValidArtistSearchRequest):
|
||||
"""
|
||||
/get_artist_albums/
|
||||
Get artist's albums/releases
|
||||
- **a**: Artist to search
|
||||
"""
|
||||
artist = data.a.strip()
|
||||
if not artist:
|
||||
@ -130,8 +130,9 @@ class LastFM(FastAPI):
|
||||
|
||||
async def release_detail_handler(self, data: ValidAlbumDetailRequest):
|
||||
"""
|
||||
/get_release/
|
||||
Get details of a particular release by an artist
|
||||
- **a**: Artist to search
|
||||
- **a2**: Release title to search (subject to change)
|
||||
"""
|
||||
artist = data.a.strip()
|
||||
release = data.a2.strip()
|
||||
@ -158,8 +159,9 @@ class LastFM(FastAPI):
|
||||
|
||||
async def release_tracklist_handler(self, data: ValidAlbumDetailRequest):
|
||||
"""
|
||||
/get_release_tracklist/
|
||||
Get track list for a particular release by an artist
|
||||
- **a**: Artist to search
|
||||
- **a2**: Release title to search (subject to change)
|
||||
"""
|
||||
artist = data.a.strip()
|
||||
release = data.a2.strip()
|
||||
@ -182,8 +184,9 @@ class LastFM(FastAPI):
|
||||
|
||||
async def track_info_handler(self, data: ValidTrackInfoRequest):
|
||||
"""
|
||||
/get_track_info/
|
||||
Get track info from Last.FM given an artist/track
|
||||
- **a**: Artist to search
|
||||
- **t**: Track title to search
|
||||
"""
|
||||
try:
|
||||
artist = data.a
|
||||
|
@ -59,15 +59,6 @@ class ValidTypeAheadRequest(BaseModel):
|
||||
pre_query: str|None = None
|
||||
query: str
|
||||
|
||||
|
||||
class ValidLyricSearchLogRequest(BaseModel):
|
||||
"""
|
||||
- **webradio**: whether or not to include requests generated automatically by the radio page on codey.lol, defaults to False
|
||||
"""
|
||||
|
||||
webradio: bool = False
|
||||
|
||||
|
||||
class CacheUtils:
|
||||
"""Lyrics Cache DB Utils"""
|
||||
def __init__(self):
|
||||
@ -103,8 +94,8 @@ class LyricSearch(FastAPI):
|
||||
self.endpoints = {
|
||||
"typeahead/artist": self.artist_typeahead_handler,
|
||||
"typeahead/song": self.song_typeahead_handler,
|
||||
"lyric_search": self.lyric_search_handler,
|
||||
# "lyric_cache_list": self.lyric_cache_list_handler,
|
||||
"lyric_search": self.lyric_search_handler, # Preserving old endpoint path temporarily
|
||||
"lyric/search": self.lyric_search_handler,
|
||||
}
|
||||
|
||||
self.acceptable_request_sources = [
|
||||
@ -122,17 +113,8 @@ class LyricSearch(FastAPI):
|
||||
self.lrc_regex = regex.compile(r'\[([0-9]{2}:[0-9]{2})\.[0-9]{1,3}\](\s(.*)){0,}')
|
||||
|
||||
for endpoint, handler in self.endpoints.items():
|
||||
_schema_include = endpoint in ["lyric_search"]
|
||||
_schema_include = endpoint in ["lyric/search"]
|
||||
app.add_api_route(f"/{endpoint}", handler, methods=["POST"], include_in_schema=_schema_include)
|
||||
|
||||
# async def lyric_cache_list_handler(self):
|
||||
# """
|
||||
# Get currently cached lyrics entries
|
||||
# """
|
||||
# return {
|
||||
# 'err': False,
|
||||
# 'data': await self.lyrics_engine.listCacheEntries()
|
||||
# }
|
||||
|
||||
async def artist_typeahead_handler(self, data: ValidTypeAheadRequest):
|
||||
"""Artist Type Ahead Handler"""
|
||||
@ -160,16 +142,6 @@ class LyricSearch(FastAPI):
|
||||
typeahead_list = [str(r.get('song')) for r in typeahead_result]
|
||||
return typeahead_list
|
||||
|
||||
# async def lyric_search_log_handler(self, data: ValidLyricSearchLogRequest):
|
||||
# """Lyric Search Log Handler"""
|
||||
# include_radio = data.webradio
|
||||
# await self.glob_state.increment_counter('lyrichistory_requests')
|
||||
# last_10k_sings = await self.lyrics_engine.getHistory(limit=10000, webradio=include_radio)
|
||||
# return {
|
||||
# 'err': False,
|
||||
# 'history': last_10k_sings
|
||||
# }
|
||||
|
||||
async def lyric_search_handler(self, data: ValidLyricRequest):
|
||||
"""
|
||||
Search for lyrics
|
||||
|
@ -57,7 +57,7 @@ class Misc(FastAPI):
|
||||
|
||||
#TODO: change URL below to dynamically populate based on listener
|
||||
async with ClientSession() as session:
|
||||
async with await session.post("http://127.0.0.1:52111/xc/", json=json_payload,
|
||||
async with await session.post("http://127.0.0.1:52111/xc", json=json_payload,
|
||||
headers=headers, timeout=ClientTimeout(connect=3, sock_read=2)) as request:
|
||||
request.raise_for_status()
|
||||
request_json = await request.json()
|
||||
|
@ -28,7 +28,6 @@ class RandMsg(FastAPI):
|
||||
|
||||
async def randmsg_handler(self, data: RandMsgRequest = None):
|
||||
"""
|
||||
/randmsg
|
||||
Get a randomly generated message
|
||||
"""
|
||||
random.seed()
|
||||
|
@ -54,36 +54,40 @@ class XC(FastAPI):
|
||||
/xc
|
||||
Handle XC Commands
|
||||
"""
|
||||
key = data.key
|
||||
bid = data.bid
|
||||
cmd = data.cmd
|
||||
cmd_data = data.data
|
||||
req_type = 0
|
||||
|
||||
if bid in [1]:
|
||||
req_type = 2
|
||||
|
||||
if not self.util.check_key(path=request.url.path, req_type=req_type, key=key):
|
||||
raise HTTPException(status_code=403, detail="Unauthorized")
|
||||
|
||||
BID_ADDR_MAP = {
|
||||
0: '10.10.10.101:5991', # Thomas/Aces
|
||||
1: '10.10.10.100:5992' # MS & Waleed Combo
|
||||
}
|
||||
try:
|
||||
key = data.key
|
||||
bid = data.bid
|
||||
cmd = data.cmd
|
||||
cmd_data = data.data
|
||||
req_type = 0
|
||||
|
||||
if not bid in BID_ADDR_MAP:
|
||||
return {
|
||||
'err': True,
|
||||
'errorText': 'Invalid bot id'
|
||||
}
|
||||
if bid in [1]:
|
||||
req_type = 2
|
||||
|
||||
bot_api_url = f'http://{BID_ADDR_MAP[bid]}/'
|
||||
async with ClientSession() as session:
|
||||
async with await session.post(f"{bot_api_url}{cmd}", json=cmd_data, headers={
|
||||
'Content-Type': 'application/json; charset=utf-8'
|
||||
}, timeout=ClientTimeout(connect=5, sock_read=5)) as request:
|
||||
response = await request.json()
|
||||
return {
|
||||
'success': True,
|
||||
'response': response
|
||||
}
|
||||
if not self.util.check_key(path=request.url.path, req_type=req_type, key=key):
|
||||
raise HTTPException(status_code=403, detail="Unauthorized")
|
||||
|
||||
BID_ADDR_MAP = {
|
||||
0: '10.10.10.101:5991', # Thomas/Aces
|
||||
1: '10.10.10.100:5992' # MS & Waleed Combo
|
||||
}
|
||||
|
||||
if not bid in BID_ADDR_MAP:
|
||||
return {
|
||||
'err': True,
|
||||
'errorText': 'Invalid bot id'
|
||||
}
|
||||
|
||||
bot_api_url = f'http://{BID_ADDR_MAP[bid]}/'
|
||||
async with ClientSession() as session:
|
||||
async with await session.post(f"{bot_api_url}{cmd}", json=cmd_data, headers={
|
||||
'Content-Type': 'application/json; charset=utf-8'
|
||||
}, timeout=ClientTimeout(connect=5, sock_read=5)) as request:
|
||||
response = await request.json()
|
||||
return {
|
||||
'success': True,
|
||||
'response': response
|
||||
}
|
||||
except:
|
||||
pass
|
@ -22,18 +22,18 @@ class YT(FastAPI):
|
||||
self.ytsearch = importlib.import_module("youtube_search_async").YoutubeSearch()
|
||||
|
||||
self.endpoints = {
|
||||
"yt_video_search": self.yt_video_search_handler,
|
||||
"yt/search": self.yt_video_search_handler,
|
||||
#tbd
|
||||
}
|
||||
|
||||
for endpoint, handler in self.endpoints.items():
|
||||
app.add_api_route(f"/{endpoint}", handler, methods=["POST"],
|
||||
include_in_schema=False)
|
||||
include_in_schema=True)
|
||||
|
||||
async def yt_video_search_handler(self, data: ValidYTSearchRequest):
|
||||
"""
|
||||
/yt_video_search
|
||||
Search for YT Video by Title (closest match returned)
|
||||
- **t**: Title to search
|
||||
"""
|
||||
|
||||
title = data.t
|
||||
|
Reference in New Issue
Block a user