mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-24 17:56:11 +00:00
Quick adjust for emby backup
This commit is contained in:
parent
a9aad8fabc
commit
c1c0ad6d56
1 changed files with 31 additions and 17 deletions
|
@ -5,6 +5,7 @@
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import ntpath
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
import urlparse
|
import urlparse
|
||||||
|
@ -19,6 +20,7 @@ import artwork
|
||||||
import utils
|
import utils
|
||||||
import clientinfo
|
import clientinfo
|
||||||
import connectmanager
|
import connectmanager
|
||||||
|
import database
|
||||||
import downloadutils
|
import downloadutils
|
||||||
import librarysync
|
import librarysync
|
||||||
import read_embyserver as embyserver
|
import read_embyserver as embyserver
|
||||||
|
@ -29,7 +31,6 @@ import playutils
|
||||||
import api
|
import api
|
||||||
from views import Playlist, VideoNodes
|
from views import Playlist, VideoNodes
|
||||||
from utils import window, settings, dialog, language as lang
|
from utils import window, settings, dialog, language as lang
|
||||||
from database import DatabaseConn
|
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
@ -149,13 +150,13 @@ def emby_backup():
|
||||||
# filename
|
# filename
|
||||||
default_value = "Kodi%s.%s" % (xbmc.getInfoLabel('System.BuildVersion')[:2],
|
default_value = "Kodi%s.%s" % (xbmc.getInfoLabel('System.BuildVersion')[:2],
|
||||||
xbmc.getInfoLabel('System.Date(dd-mm-yy)'))
|
xbmc.getInfoLabel('System.Date(dd-mm-yy)'))
|
||||||
filename = dialog(type_="input",
|
folder_name = dialog(type_="input",
|
||||||
heading=lang(33089),
|
heading=lang(33089),
|
||||||
defaultt=default_value)
|
defaultt=default_value)
|
||||||
if not filename:
|
if not folder_name:
|
||||||
return
|
return
|
||||||
|
|
||||||
backup = os.path.join(path, filename)
|
backup = os.path.join(path, folder_name)
|
||||||
log.info("Backup: %s", backup)
|
log.info("Backup: %s", backup)
|
||||||
|
|
||||||
# Create directory
|
# Create directory
|
||||||
|
@ -168,22 +169,35 @@ def emby_backup():
|
||||||
shutil.rmtree(backup)
|
shutil.rmtree(backup)
|
||||||
|
|
||||||
# Addon_data
|
# Addon_data
|
||||||
shutil.copytree(src=xbmc.translatePath(
|
addon_data = xbmc.translatePath("special://profile/addon_data/plugin.video.emby").decode('utf-8')
|
||||||
"special://profile/addon_data/plugin.video.emby").decode('utf-8'),
|
try:
|
||||||
dst=os.path.join(backup, "addon_data", "plugin.video.emby"))
|
shutil.copytree(src=addon_data,
|
||||||
|
dst=os.path.join(backup, "addon_data", "plugin.video.emby"))
|
||||||
|
except shutil.Error as error:
|
||||||
|
log.error(error)
|
||||||
|
|
||||||
# Database files
|
# Database files
|
||||||
database = os.path.join(backup, "Database")
|
database_folder = os.path.join(backup, "Database")
|
||||||
xbmcvfs.mkdir(database)
|
if not xbmcvfs.mkdir(database_folder):
|
||||||
|
try:
|
||||||
|
os.makedirs(database_folder)
|
||||||
|
except OSError as error:
|
||||||
|
log.error(error)
|
||||||
|
dialog(type_="ok",
|
||||||
|
heading="{emby}",
|
||||||
|
line1="Failed to create backup")
|
||||||
|
return
|
||||||
|
|
||||||
# Emby database
|
# Emby database
|
||||||
shutil.copy(src=xbmc.translatePath("special://database/emby.db").decode('utf-8'),
|
emby_path = database.emby_database()
|
||||||
dst=database)
|
xbmcvfs.copy(emby_path, os.path.join(database_folder, ntpath.basename(emby_path)))
|
||||||
# Videos database
|
# Videos database
|
||||||
shutil.copy(src=DatabaseConn()._SQL('video'), dst=database)
|
video_path = database.video_database()
|
||||||
|
xbmcvfs.copy(video_path, os.path.join(database_folder, ntpath.basename(video_path)))
|
||||||
# Music database
|
# Music database
|
||||||
if settings('enableMusic') == "true":
|
if settings('enableMusic') == "true":
|
||||||
shutil.copy(src=DatabaseConn()._SQL('music'), dst=database)
|
music_path = database.music_database()
|
||||||
|
xbmcvfs.copy(music_path, os.path.join(database_folder, ntpath.basename(music_path)))
|
||||||
|
|
||||||
dialog(type_="ok",
|
dialog(type_="ok",
|
||||||
heading="{emby}",
|
heading="{emby}",
|
||||||
|
@ -234,7 +248,7 @@ def deleteItem():
|
||||||
log.info("Unknown type, unable to proceed.")
|
log.info("Unknown type, unable to proceed.")
|
||||||
return
|
return
|
||||||
|
|
||||||
with DatabaseConn('emby') as cursor:
|
with database.DatabaseConn('emby') as cursor:
|
||||||
emby_db = embydb.Embydb_Functions(cursor)
|
emby_db = embydb.Embydb_Functions(cursor)
|
||||||
item = emby_db.getItem_byKodiId(dbId, itemType)
|
item = emby_db.getItem_byKodiId(dbId, itemType)
|
||||||
|
|
||||||
|
@ -420,7 +434,7 @@ def getThemeMedia():
|
||||||
return
|
return
|
||||||
|
|
||||||
# Get every user view Id
|
# Get every user view Id
|
||||||
with DatabaseConn('emby') as cursor:
|
with database.DatabaseConn('emby') as cursor:
|
||||||
emby_db = embydb.Embydb_Functions(cursor)
|
emby_db = embydb.Embydb_Functions(cursor)
|
||||||
viewids = emby_db.getViews()
|
viewids = emby_db.getViews()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue