mirror of
https://github.com/simon987/scripts.git
synced 2025-12-14 07:49:03 +00:00
yee
This commit is contained in:
43
flac2mp3_V0
Executable file
43
flac2mp3_V0
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/bash python3
|
||||
|
||||
import os
|
||||
from shutil import copyfile
|
||||
import pathlib
|
||||
from multiprocessing import Pool, Value
|
||||
|
||||
SRC = "/mnt/merger/audio/music"
|
||||
DST = "/mnt/merger/audio/music_[V0]"
|
||||
|
||||
to_convert = []
|
||||
counter = Value("d")
|
||||
|
||||
|
||||
def convert(path):
|
||||
global counter
|
||||
destination = DST + path[len(SRC):]
|
||||
destination = os.path.splitext(destination)[0] + ".mp3"
|
||||
|
||||
pathlib.Path(os.path.split(destination)[0]).mkdir(parents=True, exist_ok=True)
|
||||
|
||||
if not os.path.exists(destination):
|
||||
os.system("ffmpeg -i \"" + path + "\" -c:a libmp3lame -q:a 0 -y \"" + destination + "\" -loglevel panic")
|
||||
print("[%.2f%%] - " % (counter.value / len(to_convert) * 100) + destination)
|
||||
counter.value += 1
|
||||
|
||||
|
||||
def recursive_convert(path):
|
||||
|
||||
for item in os.listdir(path):
|
||||
full_path = path + os.sep + item
|
||||
if os.path.isdir(full_path):
|
||||
recursive_convert(full_path)
|
||||
else:
|
||||
if os.path.splitext(item)[1] in [".mp3", ".flac", ".m4a", ".ape"]:
|
||||
to_convert.append(full_path)
|
||||
|
||||
|
||||
recursive_convert(SRC)
|
||||
print("Converting " + str(len(to_convert)) + " files...")
|
||||
|
||||
pool = Pool(processes=4)
|
||||
pool.map(convert, to_convert)
|
||||
Reference in New Issue
Block a user