reformat (black)

This commit is contained in:
2025-04-17 14:35:56 -04:00
parent d12b066c8e
commit 1bb482315e
20 changed files with 1928 additions and 1326 deletions

View File

@ -4,6 +4,7 @@ from aiohttp import ClientSession, ClientTimeout
"""Radio Utils"""
async def get_now_playing() -> Optional[str]:
"""
Get radio now playing
@ -15,17 +16,21 @@ async def get_now_playing() -> Optional[str]:
np_url: str = "https://api.codey.lol/radio/np"
try:
async with ClientSession() as session:
async with await session.post(np_url, headers={
'content-type': 'application/json; charset=utf-8',
}, timeout=ClientTimeout(connect=1.5, sock_read=1.5)) as request:
async with await session.post(
np_url,
headers={
"content-type": "application/json; charset=utf-8",
},
timeout=ClientTimeout(connect=1.5, sock_read=1.5),
) as request:
request.raise_for_status()
response_json = await request.json()
artistsong = response_json.get('artistsong')
artistsong = response_json.get("artistsong")
return artistsong
except Exception as e:
logging.critical("Now playing retrieval failed: %s",
str(e))
return None
logging.critical("Now playing retrieval failed: %s", str(e))
return None
async def skip() -> bool:
"""
@ -38,13 +43,13 @@ async def skip() -> bool:
try:
ls_uri: str = "http://127.0.0.1:29000"
async with ClientSession() as session:
async with session.get(f"{ls_uri}/next",
timeout=ClientTimeout(connect=2, sock_read=2)) as request:
request.raise_for_status()
text: Optional[str] = await request.text()
return text == "OK"
async with session.get(
f"{ls_uri}/next", timeout=ClientTimeout(connect=2, sock_read=2)
) as request:
request.raise_for_status()
text: Optional[str] = await request.text()
return text == "OK"
except Exception as e:
logging.debug("Skip failed: %s", str(e))
return False # failsafe
logging.debug("Skip failed: %s", str(e))
return False # failsafe