sya

split youtube audio tracks, with an optional pyqt gui
git clone git://src.gearsix.net/sya
Log | Files | Refs | Atom | README

commit 2a4237212bf3c91dc727d86f2353010940dbf2f8
parent 026f57a94251301c1f44afc99c5a23f4b93b0785
Author: gearsix <gearsix@tuta.io>
Date:   Fri, 18 Nov 2022 21:56:10 +0000

bugfix: realised shell=False is required on windows to avoid consoles popping up

Diffstat:
Msya.py | 9+++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/sya.py b/sya.py @@ -7,6 +7,7 @@ import re import os import sys +Shell = False if sys.platform is "win32" else True Timestamp = re.compile('[\[\(]?((\d+:)+(\d+))[\]\)]?') class TracklistItem: @@ -22,7 +23,7 @@ def error_exit(msg): def check_bin(*binaries): for b in binaries: try: - subprocess.call([b], stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL, shell=True) + subprocess.call([b], stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL, shell=Shell) except: error_exit('failed to execute {}'.format(b)) @@ -36,7 +37,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) + 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) @@ -81,7 +82,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) + 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': @@ -104,7 +105,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) + 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