Commit f593acdd authored by david's avatar david
Browse files

Fix for live channel selection. #81

parent e7ca792f
Pipeline #1029 failed with stage
......@@ -54,6 +54,33 @@ class Channel(Enum):
return str(self.value)
class ChannelResolver():
"""
Helpers for resolving channel enumerations.
"""
@staticmethod
def live_channel_for_resource(channel: str):
"""
Returns the channel enum for a given channel string.
"""
if not channel: return None
channel = "linein_" + channel.split("line://")[1]
if channel == Channel.LIVE_0.value:
return Channel.LIVE_0
elif channel == Channel.LIVE_1.value:
return Channel.LIVE_2
elif channel == Channel.LIVE_3.value:
return Channel.LIVE_3
elif channel == Channel.LIVE_4.value:
return Channel.LIVE_4
elif channel == Channel.LIVE_5.value:
return Channel.LIVE_5
else:
return None
class ChannelType(Enum):
"""
Engine channel types mapped to `Entry` source types.
......
......@@ -29,7 +29,7 @@ from src.base.config import AuraConfig
from src.base.utils import SimpleUtil as SU
from src.base.exceptions import LQConnectionError, InvalidChannelException, LQStreamException, LoadSourceException
from src.resources import ResourceClass, ResourceUtil
from src.channels import ChannelType, TransitionType, LiquidsoapResponse, EntryPlayState, ResourceType, ChannelRouter
from src.channels import ChannelType, TransitionType, LiquidsoapResponse, EntryPlayState, ResourceType, ChannelRouter, ChannelResolver
from src.events import EngineEventDispatcher
from src.control import EngineControlInterface
from src.mixer import Mixer, MixerType
......@@ -229,7 +229,10 @@ class Player:
# LIVE
if entry.get_content_type() in ResourceClass.LIVE.types:
entry.channel = "linein_" + entry.source.split("line://")[1]
entry.channel = ChannelResolver.live_channel_for_resource(entry.source)
if entry.channel == None:
self.logger.critical(SU.red("Invalid live channel '{entry.source}' requested!"))
entry.previous_channel = None
is_ready = True
else:
channel_type = self.channel_router.type_for_resource(entry.get_content_type())
......
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