-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |