def prompt_to_output_format(self): """ Prompt to get codec data and set the output audio format """ msgcustom(f"\n\033[1mConvert the '\033[32;1m" f"{self.input_format}\033[0m' format to:\033[0m") show_format_menu(self.index) # show text menu before prompt while True: output_select = input("Type a format number among those " "available, and press the Enter key > ") if output_select in ('a', 'A'): msgend(abort=True) sys.exit() data_codec = get_codec_data(self.input_format, output_select) if data_codec is None: msgdebug(err=f"Invalid option '{output_select}'") continue break self.codec = data_codec[0] self.output_format = data_codec[4] self.prompt_to_bitrate(data_codec)
def end_check(self): """ Print debug messages at the end of the tasks """ if self.info: for msg in self.info: msgdebug(info=msg) if self.warnings: for msg in self.warnings: msgdebug(warn=msg) if self.errors: for msg in self.errors: msgdebug(err=msg) if self.not_processed: msgcolor(orange="\nInput files NOT converted:") for list1 in self.not_processed: msgcustom(list1) if self.processed: msgcolor(green="\nConverted successfully:") for list2 in self.processed: msgcustom(list2) msgend(done=True)
def prompt_to_output_format(self): """ Prompt to set codec and output audio format. """ for input_format, val in list(self.filecatalog.items()): msgcustom(f"\n\033[1mConvert the '\033[32;1m" f"{input_format}\033[0m'format to:\033[0m") show_format_menu(val['index']) # show text menu before prompt while True: output_select = input("Type a format number among those " "available, and press the Enter key > ") if output_select in ('a', 'A'): msgend(abort=True) sys.exit() codec = get_codec_data(input_format, output_select) if codec is None: msgdebug(err=f"Invalid option '{output_select}'") continue break self.filecatalog[input_format]['codec'] = codec[0] self.filecatalog[input_format]['format'] = codec[4] self.prompt_to_bitrate(codec, input_format)
def __init__(self, path_i, path_o): """ Print a text menu with a list of available formats and wait for user input. The input value given by the user represents the format of the files to be converted in a given folder . """ # (too-many-instance-attributes) (FIXME) self.inputdir = path_i self.outputdir = path_o self.input_format = None self.output_format = None self.index = None self.codec = None self.bitrate = '' self.not_processed = [] self.processed = [] self.warnings = [] self.info = [] self.errors = [] msgcustom("\n\033[1mWhat is the files format to convert?\033[0m") for inputformat in text_menu(): msgcustom(f"{inputformat}") # show menu while True: input_selection = input("Type a format number among those " "available, and press the Enter key > ") if input_selection in ('a', 'A'): msgend(abort=True) sys.exit() try: selection = int(input_selection) except ValueError: msgdebug(err=(f"Invalid option '{input_selection}'")) continue if supported_formats().get(selection): self.input_format = supported_formats().get(selection)[1] self.index = supported_formats().get(selection)[2] else: msgdebug(err=(f"Invalid option '{input_selection}'")) continue break