Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Lars Kruse
aura-engine
Commits
f593acdd
Commit
f593acdd
authored
Jul 08, 2021
by
david
Browse files
Fix for live channel selection. #81
parent
e7ca792f
Changes
3
Show whitespace changes
Inline
Side-by-side
src/channels.py
View file @
f593acdd
...
...
@@ -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.
...
...
src/engine.py
View file @
f593acdd
...
...
@@ -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
())
...
...
src/resources.py
View file @
f593acdd
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment