Skip to content

Commit

Permalink
Merge pull request #26 from asolidtime/main
Browse files Browse the repository at this point in the history
don't specify dot character in available subtitle formats in the CLI
  • Loading branch information
abdeladim-s committed Apr 27, 2023
2 parents 5b0f572 + 1eaf2af commit 32fdec7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/subsai/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def main():
"string)")
parser.add_argument('-f', '--format', '--subtitles-format', default='srt',
help=f"Output subtitles format, available "
f"formats {available_subs_formats()}")
f"formats {available_subs_formats(include_extensions=False)}")
parser.add_argument('-df', '--destination-folder', default=None,
help='The directory where the subtitles will be stored, default to the same folder where '
'the media file(s) is stored.')
Expand Down
13 changes: 11 additions & 2 deletions src/subsai/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,20 @@ def available_translation_models() -> list:
return models


def available_subs_formats():
def available_subs_formats(include_extensions=True):
"""
Returns available subtitle formats
from :attr:`pysubs2.FILE_EXTENSION_TO_FORMAT_IDENTIFIER`
:param include_extensions: include the dot separator in file extensions
:return: list of subtitle formats
"""
return list(FILE_EXTENSION_TO_FORMAT_IDENTIFIER.keys())

extensions = list(FILE_EXTENSION_TO_FORMAT_IDENTIFIER.keys())

if include_extensions:
return extensions
else:
# remove the '.' separator from extension names
return [ext.split('.')[1] for ext in extensions]

0 comments on commit 32fdec7

Please sign in to comment.