diff --git a/.gitignore b/.gitignore index 61f2dc9..4f60f87 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ **/__pycache__/ +build +*.egg-info diff --git a/README.md b/README.md index 4a68c88..c051468 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,9 @@ Only compatible with separate [Stream Deck Plugin](https://github.com/Patrick762 ## Dependencies - [websockets](https://pypi.org/project/websockets/) 11.0.2 + + +## Server +This library also contains a server to use the streamdeck with linux or without the official Stream Deck Software. + +For this to work, the LibUSB HIDAPI is required. [Installation instructions](https://python-elgato-streamdeck.readthedocs.io/en/stable/pages/backend_libusb_hidapi.html) diff --git a/setup.py b/setup.py index 1f95206..7585a7b 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ here = os.path.abspath(os.path.dirname(__file__)) with codecs.open(os.path.join(here, "README.md"), encoding="utf-8") as fh: long_description = "\n" + fh.read() -VERSION = '0.0.2' +VERSION = '0.0.3' DESCRIPTION = 'Stream Deck API Library' # Setting up @@ -21,8 +21,12 @@ setup( long_description=long_description, url="https://github.com/Patrick762/streamdeckapi", packages=find_packages(), - install_requires=["websockets==11.0.2"], + install_requires=["websockets==11.0.2", + "streamdeck==0.9.3", "pillow>=9.4.0,<10.0.0"], keywords=[], + entry_points={ + "console_scripts": ["streamdeckapi-server = streamdeckapi.server:start"] + }, classifiers=[ "Development Status :: 1 - Planning", "Intended Audience :: Developers", diff --git a/streamdeckapi/api.py b/streamdeckapi/api.py index 8ac56c7..8ffcc8d 100644 --- a/streamdeckapi/api.py +++ b/streamdeckapi/api.py @@ -9,11 +9,9 @@ import requests from websockets.client import connect from websockets.exceptions import WebSocketException -from .types import SDInfo, SDWebsocketMessage +from streamdeckapi.const import PLUGIN_ICON, PLUGIN_INFO, PLUGIN_PORT -_PLUGIN_PORT = 6153 -_PLUGIN_INFO = "/sd/info" -_PLUGIN_ICON = "/sd/icon" +from .types import SDInfo, SDWebsocketMessage _LOGGER = logging.getLogger(__name__) @@ -53,17 +51,17 @@ class StreamDeckApi: @property def _info_url(self) -> str: """URL to info endpoint.""" - return f"http://{self._host}:{_PLUGIN_PORT}{_PLUGIN_INFO}" + return f"http://{self._host}:{PLUGIN_PORT}{PLUGIN_INFO}" @property def _icon_url(self) -> str: """URL to icon endpoint.""" - return f"http://{self._host}:{_PLUGIN_PORT}{_PLUGIN_ICON}/" + return f"http://{self._host}:{PLUGIN_PORT}{PLUGIN_ICON}/" @property def _websocket_url(self) -> str: """URL to websocket.""" - return f"ws://{self._host}:{_PLUGIN_PORT}" + return f"ws://{self._host}:{PLUGIN_PORT}" # # API Methods diff --git a/streamdeckapi/const.py b/streamdeckapi/const.py new file mode 100644 index 0000000..984ca48 --- /dev/null +++ b/streamdeckapi/const.py @@ -0,0 +1,5 @@ +"""Stream Deck API const.""" + +PLUGIN_PORT = 6153 +PLUGIN_INFO = "/sd/info" +PLUGIN_ICON = "/sd/icon" diff --git a/streamdeckapi/server.py b/streamdeckapi/server.py new file mode 100644 index 0000000..a0a2b87 --- /dev/null +++ b/streamdeckapi/server.py @@ -0,0 +1,11 @@ +"""Stream Deck API Server.""" + +from StreamDeck.DeviceManager import DeviceManager +from streamdeckapi.const import PLUGIN_ICON, PLUGIN_INFO, PLUGIN_PORT + +def start(): + streamdecks = DeviceManager().enumerate() + + print("Found {} Stream Deck(s).\n".format(len(streamdecks))) + + print("Started Stream Deck API server on port", PLUGIN_PORT)