diff --git a/setup.py b/setup.py index 2dfbc5d..d2b2865 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ with open('README.md') as file: setup( name="tatt", - version="0.958", + version="0.970", py_modules=['tatt'], url='https://github.com/zevaverbach/tatt', install_requires=[ diff --git a/tatt/helpers.py b/tatt/helpers.py index c3bdfbe..59999c3 100644 --- a/tatt/helpers.py +++ b/tatt/helpers.py @@ -1,3 +1,5 @@ +from typing import Dict, List + from tatt import config, exceptions, vendors LB = '\n' @@ -67,7 +69,11 @@ def print_transcription_jobs(jobs): print() -def get_transcription_jobs(service_name=None, name=None, status=None): +def get_transcription_jobs( + service_name=None, + name=None, + status=None + ) -> Dict[str, List[dict]]: all_jobs = {} for stt_name in vendors.SERVICES: if service_name is None or service_name == stt_name: @@ -77,6 +83,10 @@ def get_transcription_jobs(service_name=None, name=None, status=None): status=status) if jobs: all_jobs[stt_name] = jobs + + if name and len(all_jobs) == 0: + raise exceptions.DoesntExistError + return all_jobs diff --git a/tatt/transcribe.py b/tatt/transcribe.py index c54d847..2b07fb8 100644 --- a/tatt/transcribe.py +++ b/tatt/transcribe.py @@ -31,7 +31,7 @@ def get(name, save, pretty): file = None if save: - filepath = f'{name}.json', 'w' + filepath = f'{name}.json' file = open(filepath) click.echo(transcript, file=file) @@ -72,10 +72,15 @@ def services(free_only): @cli.command() @click.argument('job_name', type=str) def status(job_name): - jobs = get_transcription_jobs(name=job_name) - if not jobs or not list(jobs.values())[0]: + """Check the status of a transcription job.""" + try: + jobs = get_transcription_jobs(name=job_name) + except exceptions.DoesntExistError: raise click.ClickException('no job by that name') - click.echo(list(jobs.values())[0][0]['status']) + for job_list in jobs.values(): + for job in job_list: + click.echo(job['status']) + break @cli.command()