def _import(self, mdb, mds, args, config, filename): printer.debug('Importing file {filename}', filename=filename) short_filename = os.path.basename(filename) title, ext = os.path.splitext(short_filename) title, season_num, episode_num = clean_title_series(title) while True: # Disable the title input if auto mode is enabled: if not args.auto: title = printer.input(u'Title to search', default=title) season_num = int(printer.input(u'Season number', default=season_num)) episode_num = int(printer.input(u'Episode number', default=episode_num)) datasource, episode = self._search(mds, title, short_filename, season_num, episode_num, auto=args.auto) if datasource == 'manual': episode = self.profile.object_class() elif datasource == 'abort': printer.p('Aborted import of {filename}', filename=filename) return break if datasource is None: return return episode # Refresh the full data for the choosen movie: episode = mds.refresh(episode)
def _import(self, mdb, mds, args, config, filename): printer.debug('Importing file {filename}', filename=filename) short_filename = os.path.basename(filename) title, ext = os.path.splitext(short_filename) year, title = clean_title(title) # Disable the year filter if auto mode is disabled: if not args.auto: year = None while True: # Disable the title input if auto mode is enabled: if not args.auto: title = printer.input(u'Title to search', default=title) datasource, movie = self._search(mds, title, short_filename, year, auto=args.auto) if datasource == 'manual': movie = self.profile.object_class() elif datasource == 'abort': printer.p('Aborted import of {filename}', filename=filename) return break if datasource is None: return return movie
def _import(self, mdb, mds, args, config, filename): printer.debug('Importing file {filename}', filename=filename) short_filename = os.path.basename(filename) title, ext = os.path.splitext(short_filename) year, title = clean_title(title) # Disable the year filter if auto mode is disabled: if not args.auto: year = None while True: # Disable the title input if auto mode is enabled: if not args.auto: title = printer.input(u'Title to search', default=title) datasource, movie = self._search(mds, title, short_filename, year, auto=args.auto) if datasource == 'manual': movie = self.profile.object_class elif datasource == 'abort': printer.p('Aborted import of {filename}', filename=filename) return break if datasource is None: return # Refresh the full data for the choosen movie: movie = mds.refresh(movie) if args.show: show(movie) printer.p('') # Edit available data: if not args.auto and printer.ask('Do you want to edit the movie metadata', default=False): movie = self.profile.object_class(json.loads(printer.edit(json.dumps(movie, indent=True)))) # Hardlink or copy the movie in the tree if args.hardlink or args.symlink: printer.p('\nComputing movie sha1sum...') movie_hash = link(args.tree, filename, args.symlink) else: printer.p('\nCopying movie in kolekto tree...') movie_hash = copy(args.tree, filename) printer.p('') mdb.save(movie_hash, movie) printer.debug('Movie {hash} saved to the database', hash=movie_hash) if args.delete: os.unlink(filename) printer.debug('Deleted original file {filename}', filename=filename)