def rename(self, details): working, filename = details try: tv = TvRenamr(working, self.config, options.debug, options.dry) episode = Episode(tv.extract_details_from_file(filename, user_regex=options.regex)) if options.show: episode.show_name = options.show if options.season: episode.season = options.season if options.episode: episode.episode = options.episode episode.title = tv.retrieve_episode_name(episode, library=options.library, canonical=options.canonical) episode.show_name = tv.format_show_name(episode.show_name, the=options.the, override=options.show_override) path = tv.build_path( episode, rename_dir=options.rename_dir, organise=options.organise, format=options.output_format ) tv.rename(filename, path) except (ConfigNotFoundException, NoMoreLibrariesException, NoNetworkConnectionException): if options.dry or options.debug: self._stop_dry_run() sys.exit(1) except ( EmptyEpisodeNameException, EpisodeAlreadyExistsInDirectoryException, EpisodeNotFoundException, IncorrectCustomRegularExpressionSyntaxException, InvalidXMLException, OutputFormatMissingSyntaxException, ShowNotFoundException, UnexpectedFormatException, ): pass except Exception as err: if options.debug: # In debug mode, show the full traceback. raise log.critical("tvr: critical error: %s" % str(err)) sys.exit(1)