Skip to content

Commit

Permalink
v2.2.0 – Experimental JSON passing from Liquidsoap
Browse files Browse the repository at this point in the history
  • Loading branch information
Moonbase59 committed Jun 10, 2024
1 parent f8b84e1 commit aff9320
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
29 changes: 28 additions & 1 deletion autocue.cue_file.liq
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
# 2024-06-05 - Moonbase59 - v2.0.2 Initial display of version, at log level 2.
# 2024-06-08 - Moonbase59 - v2.0.3 Sync version number with cue_file
# 2024-06-09 - Moonbase59 - v2.1.0 Sync version number with cue_file
# 2024-06-11 - Moonbase59 - v2.2.0 JSON override tags for cue_file in temp file:
# Allows passing annotate/database overrides to
# cue_file, to reduce re-analysis runs even more.

# Lots of debugging output for AzuraCast in this, will be removed eventually.

Expand All @@ -32,7 +35,7 @@ let settings.autocue.cue_file.version =
settings.make(
description=
"Software version of autocue.cue_file. Should coincide with `cue_file`.",
"2.1.0"
"2.2.0"
)

let settings.autocue.cue_file.path =
Expand Down Expand Up @@ -157,6 +160,18 @@ let settings.autocue.cue_file.nice =

stdlib_metadata = metadata

# metadata.json.stringify only exports a limited set, use our own
def meta_json_stringify(
~compact=false,
~json5=false,
m
) =
m = metadata.cover.remove(m)
data = json()
list.iter(fun (v) -> data.add(fst(v), snd(v)), m)
json.stringify(json5=json5, compact=compact, data)
end

# Compute cue_file data
# @flag extra
def cue_file(~request_metadata, ~file_metadata, filename) =
Expand Down Expand Up @@ -287,6 +302,17 @@ def cue_file(~request_metadata, ~file_metadata, filename) =
if force_analysis then args := list.add('-f', args()) end
if nice then args := list.add('-n', args()) end

# write metadata to temp file for cue_file to pick up
tempfile = file.temp("cue_file", ".json")
json_meta = meta_json_stringify(compact=true, meta)
log(level=4, label=label, "#{tempfile}: #{json_meta}")
file.write(
data=json_meta,
append=true,
tempfile
)
args := ['-j', tempfile, ...args()]

res = ref("")
try
res :=
Expand All @@ -305,6 +331,7 @@ def cue_file(~request_metadata, ~file_metadata, filename) =
)
res := ""
end
file.remove(tempfile)

if
res() != ""
Expand Down
3 changes: 2 additions & 1 deletion cue_file
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@
# - Make variable checking more robust (bool & unit suffixes)
# - Add `liq_fade_in` & `liq_fade_out` tags for reading/writing,
# in case a preprocessor needs to set fade durations.
# 2024-06-11 Moonbase59 - v2.2.0 Sync version numver with autocue.cue_file
#
# Originally based on an idea and some code by John Warburton (@Warblefly):
# https://github.com/Warblefly/TrackBoundaries

__author__ = 'Matthias C. Hormann'
__version__ = '2.1.0'
__version__ = '2.2.0'

import os
import tempfile
Expand Down

0 comments on commit aff9320

Please sign in to comment.