diff --git a/tatt/helpers.py b/tatt/helpers.py index 96fb9eb..4d18076 100644 --- a/tatt/helpers.py +++ b/tatt/helpers.py @@ -88,14 +88,11 @@ def get_transcription_jobs( status=status) if jobs: if name: - exact_match_jobs = [] - for job in jobs: - if job['name'] == name: - exact_match_jobs.append(job) - if not exact_match_jobs: + jobs = get_exact_name_matches(jobs, name) + # this is because AWS Transcribe doesn't have exact file + # search + if not jobs: continue - else: - jobs = exact_match_jobs all_jobs[stt_name] = jobs if name and len(all_jobs) == 0: @@ -104,6 +101,14 @@ def get_transcription_jobs( return all_jobs +def get_exact_name_matches(jobs, name): + exact_match_jobs = [] + for job in jobs: + if job['name'] == name: + exact_match_jobs.append(job) + return exact_match_jobs + + def get_transcription_jobs_dict(): jobs = get_transcription_jobs() return { diff --git a/tatt/transcribe.py b/tatt/transcribe.py index fea5787..1de45ef 100644 --- a/tatt/transcribe.py +++ b/tatt/transcribe.py @@ -44,15 +44,14 @@ def get(name, save, pretty): @cli.command() @click.option('--service', type=str, help="STT service name") -@click.option('-n', '--name', type=str, help="transcription job name") @click.option('--status', type=str, help="completed | failed | in_progress") -def list(service, name, status): +def list(service, status): """Lists available STT services.""" if service is not None and service not in vendors.SERVICES: raise click.ClickException(f'no such service: {service}') try: - all_jobs = get_transcription_jobs(service, name, status) + all_jobs = get_transcription_jobs(service_name=service, status=status) except exceptions.ConfigError as e: raise click.ClickException(str(e)) else: