add a little colour to the output

patch bump
This commit is contained in:
onyx-and-iris 2025-06-25 17:22:32 +01:00
parent 130bf74f27
commit 430aaf5cc5
2 changed files with 12 additions and 5 deletions

View File

@ -1,6 +1,6 @@
[project] [project]
name = "simple-recorder" name = "simple-recorder"
version = "0.1.0" version = "0.1.1"
description = "A simple OBS recorder" description = "A simple OBS recorder"
authors = [{ name = "onyx-and-iris", email = "code@onyxandiris.online" }] authors = [{ name = "onyx-and-iris", email = "code@onyxandiris.online" }]
dependencies = [ dependencies = [

View File

@ -1,6 +1,7 @@
import logging import logging
from datetime import datetime from datetime import datetime
import clypi
import FreeSimpleGUI as fsg import FreeSimpleGUI as fsg
import obsws_python as obsws import obsws_python as obsws
from clypi import ClypiConfig, ClypiException, Command, Positional, arg, configure from clypi import ClypiConfig, ClypiException, Command, Positional, arg, configure
@ -13,6 +14,9 @@ config = ClypiConfig(
) )
configure(config) configure(config)
highlight = clypi.Styler(fg="green")
error = clypi.Styler(fg="red", bold=True)
class Start(Command): class Start(Command):
"""Start recording.""" """Start recording."""
@ -33,21 +37,23 @@ class Start(Command):
@override @override
async def run(self): async def run(self):
if not self.filename: if not self.filename:
raise ClypiException("Recording name cannot be empty.") raise ClypiException(error("Recording name cannot be empty."))
with obsws.ReqClient( with obsws.ReqClient(
host=self.host, port=self.port, password=self.password host=self.host, port=self.port, password=self.password
) as client: ) as client:
resp = client.get_record_status() resp = client.get_record_status()
if resp.output_active: if resp.output_active:
raise ClypiException("Recording is already active.") raise ClypiException(error("Recording is already active."))
filename = f"{self.filename} {self.get_timestamp()}"
client.set_profile_parameter( client.set_profile_parameter(
"Output", "Output",
"FilenameFormatting", "FilenameFormatting",
f"{self.filename} {self.get_timestamp()}", filename,
) )
client.start_record() client.start_record()
print(f"Recording started with filename: {highlight(filename)}")
class Stop(Command): class Stop(Command):
@ -64,9 +70,10 @@ class Stop(Command):
) as client: ) as client:
resp = client.get_record_status() resp = client.get_record_status()
if not resp.output_active: if not resp.output_active:
raise ClypiException("Recording is not active.") raise ClypiException(error("Recording is not active."))
client.stop_record() client.stop_record()
print("Recording stopped successfully.")
def theme_parser(value: str) -> str: def theme_parser(value: str) -> str: