mirror of
https://github.com/Escartem/AnimeWwise.git
synced 2026-06-11 20:20:25 +08:00
use format arg instead
This commit is contained in:
16
extract.py
16
extract.py
@@ -30,12 +30,14 @@ skips = "000000000" # used for debugging
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--ogg', action='store_true', help='Convert to .ogg instead of .mp3', default=False)
|
parser.add_argument("--format", nargs="?", type=str, default="mp3", help="Output audio format, can be either mp3 or ogg")
|
||||||
parse_args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
is_ogg = parse_args.ogg and True or False
|
formats = ["mp3", "ogg"]
|
||||||
|
audio_format = "mp3"
|
||||||
|
if args.format in formats:
|
||||||
|
audio_format = args.format
|
||||||
|
|
||||||
audio_format = 'ogg' if is_ogg else 'mp3'
|
|
||||||
print(f'Format: {audio_format}')
|
print(f'Format: {audio_format}')
|
||||||
|
|
||||||
# Initial cleanup
|
# Initial cleanup
|
||||||
@@ -209,9 +211,7 @@ def main():
|
|||||||
diff_length = wem_length - len(all_files)
|
diff_length = wem_length - len(all_files)
|
||||||
|
|
||||||
if diff_length > 0:
|
if diff_length > 0:
|
||||||
print(
|
print(f": Failed to extract {diff_length} files out of {wem_length} (probably no extractable content)")
|
||||||
f": Failed to extract {diff_length} files out of {wem_length} (probably no extractable content)"
|
|
||||||
)
|
|
||||||
|
|
||||||
#############################################
|
#############################################
|
||||||
### 6 - Convert .wav files to .mp3 or ogg ###
|
### 6 - Convert .wav files to .mp3 or ogg ###
|
||||||
@@ -238,7 +238,7 @@ def main():
|
|||||||
"-i",
|
"-i",
|
||||||
path(f"temp/wav/{file}"),
|
path(f"temp/wav/{file}"),
|
||||||
"-acodec",
|
"-acodec",
|
||||||
"libvorbis" if is_ogg else "libmp3lame",
|
"libvorbis" if audio_format == "ogg" else "libmp3lame",
|
||||||
"-b:a",
|
"-b:a",
|
||||||
"192k",
|
"192k",
|
||||||
path(f"temp/{audio_format}/{file.split('.')[0]}.{audio_format}"),
|
path(f"temp/{audio_format}/{file.split('.')[0]}.{audio_format}"),
|
||||||
|
|||||||
Reference in New Issue
Block a user