Skip to content

Commit

Permalink
Fix JSON override if liq_cue_file is true
Browse files Browse the repository at this point in the history
  • Loading branch information
Moonbase59 committed Aug 5, 2024
1 parent 3c268e3 commit 2d95fc5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# autocue changelog

### 2024-08-05 - v4.1.1

- Fix situation where supplied JSON data could still overwrite `cue_file` results even if a file’s `liq_cue_file` tag was set to `true`, meaning the `cue_file` results should be preferred in any case.
- For freshly generated/downloaded news or time announcements, this could lead to erroneous cut-offs or loudness jumps in case AzuraCast’s media checker hadn’t yet picked up the new data. It would then overwrite the actual file data with stored values from the database.

### 2024-07-05 – v4.1.0

#### New features
Expand Down
3 changes: 2 additions & 1 deletion autocue.cue_file.liq
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
# - not set = default (metadata can override cue_file)
# - false = don’t autocue (still use metadata if present)
# - true = cue_file results override metadata
# 2024-08-05 - Moonbase59 - v4.1.1 Sync with cue_file version

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

Expand All @@ -62,7 +63,7 @@ let settings.autocue.cue_file.version =
settings.make(
description=
"Software version of autocue.cue_file. Should coincide with `cue_file`.",
"4.1.0"
"4.1.1"
)

# Internal only! Not a user setting.
Expand Down
14 changes: 9 additions & 5 deletions cue_file
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@
# 2024-07-05 Moonbase59 - v4.1.0 Add `liq_cue_file` to known tags, so we can
# forbid external processes to call us again and
# possibly deliver outdated metadata to us.
# 2024-08-05 Moonbase59 - v4.1.1 Fix JSON overriding if `liq_cue_file` is true
#
# Originally based on an idea and some code by John Warburton (@Warblefly):
# https://github.com/Warblefly/TrackBoundaries
# Some collaborative work with RM-FM (@RM-FM): Sustained ending analysis.

__author__ = 'Matthias C. Hormann'
__version__ = '4.1.0'
__version__ = '4.1.1'

import os
import sys
Expand Down Expand Up @@ -304,9 +305,12 @@ def override_from_JSON(tags, tags_json={}):
# get tags in JSON override file
tags_in_json = convert_tags(tags_json)

# unify, right overwrites left if key in both
# tags_found = tags_in_stream | tags_in_format | tags_in_json
tags = {**tags, **tags_in_json}
# do NOT overwrite from JSON if `liq_cue_file` is true
if "liq_cue_file" in tags and tags["liq_cue_file"] == True:
pass
else:
# unify, right overwrites left if key in both
tags = {**tags, **tags_in_json}

return tags

Expand Down Expand Up @@ -1230,7 +1234,7 @@ if args.force or not skip_analysis:
nice=args.nice,
noclip=args.noclip
)
# allow to override even the analysis results
# allow to override even the analysis results (not if `liq_cue_file=true`)
if args.json:
result = override_from_JSON(result, tags_json)
# override duration, seems ffprobe can be more exact
Expand Down

0 comments on commit 2d95fc5

Please sign in to comment.