Commit 3fe386a5 authored by David Trattnig's avatar David Trattnig
Browse files

Channel and ChannelType handling.

parent 09c68757
......@@ -38,9 +38,9 @@ from sqlalchemy.orm import relationship
from sqlalchemy import create_engine
from libraries.enum.auraenumerations import ScheduleEntryType
from libraries.enum.auraenumerations import Channel, ChannelType
from modules.base.config import AuraConfig
from modules.base.simpleutil import SimpleUtil
from modules.base.simpleutil import SimpleUtil, EngineUtil
# Init Config
......@@ -462,23 +462,19 @@ class PlaylistEntry(DB.Model, AuraDatabaseModel):
@hybrid_property
def type(self):
if self.uri.startswith("http"):
return ScheduleEntryType.STREAM
if self.uri.startswith("pool") or self.uri.startswith("playlist") or self.uri.startswith("file"):
return ScheduleEntryType.FILESYSTEM
if self.uri.startswith("live") or self.uri.startswith("linein"):
if self.cleansource == "0":
return ScheduleEntryType.LIVE_0
elif self.cleansource == "1":
return ScheduleEntryType.LIVE_1
elif self.cleansource == "2":
return ScheduleEntryType.LIVE_2
elif self.cleansource == "3":
return ScheduleEntryType.LIVE_3
elif self.cleansource == "4":
return ScheduleEntryType.LIVE_4
return EngineUtil.get_channel_type(self.uri)
@hybrid_property
def channel(self):
type = EngineUtil.get_channel_type(self.uri)
if type == ChannelType.FILESYSTEM:
return Channel.FILESYSTEM_A
elif type == ChannelType.STREAM:
return Channel.STREAM_A
else:
return "foo:bar"
#FIXME Extend & finalize!!
def get_prev_entries(self):
"""
Retrieves all previous entries as part of the current entry's playlist.
......@@ -754,21 +750,18 @@ class SingleEntry(DB.Model, AuraDatabaseModel):
@hybrid_property
def type(self):
if self.uri.startswith("http"):
return ScheduleEntryType.STREAM
if self.uri.startswith("pool") or self.uri.startswith("playlist") or self.uri.startswith("file"):
return ScheduleEntryType.FILESYSTEM
if self.uri.startswith("live") or self.uri.startswith("linein"):
if self.cleansource == "0":
return ScheduleEntryType.LIVE_0
elif self.cleansource == "1":
return ScheduleEntryType.LIVE_1
elif self.cleansource == "2":
return ScheduleEntryType.LIVE_2
elif self.cleansource == "3":
return ScheduleEntryType.LIVE_3
elif self.cleansource == "4":
return ScheduleEntryType.LIVE_4
return EngineUtil.get_channel_type(self.uri)
@hybrid_property
def channel(self):
type = EngineUtil.get_channel_type(self.uri)
if type == ChannelType.FILESYSTEM:
return Channel.FILESYSTEM_A
elif type == ChannelType.STREAM:
return Channel.STREAM_A
else:
return "foo:bar"
#FIXME Extend & finalize!!
def as_dict(self):
......
......@@ -61,10 +61,23 @@ class RedisChannel(Enum):
SNF_REPLY = "get_next_file_reply"
class ScheduleEntryType(Enum):
# enumeration with names of liquidsoap inputs
class ChannelType(Enum):
"""
Engine channel types mapped to `Entry` source types.
"""
FILESYSTEM = "fs"
STREAM = "http"
LIVE = "live"
class Channel(Enum):
"""
Channel name mappings to the Liqidsoap channel IDs
"""
FILESYSTEM_A = "in_filesystem_0"
FILESYSTEM_B = "in_filesystem_1"
STREAM_A = "http_1"
STREAM_B = "http_2"
LIVE_0 = "aura_linein_0"
LIVE_1 = "aura_linein_1"
LIVE_2 = "aura_linein_2"
......
......@@ -33,11 +33,49 @@ __author__ = 'David Trattnig <david.trattnig@subsquare.at>'
import datetime
import time
from libraries.enum.auraenumerations import Channel, ChannelType
class EngineUtil:
"""
A class for Engine utilities.
"""
@staticmethod
def get_channel_type(uri):
"""
Returns the channel type, depending on the passed URI and source.
Args:
uri (String): The URI of the source
"""
if uri.startswith("http"):
return ChannelType.STREAM
if uri.startswith("pool") or uri.startswith("playlist") or uri.startswith("file"):
return ChannelType.FILESYSTEM
if uri.startswith("live") or uri.startswith("linein"):
return ChannelType.LIVE
# FIXME Mix of channels and channel-types!!!
# if source == "0":
# return Channel.LIVE_0
# elif source == "1":
# return Channel.LIVE_1
# elif source == "2":
# return Channel.LIVE_2
# elif source == "3":
# return Channel.LIVE_3
# elif source == "4":
# return Channel.LIVE_4
class SimpleUtil:
"""
A container for simple utility methods.
A container class for simple utility methods.
"""
......
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