Skip to content

Commit

Permalink
Add utils for ASF IPC
Browse files Browse the repository at this point in the history
  • Loading branch information
woctezuma committed Jun 15, 2022
1 parent d4cbc2e commit 0df1de1
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/asf_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from src.utils import to_str
from ASF import IPC


def get_addlicense_command(appids):
return "addlicense a/" + ",a/".join(to_str(appids))


def get_play_command(appids):
return "play " + ",".join(to_str(appids))


def get_resume_command():
return "resume"


async def send_command(asf, cmd, verbose=True):
# Reference: https://github.com/deluxghost/ASF_IPC
resp = await asf.Api.Command.post(body={"Command": cmd})

if verbose:
if resp.success:
print(resp.result)
else:
print(f"Error: {resp.message}")

return resp


async def addlicense(asf, appids):
return await send_command(asf, get_addlicense_command(appids))


async def play(asf, appids):
return await send_command(asf, get_play_command(appids))


async def resume(asf):
return await send_command(asf, get_resume_command())


async def add_and_play(appids):
async with IPC() as asf:
await addlicense(asf, appids)
await play(asf, appids)
await resume(asf)

return

0 comments on commit 0df1de1

Please sign in to comment.