Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit ab21235

Browse files
committed
added cuebreakpoints | shnsplit
1 parent 57c869b commit ab21235

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.idea
2+
.DS_Store
23

wavCue2Flac.py

+19-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import os
22
import sys
3-
4-
# call 'cuebreakpoints | shnsplit'
5-
# check for errors
3+
import shlex
4+
from subprocess import call
65

76
# call cuetag
87
# check for errors
98

109
# programmatically rename by metadata (if possible)
1110

1211
def find_command(name):
12+
print('checking for %s' % name)
1313
for dir in os.environ['PATH'].split(':'):
1414
command = os.path.join(dir, name)
1515
if os.path.exists(command): return command
@@ -18,13 +18,25 @@ def print_usage():
1818
print('usage: wavCue2Flac albumPath')
1919

2020
def find_cue_wav(path):
21+
print('checking for cue/wav in %s' % path)
2122
for root, dirs, files in os.walk(path):
2223
for file in files:
2324
cue = os.path.abspath(os.path.join(root, file))
2425
if cue.endswith('.cue'):
25-
wav = cue.replace('.cue', '.wav')
26-
if os.path.exists(wav):
27-
return cue, wav
26+
for ext in ['.wav', '.wv']:
27+
wav = cue.replace('.cue', ext)
28+
if os.path.exists(wav):
29+
return cue, wav
30+
31+
def split_album(cue, wav):
32+
print('splitting album with cuebreakpoints | shnsplit')
33+
os.chdir(os.path.dirname(cue))
34+
ret = call(
35+
'cuebreakpoints %s | shnsplit -q -o "flac flac -s --best -o %%f -" %s' % (shlex.quote(cue), shlex.quote(wav)),
36+
shell=True)
37+
if ret != 0:
38+
print('error calling cuebreakpoints/shnsplit', file=sys.stderr)
39+
sys.exit(1)
2840

2941
if len(sys.argv) != 2:
3042
print_usage()
@@ -60,5 +72,4 @@ def find_cue_wav(path):
6072
cue = paths[0]
6173
wav = paths[1]
6274

63-
print(cue)
64-
print(wav)
75+
split_album(cue, wav)

0 commit comments

Comments
 (0)