def backup(): ''' Emby backup. ''' from helper.utils import delete_folder, copytree path = settings('backupPath') folder_name = "Kodi%s.%s" % (xbmc.getInfoLabel('System.BuildVersion')[:2], xbmc.getInfoLabel('System.Date(dd-mm-yy)')) folder_name = dialog("input", heading=_(33089), defaultt=folder_name) if not folder_name: return backup = os.path.join(path, folder_name) if xbmcvfs.exists(backup + '/'): if not dialog("yesno", heading="{emby}", line1=_(33090)): return backup() delete_folder(backup) addon_data = xbmc.translatePath( "special://profile/addon_data/plugin.video.emby").decode('utf-8') destination_data = os.path.join(backup, "addon_data", "plugin.video.emby") destination_databases = os.path.join(backup, "Database") if not xbmcvfs.mkdirs(path) or not xbmcvfs.mkdirs(destination_databases): LOG.info("Unable to create all directories") dialog("notification", heading="{emby}", icon="{emby}", message=_(33165), sound=False) return copytree(addon_data, destination_data) db = xbmc.translatePath("special://database/").decode('utf-8') dirs, files = xbmcvfs.listdir(db) for Temp in files: if 'MyVideos' in Temp: xbmcvfs.copy(os.path.join(db, Temp), os.path.join(destination_databases, Temp)) LOG.info("copied %s", Temp) elif 'emby' in Temp: xbmcvfs.copy(os.path.join(db, Temp), os.path.join(destination_databases, Temp)) LOG.info("copied %s", Temp) elif 'MyMusic' in Temp: xbmcvfs.copy(os.path.join(db, Temp), os.path.join(destination_databases, Temp)) LOG.info("copied %s", Temp) LOG.info("backup completed") dialog("ok", heading="{emby}", line1="%s %s" % (_(33091), backup))
def backup(): ''' Emby backup. ''' from helper.utils import delete_folder, copytree path = settings('backupPath') folder_name = "Kodi%s.%s" % (xbmc.getInfoLabel('System.BuildVersion')[:2], xbmc.getInfoLabel('System.Date(dd-mm-yy)')) folder_name = dialog("input", heading=_(33089), defaultt=folder_name) if not folder_name: return backup = os.path.join(path, folder_name) if xbmcvfs.exists(backup + '/'): if not dialog("yesno", heading="{emby}", line1=_(33090)): return backup() delete_folder(backup) addon_data = xbmc.translatePath("special://profile/addon_data/plugin.video.emby").decode('utf-8') destination_data = os.path.join(backup, "addon_data", "plugin.video.emby") destination_databases = os.path.join(backup, "Database") if not xbmcvfs.mkdirs(path) or not xbmcvfs.mkdirs(destination_databases): LOG.info("Unable to create all directories") dialog("notification", heading="{emby}", icon="{emby}", message=_(33165), sound=False) return copytree(addon_data, destination_data) databases = Objects().objects db = xbmc.translatePath(databases['emby']).decode('utf-8') xbmcvfs.copy(db, os.path.join(destination_databases, db.rsplit('\\', 1)[1])) LOG.info("copied emby.db") db = xbmc.translatePath(databases['video']).decode('utf-8') filename = db.rsplit('\\', 1)[1] xbmcvfs.copy(db, os.path.join(destination_databases, filename)) LOG.info("copied %s", filename) if settings('enableMusic.bool'): db = xbmc.translatePath(databases['music']).decode('utf-8') filename = db.rsplit('\\', 1)[1] xbmcvfs.copy(db, os.path.join(destination_databases, filename)) LOG.info("copied %s", filename) LOG.info("backup completed") dialog("ok", heading="{emby}", line1="%s %s" % (_(33091), backup))