forked from fcode/delarte
48 lines
1.2 KiB
Python
48 lines
1.2 KiB
Python
"""CLI arguments related module."""
|
|
import argparse
|
|
|
|
|
|
class Parser(argparse.ArgumentParser):
|
|
"""Parser responsible for parsing CLI arguments."""
|
|
|
|
def __init__(self):
|
|
"""Generate a parser."""
|
|
super().__init__(
|
|
description="downloads Arte's videos with subtitles",
|
|
)
|
|
self.add_argument(
|
|
"url",
|
|
help="url of Arte movie's webpage",
|
|
action="store",
|
|
type=str,
|
|
nargs="?",
|
|
)
|
|
self.add_argument(
|
|
"version",
|
|
help="one of the language code proposed by Arte",
|
|
action="store",
|
|
type=str,
|
|
nargs="?",
|
|
)
|
|
self.add_argument(
|
|
"resolution",
|
|
help="video resolution",
|
|
action="store",
|
|
type=str,
|
|
nargs="?",
|
|
)
|
|
|
|
def get_args_as_list(self):
|
|
"""Get arguments from CLI as a list.
|
|
|
|
Returns:
|
|
List: ordered list of arguments, None removed
|
|
"""
|
|
args_namespace = self.parse_args()
|
|
args_list = [
|
|
args_namespace.url,
|
|
args_namespace.version,
|
|
args_namespace.resolution,
|
|
]
|
|
return [arg for arg in args_list if arg is not None]
|