Created
December 30, 2018 05:05
-
-
Save jfeilbach/f1aa52b64c3c4d54480a313238216b91 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python 2 - Requires: flac, lame | |
# Usage: python transcode.py 320/V0/V2 inputfolder | |
# By: TheSingularity | |
python | |
import sys, os, shutil | |
from subprocess import call | |
convertTo = sys.argv[1] | |
folderPath = sys.argv[2] | |
baseFolder = os.path.basename(os.path.dirname(folderPath)) | |
outputDir = "/media/a7071/nem3sis/orpheus-transcode/" | |
folderExtension = " [" + convertTo + "]" | |
print("[+] Folder Loaded : " + baseFolder) | |
print("[+] Transcoding To : " + convertTo) | |
print("[+] Starting Transcoding...") | |
if convertTo == "V0": | |
lameArgs = "-V 0 --vbr-new" | |
elif convertTo == "V2": | |
lameArgs = "-V 2 --vbr-new" | |
elif convertTo == "320": | |
lameArgs = "-h -b 320" | |
else: | |
print("Not sure what to convert to...") | |
exit() | |
if not os.path.exists(outputDir + baseFolder + folderExtension): | |
os.makedirs(outputDir + baseFolder + folderExtension) | |
for file in os.listdir(folderPath): | |
if file.endswith(".flac"): | |
return_code = call("flac -dcs -- \"" + folderPath + file + "\" | lame -S " + lameArgs + " --ignore-tag-errors - \"" + outputDir + baseFolder + folderExtension + "/" + os.path.splitext(file)[0] + ".mp3\"", shell=True, stdout=open(os.devnull, 'wb'), stderr=open(os.devnull, 'wb')) | |
print("[+] Transcoded: " + file) | |
else: | |
shutil.copy(folderPath + file, outputDir + baseFolder + folderExtension + "/" + file) | |
print("[+] Copied: " + file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment