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
3872a3be
Commit
3872a3be
authored
2 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Basic functionality to merge and insert metadata
parent
87ef126b
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/functions.liq
+65
-0
65 additions, 0 deletions
src/functions.liq
src/settings.liq
+1
-0
1 addition, 0 deletions
src/settings.liq
with
66 additions
and
0 deletions
src/functions.liq
+
65
−
0
View file @
3872a3be
...
...
@@ -22,6 +22,71 @@
# METADATA
#
# Merge with previous metadata, avoid duplicates
def merge_meta(last_meta, meta) =
log(level=5, label="metadata", "Merge | last metadata: #{last_meta}")
log(level=5, label="metadata", "Merge | current metadata: #{meta}")
merged = ref(last_meta)
def add_meta_entry(entry) =
let (k, _) = entry
if list.assoc.mem(k, !merged) then
log(level=5, label="metadata", "Remove existing entry #{entry}")
merged := list.assoc.remove(k, !merged)
end
merged := list.add(entry, !merged)
end
list.iter(add_meta_entry, (meta))
log(level=5, label="metadata", "Merge | resulting metadata: #{!merged}")
!merged
end
# Checks for the existence of show-specific metadata
def has_show_meta(meta) =
list.assoc.mem(engine_meta_key_show_id, meta) ? true : false
end
# Checks if the show ID in two metadata objects matches
def is_same_show(last_meta, current_meta) =
last_meta[engine_meta_key_show_id] == current_meta[engine_meta_key_show_id] ? true : false
end
# Checks if the current show metadata is same as the previous one
def is_same_show(last_meta, current_meta) =
if has_show_meta(last_meta) then
if not has_show_meta(current_meta) then
# No current show meta: handle as same show
true
elsif is_same_show(last_meta, current_meta) then
true
else
# A new show has started
false
end
else
# Last show has no show meta
if not has_show_meta(current_meta) then
# And the current one either: handle as same show
true
else
# Treat missing last show info as the same show
true
end
end
end
# Handles either insert or merge & insert of metadata, depending on the show ID
def do_meta_insert(last_meta_callback, insert_meta_callback, meta) =
lm = (last_meta_callback() ?? [])
if is_same_show(lm, meta) then
lm = (last_meta_callback() ?? [])
merged = merge_meta(lm, meta)
insert_meta_callback(merged)
else
insert_meta_callback(meta)
end
end
# Builds a metadata object from data passed as JSON
def build_metadata(json_string) =
...
...
This diff is collapsed.
Click to expand it.
src/settings.liq
+
1
−
0
View file @
3872a3be
...
...
@@ -156,6 +156,7 @@ print("Station Fallback Playlist: '#{fallback_station_playlist_path}'")
print("Station Fallback Directory: '#{fallback_station_dir}'")
# Metadata Configuration
engine_meta_key_show_id = list.assoc(default="show_id", "meta_key_show_id", ini)
engine_default_track_type = list.assoc(default="0", "default_track_type", ini)
engine_fallback_show_name = ref(list.assoc(default="Station Fallback", "fallback_show_name", ini))
engine_fallback_show_id = ref(list.assoc(default="-1", "fallback_show_id", ini))
...
...
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