def __move(self, progress): progress.start_module(lang(30132), self.MOVE_STEPS) try: progress.update(lang(30590)) # detecting library place lib_destiny = os.path.normpath(setting('fm_episodes_destination')) lib_source = os.path.dirname(os.path.dirname(os.path.dirname(self.path))) if lib_destiny == lib_source: raise Exception(lang(30602)) progress.update(lang(30506)) # moving files source = os.path.dirname(self.path) destination = os.path.normpath(setting('fm_episodes_destination')) alt_method = setting('fm_alternate') == 'true' match = os.path.splitext(os.path.basename(self.path))[0] count = utilfile.count_manage_files(alt_method, source, match) if not dialog_warning(lang(30132), count): raise Exception(lang(30609)) if setting('fm_episodes_structure') == '0': # multiple folders destination = os.path.join(destination, self.path.split(os.sep)[-3], self.path.split(os.sep)[-2]) else: # single folder destination = os.path.join(destination, self.path.split(os.sep)[-2]) utilfile.move_files(alt_method, source, destination, match, True) self.path = os.path.join(destination, os.path.basename(self.path)) progress.update(lang(30513)) # updating library progress.update_library() self.episodeid = utilxbmc.get_episodeid_by_path(self.path) if self.episodeid: # if still in lib source folders progress.update(lang(30514)) # setting watched utilxbmc.set_episode_playcount(self.episodeid, self.playcount+1) except OSError: dialog_error(lang(30610)) except Exception, e: dialog_error(e.message)
def __delete(self, progress): progress.start_module(lang(30133), self.DELETE_STEPS) try: progress.update(lang(30516)) # deleting files source = os.path.dirname(self.path) alt_method = setting('fm_alternate') == 'true' if setting('fm_movies_structure') == '0': # multiple folders count = utilfile.count_manage_directory(alt_method, source) if not dialog_warning(lang(30133), count): raise Exception(lang(30609)) utilfile.delete_directory(alt_method, source) else: # single folder match = os.path.splitext(os.path.basename(self.path))[0] count = utilfile.count_manage_files(alt_method, source, match) if not dialog_warning(lang(30133), count): raise Exception(lang(30609)) utilfile.delete_files(alt_method, source, match) progress.update(lang(30513)) # updating library progress.update_library() self.movieid = None self.path = None except OSError: dialog_error(lang(30610)) except Exception, e: dialog_error(e.message)