misc
This commit is contained in:
@ -56,7 +56,8 @@ class KarmaDB:
|
||||
"SELECT keyword, score FROM karma ORDER BY score DESC LIMIT ?", (n,)
|
||||
) as db_cursor:
|
||||
return await db_cursor.fetchall()
|
||||
except:
|
||||
except Exception as e:
|
||||
logging.debug("Exception: %s", str(e))
|
||||
traceback.print_exc()
|
||||
return None
|
||||
|
||||
@ -73,7 +74,7 @@ class KarmaDB:
|
||||
Optional[bool]
|
||||
"""
|
||||
|
||||
if not flag in [0, 1]:
|
||||
if flag not in [0, 1]:
|
||||
return None
|
||||
|
||||
modifier: str = "score + 1" if not flag else "score - 1"
|
||||
@ -182,7 +183,8 @@ class Karma(FastAPI):
|
||||
},
|
||||
)
|
||||
return JSONResponse(content=top10)
|
||||
except:
|
||||
except Exception as e:
|
||||
logging.debug("Exception: %s", str(e))
|
||||
traceback.print_exc()
|
||||
return JSONResponse(
|
||||
status_code=500,
|
||||
@ -214,7 +216,8 @@ class Karma(FastAPI):
|
||||
"count": count,
|
||||
}
|
||||
)
|
||||
except:
|
||||
except Exception as e:
|
||||
logging.debug("Exception: %s", str(e))
|
||||
traceback.print_exc()
|
||||
return JSONResponse(
|
||||
status_code=500,
|
||||
@ -239,7 +242,7 @@ class Karma(FastAPI):
|
||||
):
|
||||
raise HTTPException(status_code=403, detail="Unauthorized")
|
||||
|
||||
if not data.flag in [0, 1]:
|
||||
if data.flag not in [0, 1]:
|
||||
return JSONResponse(
|
||||
status_code=500,
|
||||
content={
|
||||
|
@ -1,4 +1,5 @@
|
||||
import importlib
|
||||
import logging
|
||||
import traceback
|
||||
from typing import Optional, Union
|
||||
from fastapi import FastAPI
|
||||
@ -214,7 +215,8 @@ class LastFM(FastAPI):
|
||||
track_info_result.get("errorText", "??"),
|
||||
)
|
||||
return JSONResponse(content={"success": True, "result": track_info_result})
|
||||
except:
|
||||
except Exception as e:
|
||||
logging.debug("Exception: %s", str(e))
|
||||
traceback.print_exc()
|
||||
return JSONResponse(
|
||||
status_code=500,
|
||||
|
@ -125,6 +125,14 @@ class LyricSearch(FastAPI):
|
||||
"errorText": f"Unknown request source: {data.src}",
|
||||
},
|
||||
)
|
||||
|
||||
if data.a == "N/A" and data.s == "N/A":
|
||||
return JSONResponse(
|
||||
status_code=200,
|
||||
content={
|
||||
'test': 'success',
|
||||
}
|
||||
)
|
||||
|
||||
if not data.t:
|
||||
search_artist: Optional[str] = data.a
|
||||
|
@ -96,9 +96,9 @@ class Misc(FastAPI):
|
||||
"""
|
||||
# Measure response time w/ test lyric search
|
||||
time_start: float = time.time() # Start time for response_time
|
||||
test_lyrics_result = await self.redis_client.ft().search(
|
||||
test_lyrics_result = await self.redis_client.ft().search( # noqa: F841
|
||||
"@artist: test @song: test"
|
||||
)
|
||||
)
|
||||
time_end: float = time.time()
|
||||
# End response time test
|
||||
total_keys = await self.redis_client.dbsize()
|
||||
|
@ -2,7 +2,6 @@ import logging
|
||||
import traceback
|
||||
import time
|
||||
import random
|
||||
from multiprocessing.pool import ThreadPool as Pool
|
||||
from .constructors import (
|
||||
ValidRadioNextRequest,
|
||||
ValidRadioReshuffleRequest,
|
||||
@ -129,14 +128,12 @@ class Radio(FastAPI):
|
||||
start: int = int(data.start)
|
||||
end: int = start + 20
|
||||
search: Optional[str] = data.search
|
||||
logging.info("queue request with start pos: %s & end pos: %s", start, end)
|
||||
|
||||
if not search:
|
||||
queue_full: list = self.radio_util.active_playlist
|
||||
else:
|
||||
queue_full: list = self.radio_util.datatables_search(data.search)
|
||||
queue: list = queue_full[start:end]
|
||||
logging.info("queue length: %s", len(queue))
|
||||
queue_out: list[dict] = []
|
||||
for x, item in enumerate(queue):
|
||||
queue_out.append(
|
||||
@ -313,9 +310,7 @@ class Radio(FastAPI):
|
||||
if len(self.radio_util.active_playlist) > 1:
|
||||
self.radio_util.active_playlist.append(next) # Push to end of playlist
|
||||
else:
|
||||
with Pool() as pool:
|
||||
pool.apply_async(self.radio_util.load_playlist())
|
||||
pool.close()
|
||||
self.loop.run_in_executor(None, self.radio_util.load_playlist)
|
||||
|
||||
self.radio_util.now_playing = next
|
||||
next["start"] = time_started
|
||||
@ -374,7 +369,7 @@ class Radio(FastAPI):
|
||||
await self.radio_util._ls_skip()
|
||||
return JSONResponse(content={"result": search})
|
||||
|
||||
async def radio_typeahead(
|
||||
def radio_typeahead(
|
||||
self, data: ValidRadioTypeaheadRequest, request: Request
|
||||
) -> JSONResponse:
|
||||
"""
|
||||
|
Reference in New Issue
Block a user