Commit b988f0dc authored by david's avatar david
Browse files

Namespace fix and refactor note. #65 #72

parent d38fcf67
...@@ -31,10 +31,12 @@ from src.base.utils import TerminalColors ...@@ -31,10 +31,12 @@ from src.base.utils import TerminalColors
class LiquidSoapClient: class LiquidSoapClient:
""" """
LiquidSoapClient Class LiquidSoapClient Class
Connects to a LiquidSoap instance over a socket and sends commands to it Connects to a LiquidSoap instance over a socket and sends commands to it
#TODO Refactor class: https://gitlab.servus.at/aura/engine/-/issues/65
""" """
mutex = None mutex = None
logger = None logger = None
...@@ -191,7 +193,7 @@ class LiquidSoapClient: ...@@ -191,7 +193,7 @@ class LiquidSoapClient:
param = (param.strip() if param.strip() == "" else " " + urllib.parse.unquote(param.strip())) param = (param.strip() if param.strip() == "" else " " + urllib.parse.unquote(param.strip()))
if self.connected: if self.connected:
# print namespace + '.' + command + param + "\n" # print namespace + '.' + command + param + "\n"
if namespace is "": if namespace == "":
message = str(command) + str(param) + str("\n") message = str(command) + str(param) + str("\n")
else: else:
message = str(namespace) + str(".") + str(command) + str(param) + str("\n") message = str(namespace) + str(".") + str(command) + str(param) + str("\n")
......
...@@ -22,7 +22,7 @@ import time ...@@ -22,7 +22,7 @@ import time
from src.base.config import AuraConfig from src.base.config import AuraConfig
from src.base.utils import TerminalColors, SimpleUtil as SU from src.base.utils import TerminalColors, SimpleUtil as SU
from src.base.exceptions import LQConnectionError from src.base.exceptions import LQConnectionError
from src.client.playerclient import LiquidSoapPlayerClient from src.client.playerclient import LiquidSoapPlayerClient
...@@ -30,6 +30,8 @@ from src.client.playerclient import LiquidSoapPlayerClient ...@@ -30,6 +30,8 @@ from src.client.playerclient import LiquidSoapPlayerClient
class PlayerConnector(): class PlayerConnector():
""" """
Establishes a Socket connection to Liquidsoap. Establishes a Socket connection to Liquidsoap.
#TODO Refactor class: https://gitlab.servus.at/aura/engine/-/issues/65
""" """
client = None client = None
logger = None logger = None
...@@ -80,26 +82,26 @@ class PlayerConnector(): ...@@ -80,26 +82,26 @@ class PlayerConnector():
# FIXME REFACTOR all calls in a common way # FIXME REFACTOR all calls in a common way
if command in [ if command in [
"queue_push", "queue_push",
"queue_seek", "queue_seek",
"queue_clear", "queue_clear",
"playlist_uri_set", "playlist_uri_set",
"playlist_uri_clear", "playlist_uri_clear",
"stream_set_url", "stream_set_url",
"stream_start", "stream_start",
"stream_stop", "stream_stop",
"stream_status", "stream_status",
]: ]:
func = getattr(lqs_instance, command) func = getattr(lqs_instance, command)
result = func(str(namespace), *args) result = func(str(namespace), *args)
elif namespace == "mixer" or namespace == "mixer_fallback": elif namespace == "mixer" or namespace == "mixer_fallback":
func = getattr(lqs_instance, command) func = getattr(lqs_instance, command)
result = func(str(namespace), *args) result = func(str(namespace), *args)
else: else:
func = getattr(lqs_instance, namespace) func = getattr(lqs_instance, namespace)
result = func(command, *args) result = func(command, *args)
if not self.disable_logging: if not self.disable_logging:
......
...@@ -22,6 +22,8 @@ from src.client.client import LiquidSoapClient ...@@ -22,6 +22,8 @@ from src.client.client import LiquidSoapClient
class LiquidSoapPlayerClient(LiquidSoapClient): class LiquidSoapPlayerClient(LiquidSoapClient):
#TODO Refactor class: https://gitlab.servus.at/aura/engine/-/issues/65
# #
# Mixer # Mixer
# #
...@@ -143,7 +145,7 @@ class LiquidSoapPlayerClient(LiquidSoapClient): ...@@ -143,7 +145,7 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
self.command(channel, 'seek', str(duration)) self.command(channel, 'seek', str(duration))
return self.message return self.message
def queue_clear(self, channel): def queue_clear(self, channel):
""" """
Clears all `equeue` playlist entries of the given channel. Clears all `equeue` playlist entries of the given channel.
...@@ -174,7 +176,7 @@ class LiquidSoapPlayerClient(LiquidSoapClient): ...@@ -174,7 +176,7 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
Returns: Returns:
Liquidsoap server response Liquidsoap server response
""" """
self.command(channel, 'uri', uri) self.command(channel, 'uri', uri)
return self.message return self.message
...@@ -189,7 +191,7 @@ class LiquidSoapPlayerClient(LiquidSoapClient): ...@@ -189,7 +191,7 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
Returns: Returns:
Liquidsoap server response Liquidsoap server response
""" """
self.command(channel, 'clear') self.command(channel, 'clear')
return self.message return self.message
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment