Add flacs to transcode list and assemble encoder argument tuple
This commit is contained in:
parent
de02cb2d08
commit
19a70dd2e7
20
src/main.py
20
src/main.py
|
@ -4,8 +4,9 @@ from pathlib import Path
|
||||||
|
|
||||||
def get_args():
|
def get_args():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('indir', type=Path)
|
parser.add_argument('indir', type=Path, help='Directory containing artist directories')
|
||||||
parser.add_argument('outdir', type=Path)
|
parser.add_argument('outdir', type=Path, help='Empty directory where transcodes will be placed')
|
||||||
|
parser.add_argument('encoder', type=Path, help='Location of encoder')
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +27,14 @@ def skip_album(path: Path):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def main(input_dir: Path, output_dir: Path):
|
def transcode(transcode_list: list, encoder: Path):
|
||||||
|
additional_args = ('--bitrate 128', '--music')
|
||||||
|
for in_track, out_track in transcode_list:
|
||||||
|
print((in_track, out_track) + additional_args)
|
||||||
|
|
||||||
|
|
||||||
|
def main(input_dir: Path, output_dir: Path, encoder: Path):
|
||||||
|
transcode_list = []
|
||||||
for artist in input_dir.iterdir():
|
for artist in input_dir.iterdir():
|
||||||
if artist.is_dir():
|
if artist.is_dir():
|
||||||
artist_out = Path(output_dir) / artist.name
|
artist_out = Path(output_dir) / artist.name
|
||||||
|
@ -42,14 +50,18 @@ def main(input_dir: Path, output_dir: Path):
|
||||||
print(f"Skipping '{artist.parts[-1]} / {album.parts[-1]}'")
|
print(f"Skipping '{artist.parts[-1]} / {album.parts[-1]}'")
|
||||||
else:
|
else:
|
||||||
album_out.mkdir()
|
album_out.mkdir()
|
||||||
|
for track in album.iterdir():
|
||||||
|
if track.is_file() and track.suffix.lower() == '.flac':
|
||||||
|
transcode_list.append((str(track), str(album_out / f"{track.name}.opus")))
|
||||||
else:
|
else:
|
||||||
print(f"Warning, skipping non-dir '{album}' found in artist '{artist.parts[-1]}'")
|
print(f"Warning, skipping non-dir '{album}' found in artist '{artist.parts[-1]}'")
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
print(f"Warning, skipping non-dir '{artist}' found in root")
|
print(f"Warning, skipping non-dir '{artist}' found in root")
|
||||||
continue
|
continue
|
||||||
|
transcode(transcode_list, encoder)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
args = get_args()
|
args = get_args()
|
||||||
main(args.indir, args.outdir)
|
main(args.indir, args.outdir, args.encoder)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user