aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaditya Dhruv <[email protected]>2025-05-05 21:36:33 -0500
committerAaditya Dhruv <[email protected]>2025-05-05 21:36:33 -0500
commit0a12e76855b21ad48884cddf772039579924d71f (patch)
treef4e90b221db609d74697f927a1418fff2a94e50d
parent74d0aa127ad984c1697603256c2a74492269a27e (diff)
Add converter script for .wav to.flac, and set artist, genre, and album
-rwxr-xr-xalbum_metadata_converter/converter.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/album_metadata_converter/converter.py b/album_metadata_converter/converter.py
new file mode 100755
index 0000000..00d17c5
--- /dev/null
+++ b/album_metadata_converter/converter.py
@@ -0,0 +1,56 @@
+import os
+import asyncio
+import subprocess
+
+
+async def run_ffmpeg(path, album):
+ print(f"Parsing {path}")
+ cmd = ["ffmpeg", "-i", f"{path}.wav", "-af", "aformat=s32:176000", f"{path}.flac"]
+ p = subprocess.Popen(cmd)
+ print(f"Running {p.args}")
+ while p.poll() == None:
+ await asyncio.sleep(1)
+
+ if p.returncode == 0:
+ # Set Artist
+ cmd = ["metaflac", "--set-tag=artist='The Consouls'", f"{path}.flac"]
+ p = subprocess.Popen(cmd)
+ print(f"Running {p.args}")
+ while p.poll() == None:
+ await asyncio.sleep(1)
+ # Set Album
+ cmd = ["metaflac", f"--set-tag=album=\"{album}\"", f"{path}.flac"]
+ p = subprocess.Popen(cmd)
+ print(f"Running {p.args}")
+ while p.poll() == None:
+ await asyncio.sleep(1)
+
+ # Set Genre
+ cmd = ["metaflac", "--set-tag=genre='Jazz'", "--set-tag=genre='Video Game'", f"{path}.flac"]
+ p = subprocess.Popen(cmd)
+ print(f"Running {p.args}")
+ while p.poll() == None:
+ await asyncio.sleep(1)
+
+ # Delete wav
+ cmd = ["rm", "-f", f"{path}.wav"]
+ p = subprocess.Popen(cmd)
+ print(f"Running {p.args}")
+ while p.poll() == None:
+ await asyncio.sleep(1)
+
+ return p.returncode
+
+
+async def main():
+ tasks = []
+ for root, dirs, files in os.walk("Music"):
+ for file in files:
+ if file.endswith(".wav"):
+ filename = os.path.join(root, os.path.splitext(file)[0])
+ album = root.split('/')[-1]
+ tasks.append(asyncio.create_task(run_ffmpeg(filename, album)))
+
+ await asyncio.gather(*tasks)
+
+asyncio.run(main())