diff --git a/__main__.py b/__main__.py index d2eca1c..c1d7be8 100644 --- a/__main__.py +++ b/__main__.py @@ -2,30 +2,30 @@ import streamlabsio def on_youtube_event(event, data): - print(f"{event}: {data.attrs()}") + print(f'{event}: {data.attrs()}') def on_twitch_event(event, data): - if event == "follow": - print(f"Received follow from {data.name}") - elif event == "bits": - print(f"{data.name} donated {data.amount} bits! With message: {data.message}") - elif event == "donation": + if event == 'follow': + print(f'Received follow from {data.name}') + elif event == 'bits': + print(f'{data.name} donated {data.amount} bits! With message: {data.message}') + elif event == 'donation': print( - f"{data.name} donated {data.formatted_amount}! With message: {data.message}" + f'{data.name} donated {data.formatted_amount}! With message: {data.message}' ) def main(): # read token from config.toml with streamlabsio.connect() as client: - client.obs.on("streamlabs", on_twitch_event) - client.obs.on("twitch_account", on_twitch_event) - client.obs.on("youtube_account", on_youtube_event) + client.obs.on('streamlabs', on_twitch_event) + client.obs.on('twitch_account', on_twitch_event) + client.obs.on('youtube_account', on_youtube_event) # run for 30 seconds then disconnect client from server client.sio.sleep(30) -if __name__ == "__main__": +if __name__ == '__main__': main() diff --git a/examples/debug/__main__.py b/examples/debug/__main__.py index ad13d74..cd0f707 100644 --- a/examples/debug/__main__.py +++ b/examples/debug/__main__.py @@ -4,47 +4,53 @@ import streamlabsio config.dictConfig( { - "version": 1, - "formatters": { - "standard": { - "format": "%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s" + 'version': 1, + 'disable_existing_loggers': False, + 'loggers': { + 'streamlabsio.client': { + 'level': 'DEBUG', + 'handlers': ['console'], + 'propagate': False, } }, - "handlers": { - "stream": { - "level": "DEBUG", - "class": "logging.StreamHandler", - "formatter": "standard", + 'handlers': { + 'console': { + 'class': 'logging.StreamHandler', + 'level': 'DEBUG', + 'formatter': 'simple', + 'stream': 'ext://sys.stdout', } }, - "loggers": {"streamlabsio.client": {"handlers": ["stream"], "level": "DEBUG"}}, + 'formatters': { + 'simple': {'format': '%(asctime)s - %(name)s - %(levelname)s - %(message)s'} + }, } ) def on_youtube_event(event, data): - print(f"{event}: {data.attrs()}") + print(f'{event}: {data.attrs()}') def on_twitch_event(event, data): - if event == "follow": - print(f"Received follow from {data.name}") - elif event == "bits": - print(f"{data.name} donated {data.amount} bits! With message: {data.message}") - elif event == "donation": + if event == 'follow': + print(f'Received follow from {data.name}') + elif event == 'bits': + print(f'{data.name} donated {data.amount} bits! With message: {data.message}') + elif event == 'donation': print( - f"{data.name} donated {data.formatted_amount}! With message: {data.message}" + f'{data.name} donated {data.formatted_amount}! With message: {data.message}' ) def main(): with streamlabsio.connect() as client: - client.obs.on("streamlabs", on_twitch_event) - client.obs.on("twitch_account", on_twitch_event) - client.obs.on("youtube_account", on_youtube_event) + client.obs.on('streamlabs', on_twitch_event) + client.obs.on('twitch_account', on_twitch_event) + client.obs.on('youtube_account', on_youtube_event) client.sio.sleep(30) -if __name__ == "__main__": +if __name__ == '__main__': main() diff --git a/scripts.py b/scripts.py index 13748b3..5e3d7d9 100644 --- a/scripts.py +++ b/scripts.py @@ -4,5 +4,5 @@ from pathlib import Path def ex_debug(): - scriptpath = Path.cwd() / "examples" / "debug" / "." + scriptpath = Path.cwd() / 'examples' / 'debug' / '.' subprocess.run([sys.executable, str(scriptpath)]) diff --git a/streamlabsio/models.py b/streamlabsio/models.py index fb0fb0c..43b023f 100644 --- a/streamlabsio/models.py +++ b/streamlabsio/models.py @@ -3,7 +3,7 @@ from dataclasses import dataclass def to_snake_case(s): - return re.sub(r"(?