sya

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

commit 93d9af9797c7301581310ab3a09813e8628d9cc4
parent 025de299b95961101790f8646675de7ad1daab40
Author: gearsix <gearsix@tuta.io>
Date:   Tue,  7 Mar 2023 19:18:18 +0000

sya: you can now pass multiple TRACKLIST files

Diffstat:
Mdoc/TODO.md | 5+++--
Msrc/sya.py | 45+++++++++++++++++++++++----------------------
2 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/doc/TODO.md b/doc/TODO.md @@ -3,9 +3,10 @@ - `-` = To do - `~` = Doing -- `x` = Done +- `/` = Done +- `x` = Won't do -- (2023/03/07) allow sya.py to process multiple FILE... arguments +/ (2023/03/07) allow sya.py to process multiple FILE... arguments - (2023/03/02) write a build script for building the binaries - (2023/03/01) update yt-dlp, youtube api seems to have broken again diff --git a/src/sya.py b/src/sya.py @@ -134,7 +134,7 @@ def parse_args(): parser = argparse.ArgumentParser( description='download & split audio tracks long youtube videos') # arguments - parser.add_argument('tracklist', metavar='TRACKLIST', nargs='?', + parser.add_argument('tracklist', metavar='TRACKLIST', nargs='*', help='tracklist of title and timestamp information to split audio by') # options parser.add_argument('-o', '--output', @@ -165,33 +165,34 @@ def sya(args): if check_bin(args.youtubedl, args.ffmpeg) == False: error_exit('required binaries are missing') - if args.tracklist == None or os.path.exists(args.tracklist) == False: - error_exit('missing tracklist') - if args.output == None: - args.output = os.path.splitext(args.tracklist)[0] - url, tracklist = load_tracklist(args.tracklist) - - audio_fpath = get_audio(args.youtubedl, url, args.output, - args.format, args.quality, args.keep, args.ffmpeg) - if os.path.exists(audio_fpath) == False: - error_exit('download failed, aborting') + for t in args.tracklist: + if args.tracklist == None or os.path.exists(t) == False: + error_exit('missing tracklist "{}"'.format(t)) + url, tracklist = load_tracklist(t) + + output = args.output if args.output != None else os.path.splitext(t)[0] + audio_fpath = get_audio(args.youtubedl, url, output, + args.format, args.quality, args.keep, args.ffmpeg) + if os.path.exists(audio_fpath) == False: + error_exit('download failed, aborting') - tracks = parse_tracks(tracklist) - - missing = missing_times(tracks) - if len(missing) > 0: - error_exit('some tracks are missing timestamps') + tracks = parse_tracks(tracklist) + + missing = missing_times(tracks) + if len(missing) > 0: + error_exit('some tracks are missing timestamps') - length = read_tracklen(args.ffmpeg, audio_fpath) - os.makedirs(args.output, exist_ok=True) - split_tracks(args.ffmpeg, audio_fpath, length, tracks, args.format, args.output) + length = read_tracklen(args.ffmpeg, audio_fpath) + os.makedirs(output, exist_ok=True) + split_tracks(args.ffmpeg, audio_fpath, length, tracks, args.format, output) - if args.keep is False: - os.remove(audio_fpath) + if args.keep is False: + os.remove(audio_fpath) - print('Success') + print('Success') if __name__ == '__main__': sya(parse_args()) +