mirror of
https://github.com/onyx-and-iris/simple-recorder.git
synced 2025-06-27 18:00:23 +01:00
implement pause + resume
This commit is contained in:
parent
b161c1ec3d
commit
ef68915f6a
30
src/simple_recorder/pause.py
Normal file
30
src/simple_recorder/pause.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import obsws_python as obsws
|
||||||
|
from clypi import Command, arg
|
||||||
|
from typing_extensions import override
|
||||||
|
|
||||||
|
from .errors import SimpleRecorderError
|
||||||
|
|
||||||
|
|
||||||
|
class Pause(Command):
|
||||||
|
"""Pause recording."""
|
||||||
|
|
||||||
|
host: str = arg(inherited=True)
|
||||||
|
port: int = arg(inherited=True)
|
||||||
|
password: str = arg(inherited=True)
|
||||||
|
|
||||||
|
@override
|
||||||
|
async def run(self):
|
||||||
|
try:
|
||||||
|
with obsws.ReqClient(
|
||||||
|
host=self.host, port=self.port, password=self.password, timeout=3
|
||||||
|
) as client:
|
||||||
|
resp = client.get_record_status()
|
||||||
|
if not resp.output_active:
|
||||||
|
raise SimpleRecorderError("No active recording to pause.")
|
||||||
|
if resp.output_paused:
|
||||||
|
raise SimpleRecorderError("Recording is already paused.")
|
||||||
|
|
||||||
|
client.pause_record()
|
||||||
|
print("Recording paused successfully.")
|
||||||
|
except TimeoutError:
|
||||||
|
raise SimpleRecorderError("Failed to connect to OBS. Is it running?")
|
30
src/simple_recorder/resume.py
Normal file
30
src/simple_recorder/resume.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import obsws_python as obsws
|
||||||
|
from clypi import Command, arg
|
||||||
|
from typing_extensions import override
|
||||||
|
|
||||||
|
from .errors import SimpleRecorderError
|
||||||
|
|
||||||
|
|
||||||
|
class Resume(Command):
|
||||||
|
"""Resume recording."""
|
||||||
|
|
||||||
|
host: str = arg(inherited=True)
|
||||||
|
port: int = arg(inherited=True)
|
||||||
|
password: str = arg(inherited=True)
|
||||||
|
|
||||||
|
@override
|
||||||
|
async def run(self):
|
||||||
|
try:
|
||||||
|
with obsws.ReqClient(
|
||||||
|
host=self.host, port=self.port, password=self.password, timeout=3
|
||||||
|
) as client:
|
||||||
|
resp = client.get_record_status()
|
||||||
|
if not resp.output_active:
|
||||||
|
raise SimpleRecorderError("No active recording to resume.")
|
||||||
|
if not resp.output_paused:
|
||||||
|
raise SimpleRecorderError("Recording is not paused.")
|
||||||
|
|
||||||
|
client.resume_record()
|
||||||
|
print("Recording resumed successfully.")
|
||||||
|
except TimeoutError:
|
||||||
|
raise SimpleRecorderError("Failed to connect to OBS. Is it running?")
|
Loading…
x
Reference in New Issue
Block a user