def main(sys_args=sys.argv[1:]):
    parser = vanparse.ArgumentParser('grep', auto_editor.version, description='Read and match subtitle tracks in media files.')
    parser = grep_options(parser)
    TEMP = tempfile.mkdtemp()
    log = Log(temp=TEMP)
    try:
        args = parser.parse_args(sys_args)
    except vanparse.ParserError as e:
        log.error(str(e))
    ffmpeg = FFmpeg(args.ffmpeg_location, args.my_ffmpeg, debug=False)
    media_files = args.input[1:]
    add_prefix = (((len(media_files) > 1) or os.path.isdir(media_files[0])) and (not args.no_filename))
    for media_file in media_files:
        if (not os.path.exists(media_file)):
            log.error(f'{media_file}: File does not exist.')
        if os.path.isdir(media_file):
            for (_, _, files) in os.walk(media_file):
                for file in files:
                    if (file == '.DS_Store'):
                        continue
                    grep_core(os.path.join(media_file, file), add_prefix, ffmpeg, args, log, TEMP)
        else:
            grep_core(media_file, add_prefix, ffmpeg, args, log, TEMP)
    log.cleanup()
def main(sys_args=sys.argv[1:]):
    parser = vanparse.ArgumentParser('grep', auto_editor.version, description='Read and match subtitle tracks in media files.')
    parser = grep_options(parser)
    TEMP = tempfile.mkdtemp()
    log = Log(temp=TEMP)
    try:
        args = parser.parse_args(sys_args)
    except vanparse.ParserError as e:
        log.error(str(e))
    ffmpeg = FFmpeg(args.ffmpeg_location, args.my_ffmpeg, debug=False)
    media_files = args.input[1:]
    add_prefix = (((len(media_files) > 1) or os.path.isdir(media_files[0])) and (not args.no_filename))
    for media_file in media_files:
        if (not os.path.exists(media_file)):
            log.error(f'{media_file}: File does not exist.')
        if os.path.isdir(media_file):
            for (_, _, files) in os.walk(media_file):
                for file in files:
                    if (file == '.DS_Store'):
                        continue
                    grep_core(os.path.join(media_file, file), add_prefix, ffmpeg, args, log, TEMP)
        else:
            grep_core(media_file, add_prefix, ffmpeg, args, log, TEMP)
    log.cleanup()