3 Commits

Author SHA1 Message Date
0a4175e690 patch bump 2026-04-06 21:53:36 +01:00
c24c05a3ff as sync... oops 2026-04-06 21:53:00 +01:00
f44da13de9 add command endpoints
minor bump
2026-04-06 21:50:54 +01:00
6 changed files with 67 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
[project] [project]
name = "vmr-http" name = "vmr-http"
version = "0.7.2" version = "0.8.1"
description = "HTTP API for controlling Voicemeeter" description = "HTTP API for controlling Voicemeeter"
readme = "README.md" readme = "README.md"
authors = [{ name = "onyx-and-iris", email = "code@onyxandiris.online" }] authors = [{ name = "onyx-and-iris", email = "code@onyxandiris.online" }]

View File

@@ -7,7 +7,7 @@ from fastapi import Depends, FastAPI, HTTPException
from voicemeeterlib.error import CAPIError from voicemeeterlib.error import CAPIError
from .dependencies import get_voicemeeter_client from .dependencies import get_voicemeeter_client
from .web import bus, strip from .web import bus, command, strip
@asynccontextmanager @asynccontextmanager
@@ -29,6 +29,7 @@ app = FastAPI(
) )
app.include_router(strip.router, prefix='/strip/{index}') app.include_router(strip.router, prefix='/strip/{index}')
app.include_router(bus.router, prefix='/bus/{index}') app.include_router(bus.router, prefix='/bus/{index}')
app.include_router(command.router, prefix='/command')
@app.get('/health') @app.get('/health')

View File

@@ -1,5 +1,5 @@
"""API endpoints for controlling various Voicemeeter components.""" """API endpoints for controlling various Voicemeeter components."""
from . import bus, strip from . import bus, command, strip
__all__ = ['bus', 'strip'] __all__ = ['bus', 'command', 'strip']

View File

@@ -0,0 +1,5 @@
"""module for command-related endpoints."""
from .command import router
__all__ = ['router']

View File

@@ -0,0 +1,56 @@
"""module for command related endpoints."""
from fastapi import APIRouter, Depends
from vmr_http.dependencies import get_voicemeeter_client
router = APIRouter(tags=['command'])
###
# Although these endpoints are technically modifying the state of the Voicemeeter application,
# they are commands that trigger an action rather than resource updates.
# Therefore, they are implemented as POST.
###
@router.post('/show')
def show_command(voicemeeter=Depends(get_voicemeeter_client)):
"""Show the Voicemeeter application."""
voicemeeter.command.show()
return {'status': 'Voicemeeter shown'}
@router.post('/hide')
def hide_command(voicemeeter=Depends(get_voicemeeter_client)):
"""Hide the Voicemeeter application."""
voicemeeter.command.hide()
return {'status': 'Voicemeeter hidden'}
@router.post('/shutdown')
def shutdown_command(voicemeeter=Depends(get_voicemeeter_client)):
"""Shutdown the Voicemeeter application."""
voicemeeter.command.shutdown()
return {'status': 'Voicemeeter shutdown'}
@router.post('/restart')
def restart_command(voicemeeter=Depends(get_voicemeeter_client)):
"""Restart the Voicemeeter application."""
voicemeeter.command.restart()
return {'status': 'Voicemeeter restarted'}
@router.post('/lock')
def lock_command(voicemeeter=Depends(get_voicemeeter_client)):
"""Lock the Voicemeeter application."""
voicemeeter.command.lock = True
return {'status': 'Voicemeeter locked'}
@router.post('/unlock')
def unlock_command(voicemeeter=Depends(get_voicemeeter_client)):
"""Unlock the Voicemeeter application."""
voicemeeter.command.lock = False
return {'status': 'Voicemeeter unlocked'}

2
uv.lock generated
View File

@@ -1151,7 +1151,7 @@ wheels = [
[[package]] [[package]]
name = "vmr-http" name = "vmr-http"
version = "0.7.2" version = "0.8.1"
source = { editable = "." } source = { editable = "." }
dependencies = [ dependencies = [
{ name = "fastapi" }, { name = "fastapi" },