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
class LiquidSoapClient:
"""
"""
LiquidSoapClient Class
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
logger = None
......@@ -191,7 +193,7 @@ class LiquidSoapClient:
param = (param.strip() if param.strip() == "" else " " + urllib.parse.unquote(param.strip()))
if self.connected:
# print namespace + '.' + command + param + "\n"
if namespace is "":
if namespace == "":
message = str(command) + str(param) + str("\n")
else:
message = str(namespace) + str(".") + str(command) + str(param) + str("\n")
......
......@@ -22,7 +22,7 @@ import time
from src.base.config import AuraConfig
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
......@@ -30,6 +30,8 @@ from src.client.playerclient import LiquidSoapPlayerClient
class PlayerConnector():
"""
Establishes a Socket connection to Liquidsoap.
#TODO Refactor class: https://gitlab.servus.at/aura/engine/-/issues/65
"""
client = None
logger = None
......@@ -80,26 +82,26 @@ class PlayerConnector():
# FIXME REFACTOR all calls in a common way
if command in [
"queue_push",
"queue_seek",
"queue_clear",
"playlist_uri_set",
"queue_push",
"queue_seek",
"queue_clear",
"playlist_uri_set",
"playlist_uri_clear",
"stream_set_url",
"stream_start",
"stream_stop",
"stream_set_url",
"stream_start",
"stream_stop",
"stream_status",
]:
func = getattr(lqs_instance, command)
result = func(str(namespace), *args)
elif namespace == "mixer" or namespace == "mixer_fallback":
elif namespace == "mixer" or namespace == "mixer_fallback":
func = getattr(lqs_instance, command)
result = func(str(namespace), *args)
else:
func = getattr(lqs_instance, namespace)
result = func(command, *args)
result = func(command, *args)
if not self.disable_logging:
......
......@@ -22,6 +22,8 @@ from src.client.client import LiquidSoapClient
class LiquidSoapPlayerClient(LiquidSoapClient):
#TODO Refactor class: https://gitlab.servus.at/aura/engine/-/issues/65
#
# Mixer
#
......@@ -143,7 +145,7 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
self.command(channel, 'seek', str(duration))
return self.message
def queue_clear(self, channel):
"""
Clears all `equeue` playlist entries of the given channel.
......@@ -174,7 +176,7 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
Returns:
Liquidsoap server response
"""
self.command(channel, 'uri', uri)
self.command(channel, 'uri', uri)
return self.message
......@@ -189,7 +191,7 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
Returns:
Liquidsoap server response
"""
self.command(channel, 'clear')
self.command(channel, 'clear')
return self.message
......
Markdown is supported
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