1
Fork 0

Add tauon-controls script.

This commit is contained in:
Bauke 2022-09-03 19:16:21 +02:00
parent 8696f234c8
commit 12131285de
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
1 changed files with 35 additions and 0 deletions

35
.local/bin/tauon-controls Executable file
View File

@ -0,0 +1,35 @@
#!/usr/bin/env python3
import argparse
import requests
HIDDEN_API = "http://0.0.0.0:7813"
REMOTE_API = "http://0.0.0.0:7814/api1"
def main() -> None:
parser = argparse.ArgumentParser(description="Small Tauon remote control CLI")
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument("--next-song", action="store_true")
group.add_argument("--play-pause", action="store_true")
group.add_argument("--previous-song", action="store_true")
group.add_argument("--volume", type=int)
args = parser.parse_args()
if args.next_song:
call_api(f"{REMOTE_API}/next")
if args.play_pause:
call_api(f"{HIDDEN_API}/playpause/")
if args.previous_song:
call_api(f"{REMOTE_API}/back")
if args.volume is not None:
call_api(f"{REMOTE_API}/setvolumerel/{args.volume}")
def call_api(endpoint: str) -> None:
response = requests.get(endpoint)
print(f"HTTP {response.status_code} ({endpoint})")
if __name__ == "__main__":
main()