def library_channel_remove_strm(channel, folder): enc_season = ('Season %s' % season).translate(None, '\/:*?"<>|').strip('.') enc_name = 'S%02dE%02d' % (season, episode) channel_folder = os.path.join(folder, channel) stream_file = os.path.join(channel_folder, channel + '.strm') if xbmcvfs.exists(stream_file): xbmcvfs.delete(stream_file) xbmcvfs.rmdir(channel_folder) return True return False
def library_channel_remove_strm(channel, folder): enc_season = ("Season %s" % season).translate(None, '\/:*?"<>|').strip(".") enc_name = "S%02dE%02d" % (season, episode) channel_folder = os.path.join(folder, channel) stream_file = os.path.join(channel_folder, channel + ".strm") if xbmcvfs.exists(stream_file): xbmcvfs.delete(stream_file) xbmcvfs.rmdir(channel_folder) return True return False
def library_tv_remove_strm(show, folder, id, season, episode): enc_season = ('Season %s' % season).translate(None, '\/:*?"<>|').strip('.') enc_name = 'S%02dE%02d' % (season, episode) season_folder = os.path.join(folder, enc_season) stream_file = os.path.join(season_folder, enc_name + "%s" % plugin.get_setting(SETTING_LIBRARY_TAGS, unicode) + '.strm') if xbmcvfs.exists(stream_file): xbmcvfs.delete(stream_file) while not xbmc.abortRequested and xbmcvfs.exists(stream_file): xbmc.sleep(1000) a,b = xbmcvfs.listdir(season_folder) if not a and not b: xbmcvfs.rmdir(season_folder) return True return False
def remove_folder(self, folder_id): if folder_id not in self.storage: return media_path = self.storage[folder_id][1] del self.storage[folder_id] if not direxists(media_path): return self.log.info("Removing from library folder: %s", media_path) files = xbmcvfs.listdir(media_path)[1] count_deleted = 0 for f in files: if f.endswith("[%d].strm" % folder_id): path = os.path.join(media_path, f) self.log.info("Removing file: %s", path) xbmcvfs.delete(path) count_deleted += 1 if len(files) == count_deleted: self.log.info("All files deleted, removing folder: %s", media_path) xbmcvfs.rmdir(media_path)
def library_channel_remove_strm(channel, folder): channel_folder = os.path.join(folder, channel) stream_file = os.path.join(channel_folder, channel + '.strm') info_file = os.path.join(channel_folder, 'player.info') nfo_file = os.path.join(channel_folder, channel + '.nfo') if xbmcvfs.exists(stream_file): xbmcvfs.delete(stream_file) xbmcvfs.delete(info_file) xbmcvfs.delete(nfo_file) xbmcvfs.rmdir(channel_folder) return True return False
def save_files(files, rename=False, on_finish=None): save = plugin.get_setting('save-files', int) if not save: on_finish() return src, dst = temp_path(), save_path() files_dict = {} for old_path in files: old_path = ensure_unicode(old_path) rel_path = os.path.relpath(old_path, src) new_path = os.path.join(dst, rel_path) if xbmcvfs.exists(new_path): if rename: if xbmcvfs.delete(old_path): log.info("File %s deleted.", old_path) continue files_dict[old_path] = new_path if not files_dict: if on_finish: on_finish() return files_to_copy = {} if save != 2 or xbmcgui.Dialog().yesno(lang(30000), *lang(40162).split("|")): for n, old_path in enumerate(files): old_path = ensure_unicode(old_path) if old_path not in files_dict: continue new_path = files_dict[old_path] xbmcvfs.mkdirs(os.path.dirname(new_path)) if rename: log.info("Renaming %s to %s...", old_path, new_path) if not xbmcvfs.rename(old_path, new_path): log.info( "Renaming failed. Trying to copy and delete old file..." ) files_to_copy[old_path] = new_path else: log.info("Success.") else: files_to_copy[old_path] = new_path if files_to_copy: copy_files(files_to_copy, delete=rename, on_finish=on_finish) elif on_finish: on_finish()
def run(self): if xbmcvfs.exists(self.dst): xbmcvfs.delete(self.dst) xbmcvfs.mkdirs(os.path.dirname(self.dst)) log.info("Copying %s to %s...", self.src, self.dst) xbmcvfs.delete(self.tmp) if xbmcvfs.copy(self.src, self.tmp): log.info("Success.") self.copied = True if xbmcvfs.rename(self.tmp, self.dst): if self.delete and xbmcvfs.delete(self.src): log.info("File %s deleted.", self.src) else: log.info("Renaming %s to %s failed.", self.tmp, self.dst) xbmcvfs.delete(self.tmp) else: log.info("Failed")
def save_files(files, rename=False, on_finish=None): save = plugin.get_setting('save-files', int) if not save: on_finish() return src, dst = temp_path(), save_path() files_dict = {} for old_path in files: old_path = ensure_unicode(old_path) rel_path = os.path.relpath(old_path, src) new_path = os.path.join(dst, rel_path) if xbmcvfs.exists(new_path): if rename: if xbmcvfs.delete(old_path): log.info("File %s deleted.", old_path) continue files_dict[old_path] = new_path if not files_dict: if on_finish: on_finish() return files_to_copy = {} if save != 2 or xbmcgui.Dialog().yesno(lang(30000), *lang(40162).split("|")): for n, old_path in enumerate(files): old_path = ensure_unicode(old_path) if old_path not in files_dict: continue new_path = files_dict[old_path] xbmcvfs.mkdirs(os.path.dirname(new_path)) if rename: log.info("Renaming %s to %s...", old_path, new_path) if not xbmcvfs.rename(old_path, new_path): log.info("Renaming failed. Trying to copy and delete old file...") files_to_copy[old_path] = new_path else: log.info("Success.") else: files_to_copy[old_path] = new_path if files_to_copy: copy_files(files_to_copy, delete=rename, on_finish=on_finish) elif on_finish: on_finish()