add artists to ui

This commit is contained in:
iou1name 2025-01-15 12:48:45 -05:00
parent aa02cf9fa4
commit 5c8c770f96
3 changed files with 13 additions and 1 deletions

View File

@ -32,6 +32,16 @@ async def get_random_track(request):
return track
async def get_artists(request):
"""Returns all artists in the database."""
async with request.app.state.db_pool.acquire() as conn:
artists = await conn.fetch(
"SELECT DISTINCT albumartist FROM track ORDER BY albumartist"
)
artists = [a['albumartist'] for a in artists]
return artists
def convert_filepath(path):
"""Convert a filepath to a URL."""
path = os.path.relpath(path, config.music_dir)

View File

@ -23,7 +23,8 @@ templates = Jinja2Templates(directory="templates")
@app.get("/", response_class=HTMLResponse)
async def index(request: Request):
context = {"request": request}
artists = await db.get_artists(request)
context = {'request': request, 'artists': artists}
return templates.TemplateResponse('index.html', context)

View File

@ -57,6 +57,7 @@ input[type="radio"]:checked+div {
display: flex;
align-items: center;
gap: 0.5em;
background-color: white;
}
.list_item:hover {