From 186f8e5e3511a64c669d0990f1b805fcdb8ebc9b Mon Sep 17 00:00:00 2001 From: WorldObservationLog Date: Tue, 28 May 2024 23:12:55 +0800 Subject: [PATCH] fix: shell execute problem on Linux and macOS when calling mp4box --- src/mp4.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/mp4.py b/src/mp4.py index 7251515..8e94bbb 100644 --- a/src/mp4.py +++ b/src/mp4.py @@ -194,10 +194,15 @@ async def write_metadata(song: bytes, metadata: SongMetadata, embed_metadata: li time = datetime.strptime(metadata.created, "%Y-%m-%d").strftime("%d/%m/%Y") else: time = "" - subprocess.run(["mp4box", "-time", time, "-mtime", time, "-name", f"1={metadata.title}", "-itags", - ":".join(["tool=", f"cover={absolute_cover_path}", - metadata.to_itags_params(embed_metadata)]), - song_name.absolute()], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, shell=if_shell()) + if if_shell(): + subprocess.run( + f"mp4box -time {time} -mtime {time} -name 1={metadata.title} -itags tool=:cover={absolute_cover_path}:{metadata.to_itags_params(embed_metadata)} {song_name.absolute()}", + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, shell=if_shell()) + else: + subprocess.run(["mp4box", "-time", time, "-mtime", time, "-name", f"1={metadata.title}", "-itags", + ":".join(["tool=", f"cover={absolute_cover_path}", + metadata.to_itags_params(embed_metadata)]), + song_name.absolute()], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, shell=if_shell()) with open(song_name.absolute(), "rb") as f: embed_song = f.read() tmp_dir.cleanup()