def search(self, **params): self.media_type = params['type'] search_results = None try: search_results = ucli.gen_to_list( getattr(self, self.media_type)(**params)) ucli.print_candidates(search_results) except MapiNotFoundException: ucli.info('Nothing found') ucli.print_options("[e]dit query, [m]anual, [s]kip, [q]uit") except MapiNetworkException: ucli.drop('Network error: couldn\'t retrieve data') else: ucli.print_options( "[RETURN] default, [e]dit query, [m]anual, [s]kip, [q]uit") finally: return ucli.parse_selection( search_results, { 'e': self.search_again, 'm': self.get_metadata_manual})
def track_tvshow(self): ucli.info('Would you like to track this TV Show?') ucli.print_options('[RETURN] to confirm or [s]kip this step') if ucli.parse_selection(None): from tvshows import tvshows tvshows.add({ 'link': self.linkpath, 'title': self.metadata['title'] })
def create_link(self, path_to_file, linkname): ucli.header('Linkname:', linkname) ucli.print_options('[RETURN] to confirm or [e]dit the linkname') linkname = ucli.parse_selection( [linkname], { 'e': (ucli.inline_prompt, 'New Linkname: ', linkname)}) self.linkpath = os.path.join(self.LINKS_DIR, linkname) try: os.symlink(path_to_file, self.linkpath) ucli.header('Symlink:', self.linkpath) ucli.header(' ->', path_to_file) return True except FileExistsError: return ucli.info('File already exists. Skipping')
def get_metadata_manual(self): _candidates = ['movie', 'episode'] if not self.is_movie: _candidates = _candidates[::-1] ucli.print_candidates(_candidates) ucli.print_options("[RETURN] default, [q]uit") self.media_type = ucli.parse_selection(_candidates) if self.is_movie: metadata = { 'title': ucli.get_field('title', necessary=True)} else: metadata = { 'series': ucli.get_field('title', necessary=True), 'season': ucli.get_field('season', default='1')} metadata['year'] = ucli.get_field('year', default=self.CURRENT_YEAR) return metadata