commit 58bb2d5a497e6507abdf8accf40038b3959a3622
parent a6b1281f262b666bfa692f44d934c83624da64c3
Author: gearsix <gearsix@tuta.io>
Date: Wed, 7 Dec 2022 16:04:48 +0000
bugfix: shell arg in sya Popen calls set correctly
Diffstat:
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/sya.py b/sya.py
@@ -9,6 +9,8 @@ import sys
Version = 'v1.0.1'
+Shell = True if sys.platform == 'win32' else False
+
UnsafeFilenameChars = re.compile('[/\\?%*:|\"<>\x7F\x00-\x1F]')
TrackNum = re.compile('(?:\d+.? ?-? ?)')
Timestamp = re.compile('(?: - )?(?:[\t ]+)?(?:[\[\(]+)?((\d+[:.])+(\d+))(?:[\]\)])?(?:[\t ]+)?(?: - )?')
@@ -27,7 +29,7 @@ def error_exit(msg):
def check_bin(*binaries):
for b in binaries:
try:
- subprocess.call([b], stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL, shell=False)
+ subprocess.call([b], stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL, shell=Shell)
except:
error_exit('failed to execute {}'.format(b))
@@ -41,7 +43,7 @@ def get_audio(youtubedl, url, outdir, format='mp3', quality='320K', keep=True, f
if keep == True:
cmd.append('-k')
cmd.append(url)
- p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False)
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=Shell)
for line in p.stdout.readlines():
print(' {}'.format(line.decode('utf-8', errors='ignore').strip()))
return '{}.{}'.format(fname, format)
@@ -99,7 +101,7 @@ def read_tracklen(ffmpeg, track_fpath):
cmd = [ffmpeg, '-v', 'quiet', '-stats', '-i', track_fpath, '-f', 'null', '-']
length = '00:00'
try:
- ret = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=False)
+ ret = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=Shell)
length = str(ret).split('\\r')
# some nasty string manip. to extract length (printed to stderr)
if sys.platform == 'win32':
@@ -114,7 +116,7 @@ def read_tracklen(ffmpeg, track_fpath):
def split_tracks(ffmpeg, audio_fpath, audio_len, tracks, format='mp3', outpath='out'):
print('Splitting...')
for i, t in enumerate(tracks):
- outfile = '{}/{} - {}.{}'.format(outpath, str(i+1).zfill(2), t.title.strip(' - '), format)
+ outfile = '{}{}{} - {}.{}'.format(outpath, os.path.sep, str(i+1).zfill(2), t.title.strip(' - '), format)
end = audio_len
if i < len(tracks)-1:
end = tracks[i+1].timestamp
@@ -122,7 +124,7 @@ def split_tracks(ffmpeg, audio_fpath, audio_len, tracks, format='mp3', outpath='
cmd = ['ffmpeg', '-nostdin', '-y', '-loglevel', 'error',
'-i', audio_fpath, '-ss', t.timestamp, '-to', end,
'-acodec', 'copy', outfile]
- p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False)
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=Shell)
for line in p.stdout.readlines():
print(' {}'.format(line.decode('utf-8', errors='ignore').strip()))
return