From 2dcb3fe2bf483acc8792777d6344bf7adf7092a7 Mon Sep 17 00:00:00 2001 From: yajrendrag Date: Tue, 8 Oct 2024 03:46:16 -0600 Subject: [PATCH] add audio metadata check of ffprobe data --- source/rename_file/changelog.md | 3 +++ source/rename_file/info.json | 2 +- source/rename_file/plugin.py | 10 ++++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/source/rename_file/changelog.md b/source/rename_file/changelog.md index 6d6ec4284..4bb12d042 100644 --- a/source/rename_file/changelog.md +++ b/source/rename_file/changelog.md @@ -1,4 +1,7 @@ +**0.0.13** +- add check for audio metadata presence in ffprobe data + **0.0.12** - fix typo in elif: clause diff --git a/source/rename_file/info.json b/source/rename_file/info.json index 406477cf3..fe248b0a0 100644 --- a/source/rename_file/info.json +++ b/source/rename_file/info.json @@ -11,5 +11,5 @@ "on_postprocessor_task_results": 0 }, "tags": "rename, postprocessor", - "version": "0.0.12" + "version": "0.0.13" } diff --git a/source/rename_file/plugin.py b/source/rename_file/plugin.py index 4dcf27ed2..38f0a0f8e 100644 --- a/source/rename_file/plugin.py +++ b/source/rename_file/plugin.py @@ -293,13 +293,15 @@ def replace(data, settings, abspath, streams): acodec = '' if astream: - audio_codec = streams[astream]["codec_name"] - channel_layout = streams[astream]["channel_layout"] - channels = streams[astream]["channels"] + audio_codec = streams[astream]["codec_name"] if "codec_name" in streams[astream] else "" + channel_layout = streams[astream]["channel_layout"] if "channel_layout" in streams[astream] else "" + channels = streams[astream]["channels"] if "channels" in streams[astream] else "" if channel_layout == "stereo" and channels == 2: acodec = audio_codec + ' ' + str(channels) + '.0' - elif channels > 4: + elif channels > 4 and channel_layout: acodec = audio_codec + ' ' + str(channel_layout).replace('(side)','') + elif channels > 4 and not channel_layout: + acodec = audio_codec.upper() + ' ' + audio if audio_codec.upper() not in audio else audio logger.debug("acodec: '{}'".format(acodec)) if basename.find(codec) > 0: