Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
engine
Commits
b683d0e8
Commit
b683d0e8
authored
2 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Pass track metadata per channel on preloading
parent
ae57c4db
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/client/connector.py
+1
-0
1 addition, 0 deletions
src/client/connector.py
src/client/playerclient.py
+11
-7
11 additions, 7 deletions
src/client/playerclient.py
src/engine.py
+13
-7
13 additions, 7 deletions
src/engine.py
src/resources.py
+26
-7
26 additions, 7 deletions
src/resources.py
with
51 additions
and
21 deletions
src/client/connector.py
+
1
−
0
View file @
b683d0e8
...
...
@@ -98,6 +98,7 @@ class PlayerConnector:
"
stream_start
"
,
"
stream_stop
"
,
"
stream_status
"
,
"
set_track_metadata
"
,
]:
func
=
getattr
(
lqs_instance
,
command
)
...
...
This diff is collapsed.
Click to expand it.
src/client/playerclient.py
+
11
−
7
View file @
b683d0e8
...
...
@@ -118,6 +118,17 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
self
.
command
(
mixer_id
,
"
activate
"
,
str
(
pos
)
+
"
"
+
str
(
activate
).
lower
())
return
self
.
message
#
# Channel (general)
#
def
set_track_metadata
(
self
,
channel
,
json_meta
):
"""
Sets additional metadata for the current track
"""
self
.
command
(
channel
,
"
set_track_metadata
"
,
json_meta
)
return
self
.
message
#
# Queues
#
...
...
@@ -285,13 +296,6 @@ class LiquidSoapPlayerClient(LiquidSoapClient):
self
.
command
(
"
aura_engine
"
,
"
update_config
"
,
json_config
)
return
self
.
message
def
engine_set_track_metadata
(
self
,
json_meta
):
"""
Sets additional metadata for the current track
"""
self
.
command
(
"
aura_engine
"
,
"
set_track_metadata
"
,
json_meta
)
return
self
.
message
# def skip(self, namespace="playlist", pos=""):
# """
# Source skippen
...
...
This diff is collapsed.
Click to expand it.
src/engine.py
+
13
−
7
View file @
b683d0e8
...
...
@@ -247,12 +247,22 @@ class Player:
self
.
logger
.
info
(
"
Loading entry
'
%s
'"
%
entry
)
is_ready
=
False
def
set_metadata
():
track_meta
=
ResourceUtil
.
generate_track_metadata
(
entry
,
True
)
json_meta
=
json
.
dumps
(
track_meta
,
ensure_ascii
=
False
)
res
=
self
.
connector
.
send_lqc_command
(
entry
.
channel
,
"
set_track_metadata
"
,
json_meta
)
self
.
logger
.
info
(
f
"
Response for
'
{
entry
.
channel
}
.set_track_metadata
'
:
{
res
}
"
)
if
res
not
in
LiquidsoapResponse
.
SUCCESS
.
value
:
msg
=
f
"
Error while setting metadata on
{
entry
.
channel
}
to:
\n
{
json_meta
}
"
self
.
logger
.
error
(
SU
.
red
(
msg
))
# LIVE
if
entry
.
get_content_type
()
in
ResourceClass
.
LIVE
.
types
:
entry
.
channel
=
ChannelResolver
.
live_channel_for_resource
(
entry
.
source
)
if
entry
.
channel
is
None
:
self
.
logger
.
critical
(
SU
.
red
(
"
Invalid live channel
'
{entry.source}
'
requested!
"
))
entry
.
previous_channel
=
None
set_metadata
()
is_ready
=
True
else
:
channel_type
=
self
.
channel_router
.
type_for_resource
(
entry
.
get_content_type
())
...
...
@@ -268,6 +278,7 @@ class Player:
is_ready
=
self
.
stream_load_entry
(
entry
)
if
is_ready
:
set_metadata
()
entry
.
status
=
EntryPlayState
.
READY
self
.
event_dispatcher
.
on_queue
([
entry
])
...
...
@@ -335,11 +346,6 @@ class Player:
channel_type
=
self
.
channel_router
.
type_of_channel
(
entry
.
channel
)
mixer
=
self
.
mixer
current_metadata
=
ResourceUtil
.
generate_track_metadata
(
entry
)
json_meta
=
json
.
dumps
(
current_metadata
,
ensure_ascii
=
False
)
res
=
self
.
connector
.
send_lqc_command
(
"
engine
"
,
"
set_track_metadata
"
,
json_meta
)
self
.
logger
.
info
(
f
"
Liquidsoap
'
set_track_metadata
'
response: $
{
res
}
"
)
# Instant activation or fade-in
self
.
connector
.
enable_transaction
()
if
transition
==
TransitionType
.
FADE
:
...
...
@@ -432,13 +438,13 @@ class Player:
self
.
connector
.
enable_transaction
()
result
=
self
.
connector
.
send_lqc_command
(
channel
,
"
stream_stop
"
)
if
result
!=
LiquidsoapResponse
.
SUCCESS
.
value
:
if
result
not
in
LiquidsoapResponse
.
SUCCESS
.
value
:
self
.
logger
.
error
(
"
%s.stop result: %s
"
%
(
channel
,
result
))
raise
LQStreamException
(
"
Error while stopping stream!
"
)
result
=
self
.
connector
.
send_lqc_command
(
channel
,
"
stream_set_url
"
,
url
)
if
result
!=
LiquidsoapResponse
.
SUCCESS
.
value
:
if
result
not
in
LiquidsoapResponse
.
SUCCESS
.
value
:
self
.
logger
.
error
(
"
%s.set_url result: %s
"
%
(
channel
,
result
))
raise
LQStreamException
(
"
Error while setting stream URL!
"
)
...
...
This diff is collapsed.
Click to expand it.
src/resources.py
+
26
−
7
View file @
b683d0e8
...
...
@@ -185,7 +185,10 @@ class ResourceUtil(Enum):
return
uri
@staticmethod
def
generate_track_metadata
(
entry
)
->
dict
:
def
generate_track_metadata
(
entry
,
assign_track_start
:
bool
=
False
,
)
->
dict
:
"""
Generates Liquidsoap track metadata based on an entry.
"""
...
...
@@ -193,11 +196,27 @@ class ResourceUtil(Enum):
content_class
=
ResourceUtil
.
get_content_class
(
content_type
)
annotations
=
{
"
show_name
"
:
entry
.
playlist
.
timeslot
.
show_name
,
"
show_id
"
:
entry
.
playlist
.
timeslot
.
show_id
,
"
timeslot_id
"
:
entry
.
playlist
.
timeslot
.
timeslot_id
,
"
playlist_id
"
:
entry
.
playlist
.
playlist_id
,
"
playlist_item
"
:
float
(
entry
.
entry_num
),
"
track_type
"
:
content_class
.
numeric
,
"
show_name
"
:
str
(
entry
.
playlist
.
timeslot
.
show_name
),
"
show_id
"
:
int
(
entry
.
playlist
.
timeslot
.
show_id
),
"
timeslot_id
"
:
int
(
entry
.
playlist
.
timeslot
.
timeslot_id
),
"
playlist_id
"
:
int
(
entry
.
playlist
.
playlist_id
),
"
playlist_item
"
:
str
(
float
(
entry
.
entry_num
)),
"
track_type
"
:
int
(
content_class
.
numeric
),
"
track_start
"
:
""
,
"
track_duration
"
:
-
1
,
"
track_title
"
:
""
,
"
track_album
"
:
""
,
"
track_artist
"
:
""
,
}
if
assign_track_start
:
# Convert to current Liquidsoap date/time format
annotations
[
"
track_start
"
]
=
entry
.
entry_start
.
strftime
(
"
%Y/%m/%d %H:%M:%S
"
)
if
entry
.
duration
and
entry
.
duration
>
0
:
annotations
[
"
track_duration
"
]
=
entry
.
duration
if
entry
.
meta_data
:
annotations
[
"
track_title
"
]
=
str
(
entry
.
meta_data
.
title
)
annotations
[
"
track_album
"
]
=
str
(
entry
.
meta_data
.
album
)
annotations
[
"
track_artist
"
]
=
str
(
entry
.
meta_data
.
artist
)
return
annotations
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment