Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
engine-core
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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-core
Commits
c9441123
Commit
c9441123
authored
2 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Refact: Global events in separate file
parent
364a136b
No related branches found
No related tags found
1 merge request
!3
Liquidsoap 2 migration
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/engine.liq
+2
-62
2 additions, 62 deletions
src/engine.liq
src/events.liq
+77
-0
77 additions, 0 deletions
src/events.liq
with
79 additions
and
62 deletions
src/engine.liq
+
2
−
62
View file @
c9441123
...
@@ -36,68 +36,8 @@ engine_state = {
...
@@ -36,68 +36,8 @@ engine_state = {
# Include dependency-free functions
# Include dependency-free functions
%include "functions.liq"
%include "functions.liq"
#####################################
# Handle events
# EVENTS #
%include "events.liq"
#####################################
# Updates the playout state
def on_playout_state_change(source_type) =
if source_type == "fallback" then
engine_state.is_fallback := true
else
engine_state.is_fallback := false
end
end
# Called when some new metadata info is available
def on_metadata_notification(meta) =
# FIXME For some reason stream channels do not pass the `source` property in meta
channel_name = meta["source"]
source_type = eval_source_type(channel_name)
on_playout_state_change(source_type)
log(level=3, label="metadata", "Raw metadata before POST:\n\n #{meta}\n\n")
show_name = ref(list.assoc(default="", "show_name", meta))
show_id = ref(list.assoc(default="", "show_id", meta))
timeslot_id = list.assoc(default="-1", "timeslot_id", meta)
playlist_id = list.assoc(default="-1", "playlist_id", meta)
playlist_track_num = list.assoc(default="", "playlist_item", meta)
track_start = list.assoc(default=meta["track_start"], "on_air", meta)
track_duration = get_meta_track_duration(meta)
track_type = eval_track_type(meta["track_type"], meta["source"])
track_artist = list.assoc(default=meta["track_artist"], "artist", meta)
track_album = list.assoc(default=meta["track_album"], "album", meta)
track_title = list.assoc(default=meta["track_title"], "title", meta)
if source_type == "fallback" then
log(level=3, label="metadata", "Detected FALLBACK channel `#{channel_name}` playing \
(Show ID: #{!fallback_show_id})")
show_name := !fallback_show_name
show_id := !fallback_show_id
end
playlog = [
("log_source", engine_id),
("show_name", !show_name),
("show_id", !show_id),
("timeslot_id", timeslot_id),
("playlist_id", playlist_id),
("track_type", track_type),
("track_start", track_start),
("track_duration", "#{track_duration}"),
("track_title", track_title),
("track_album", track_album),
("track_artist", track_artist),
("track_num", playlist_track_num)
]
if playlog["show_id"] == "" then
log(level=3, label="metadata", "Skip posting playlog because of missing show ID!")
else
post_playlog(engine_api_playlog, playlog)
end
end
#####################################
#####################################
# INPUTS #
# INPUTS #
...
...
This diff is collapsed.
Click to expand it.
src/events.liq
0 → 100644
+
77
−
0
View file @
c9441123
#
# Aura Engine (https://gitlab.servus.at/aura/engine)
#
# Copyright (C) 2017-now() - The Aura Engine Team.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Updates the playout state
def on_playout_state_change(source_type) =
if source_type == "fallback" then
engine_state.is_fallback := true
else
engine_state.is_fallback := false
end
end
# Called when some new metadata info is available
def on_metadata_notification(meta) =
# FIXME For some reason stream channels do not pass the `source` property in meta
channel_name = meta["source"]
source_type = eval_source_type(channel_name)
on_playout_state_change(source_type)
log(level=3, label="metadata", "Raw metadata before POST:\n\n #{meta}\n\n")
show_name = ref(list.assoc(default="", "show_name", meta))
show_id = ref(list.assoc(default="", "show_id", meta))
timeslot_id = list.assoc(default="-1", "timeslot_id", meta)
playlist_id = list.assoc(default="-1", "playlist_id", meta)
playlist_track_num = list.assoc(default="", "playlist_item", meta)
track_start = list.assoc(default=meta["track_start"], "on_air", meta)
track_duration = get_meta_track_duration(meta)
track_type = eval_track_type(meta["track_type"], meta["source"])
track_artist = list.assoc(default=meta["track_artist"], "artist", meta)
track_album = list.assoc(default=meta["track_album"], "album", meta)
track_title = list.assoc(default=meta["track_title"], "title", meta)
if source_type == "fallback" then
log(level=3, label="metadata", "Detected FALLBACK channel `#{channel_name}` playing \
(Show ID: #{!fallback_show_id})")
show_name := !fallback_show_name
show_id := !fallback_show_id
end
playlog = [
("log_source", engine_id),
("show_name", !show_name),
("show_id", !show_id),
("timeslot_id", timeslot_id),
("playlist_id", playlist_id),
("track_type", track_type),
("track_start", track_start),
("track_duration", "#{track_duration}"),
("track_title", track_title),
("track_album", track_album),
("track_artist", track_artist),
("track_num", playlist_track_num)
]
if playlog["show_id"] == "" then
log(level=3, label="metadata", "Skip posting playlog because of missing show ID!")
else
post_playlog(engine_api_playlog, playlog)
end
end
\ No newline at end of file
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