Removes blank popup window from db reset logic

Cleans up the database reset logic to remove a blank popup window. Some
other minor cleanup is included for readability.
This commit is contained in:
owner 2019-08-24 09:16:39 -05:00
commit 0108ed15e2
13 changed files with 102 additions and 109 deletions

View file

@ -538,6 +538,10 @@ msgctxt "#33074"
msgid "Are you sure you want to reset your local Kodi database?"
msgstr "Möchtest du wirklich deine lokale Kodi Datenbank zurücksetzen?"
msgctxt "#33085"
msgid "Unable to reset Kodi database while sync is running"
msgstr "Kodi-Datenbank kann während der Synchronisierung nicht zurückgesetzt werden"
msgctxt "#33086"
msgid "Remove all cached artwork?"
msgstr "Alle zwischengespeicherten Bilder entfernen?"

View file

@ -514,6 +514,10 @@ msgctxt "#33074"
msgid "Are you sure you want to reset your local Kodi database?"
msgstr ""
msgctxt "#33085"
msgid "Unable to reset Kodi database while sync is running"
msgstr ""
msgctxt "#33086"
msgid "Remove all cached artwork?"
msgstr ""

View file

@ -538,6 +538,10 @@ msgid "Are you sure you want to reset your local Kodi database?"
msgstr ""
"Êtes-vous sûr de vouloir réinitialiser votre base de données Kodi locale ?"
msgctxt "#33085"
msgid "Unable to reset Kodi database while sync is running"
msgstr "Impossible de réinitialiser la base de données Kodi lorsque la synchronisation est en cours d'exécution"
msgctxt "#33086"
msgid "Remove all cached artwork?"
msgstr "Supprimer toutes les illustrations en cache ?"

View file

@ -536,6 +536,10 @@ msgctxt "#33074"
msgid "Are you sure you want to reset your local Kodi database?"
msgstr "Sei sicuro di voler resettare il tuo database Kodi locale?"
msgctxt "#33085"
msgid "Unable to reset Kodi database while sync is running"
msgstr "Impossibile ripristinare il database Kodi mentre la sincronizzazione è in esecuzione"
msgctxt "#33086"
msgid "Remove all cached artwork?"
msgstr "Rimuove tutte le artwork dalla cache?"

View file

@ -534,6 +534,10 @@ msgctxt "#33074"
msgid "Are you sure you want to reset your local Kodi database?"
msgstr "Weet u zeker dat u de lokale Kodi databank resetten wilt?"
msgctxt "#33085"
msgid "Unable to reset Kodi database while sync is running"
msgstr "Kan Kodi-database niet opnieuw instellen terwijl synchronisatie wordt uitgevoerd"
msgctxt "#33086"
msgid "Remove all cached artwork?"
msgstr "Cached artwork verwijderen?"

View file

@ -538,6 +538,10 @@ msgctxt "#33074"
msgid "Are you sure you want to reset your local Kodi database?"
msgstr "Na pewno chcesz zresetować lokalną bazę Kodi?"
msgctxt "#33085"
msgid "Unable to reset Kodi database while sync is running"
msgstr "Nie można zresetować bazy danych Kodi podczas synchronizacji"
msgctxt "#33086"
msgid "Remove all cached artwork?"
msgstr "Usunąć pobrane grafiki?"

View file

@ -16,6 +16,7 @@ from helper.utils import create_id
##################################################################################################
LOG = logging.getLogger("JELLYFIN."+__name__)
ADDON_DATA = xbmc.translatePath("special://profile/addon_data/plugin.video.jellyfin/").decode('utf-8')
##################################################################################################
@ -82,12 +83,7 @@ def get_device_id(reset=False):
if client_id:
return client_id
directory = xbmc.translatePath('special://profile/addon_data/plugin.video.jellyfin/').decode('utf-8')
if not xbmcvfs.exists(directory):
xbmcvfs.mkdir(directory)
jellyfin_guid = os.path.join(directory, "jellyfin_guid")
jellyfin_guid = os.path.join(ADDON_DATA, "jellyfin_guid")
file_guid = xbmcvfs.File(jellyfin_guid)
client_id = file_guid.read()

View file

@ -18,6 +18,7 @@ from objects import obj
#################################################################################################
LOG = logging.getLogger("JELLYFIN."+__name__)
ADDON_DATA = xbmc.translatePath("special://profile/addon_data/plugin.video.jellyfin/").decode('utf-8')
#################################################################################################
@ -211,43 +212,26 @@ def reset():
from views import Views
views = Views()
if not dialog("yesno", heading="{jellyfin}", line1=_(33074)):
return
window('jellyfin_should_stop.bool', True)
count = 10
while window('jellyfin_sync.bool'):
LOG.info("Sync is running...")
count -= 1
if not count:
if window('jellyfin_sync.bool'):
dialog("ok", heading="{jellyfin}", line1=_(33085))
return
if xbmc.Monitor().waitForAbort(1):
return
else:
if dialog("yesno", heading="{jellyfin}", line1=_(33074)):
reset_kodi()
reset_jellyfin()
views.delete_playlists()
views.delete_nodes()
LOG.info("[ reset kodi database ]")
if dialog("yesno", heading="{jellyfin}", line1=_(33086)):
reset_artwork()
addon_data = xbmc.translatePath("special://profile/addon_data/plugin.video.jellyfin/").decode('utf-8')
if dialog("yesno", heading="{jellyfin}", line1=_(33087)):
xbmcvfs.delete(os.path.join(addon_data, "settings.xml"))
xbmcvfs.delete(os.path.join(addon_data, "data.json"))
xbmcvfs.delete(os.path.join(ADDON_DATA, "settings.xml"))
xbmcvfs.delete(os.path.join(ADDON_DATA, "data.json"))
LOG.info("[ reset settings ]")
if xbmcvfs.exists(os.path.join(addon_data, "sync.json")):
xbmcvfs.delete(os.path.join(addon_data, "sync.json"))
if xbmcvfs.exists(os.path.join(ADDON_DATA, "sync.json")):
xbmcvfs.delete(os.path.join(ADDON_DATA, "sync.json"))
settings('enableMusic.bool', False)
settings('MinimumSetup', "")
@ -255,6 +239,10 @@ def reset():
settings('SyncInstallRunDone.bool', False)
dialog("ok", heading="{jellyfin}", line1=_(33088))
xbmc.executebuiltin('RestartApp')
else:
pass
return
def reset_kodi():
@ -278,7 +266,7 @@ def reset_kodi():
if name != 'version':
musicdb.cursor.execute("DELETE FROM " + name)
LOG.warn("[ reset kodi ]")
LOG.info("[ reset kodi ]")
def reset_jellyfin():
@ -295,7 +283,7 @@ def reset_jellyfin():
jellyfindb.cursor.execute("DROP table IF EXISTS view")
jellyfindb.cursor.execute("DROP table IF EXISTS version")
LOG.warn("[ reset jellyfin ]")
LOG.info("[ reset jellyfin ]")
def reset_artwork():
@ -322,17 +310,12 @@ def reset_artwork():
if name != 'version':
texdb.cursor.execute("DELETE FROM " + name)
LOG.warn("[ reset artwork ]")
LOG.info("[ reset artwork ]")
def get_sync():
path = xbmc.translatePath("special://profile/addon_data/plugin.video.jellyfin/").decode('utf-8')
if not xbmcvfs.exists(path):
xbmcvfs.mkdirs(path)
try:
with open(os.path.join(path, 'sync.json')) as infile:
with open(os.path.join(ADDON_DATA, 'sync.json')) as infile:
sync = json.load(infile)
except Exception:
sync = {}
@ -346,34 +329,23 @@ def get_sync():
def save_sync(sync):
path = xbmc.translatePath("special://profile/addon_data/plugin.video.jellyfin/").decode('utf-8')
if not xbmcvfs.exists(path):
xbmcvfs.mkdirs(path)
sync['Date'] = datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')
with open(os.path.join(path, 'sync.json'), 'w') as outfile:
with open(os.path.join(ADDON_DATA, 'sync.json'), 'w') as outfile:
json.dump(sync, outfile, sort_keys=True, indent=4, ensure_ascii=False)
def get_credentials():
path = xbmc.translatePath("special://profile/addon_data/plugin.video.jellyfin/").decode('utf-8')
if not xbmcvfs.exists(path):
xbmcvfs.mkdirs(path)
try:
with open(os.path.join(path, 'data.json')) as infile:
credentials = json.load(infile)
except Exception:
if os.path.exists(os.path.join(ADDON_DATA, 'data.json')):
pass
elif os.path.exists(os.path.join(ADDON_DATA, 'data.txt')):
os.rename(os.path.join(ADDON_DATA, 'data.txt'), os.path.join(ADDON_DATA, 'data.json'))
else:
open(os.path.join(ADDON_DATA, 'data.json'), 'a')
try:
with open(os.path.join(path, 'data.txt')) as infile:
with open(os.path.join(ADDON_DATA, 'data.json')) as infile:
credentials = json.load(infile)
save_credentials(credentials)
xbmcvfs.delete(os.path.join(path, 'data.txt'))
except Exception:
credentials = {}
@ -383,12 +355,8 @@ def get_credentials():
def save_credentials(credentials):
credentials = credentials or {}
path = xbmc.translatePath("special://profile/addon_data/plugin.video.jellyfin/").decode('utf-8')
if not xbmcvfs.exists(path):
xbmcvfs.mkdirs(path)
with open(os.path.join(path, 'data.json'), 'w') as outfile:
with open(os.path.join(ADDON_DATA, 'data.json'), 'w') as outfile:
json.dump(credentials, outfile, sort_keys=True, indent=4, ensure_ascii=False)
def get_item(kodi_id, media):

View file

@ -22,7 +22,7 @@ from jellyfin import Jellyfin
##################################################################################################
LOG = logging.getLogger("JELLYFIN."+__name__)
LOG = logging.getLogger("JELLYFIN." + __name__)
LIMIT = min(int(settings('limitIndex') or 50), 50)
DTHREADS = int(settings('limitThreads') or 3)
MEDIA = {
@ -96,7 +96,7 @@ class Library(threading.Thread):
def run(self):
LOG.warn("--->[ library ]")
LOG.info("--->[ library ]")
if not self.startup():
self.stop_client()
@ -117,7 +117,7 @@ class Library(threading.Thread):
if self.monitor.waitForAbort(2):
break
LOG.warn("---<[ library ]")
LOG.info("---<[ library ]")
def test_databases(self):

View file

@ -22,7 +22,7 @@ from webservice import WebService
#################################################################################################
LOG = logging.getLogger("JELLYFIN."+__name__)
LOG = logging.getLogger("JELLYFIN." + __name__)
#################################################################################################
@ -449,7 +449,7 @@ class Listener(threading.Thread):
''' Detect the resume dialog for widgets.
Detect external players.
'''
LOG.warn("--->[ listener ]")
LOG.info("--->[ listener ]")
while not self.stop_thread:
special_listener()

View file

@ -15,7 +15,7 @@ from jellyfin import Jellyfin
#################################################################################################
LOG = logging.getLogger("JELLYFIN."+__name__)
LOG = logging.getLogger("JELLYFIN." + __name__)
#################################################################################################

View file

@ -10,7 +10,7 @@ from helper import _, settings, dialog, JSONRPC, compare_version
#################################################################################################
LOG = logging.getLogger("JELLYFIN."+__name__)
LOG = logging.getLogger("JELLYFIN." + __name__)
#################################################################################################

View file

@ -9,6 +9,7 @@ import sys
import xbmc
import xbmcaddon
import xbmcvfs
#################################################################################################
@ -27,6 +28,7 @@ from helper import settings
#################################################################################################
LOG = logging.getLogger("JELLYFIN." + __name__)
ADDON_DATA = xbmc.translatePath("special://profile/addon_data/plugin.video.jellyfin/").decode('utf-8')
DELAY = int(settings('startupDelay') if settings('SyncInstallRunDone.bool') else 4 or 0)
#################################################################################################
@ -71,14 +73,14 @@ if __name__ == "__main__":
LOG.info("-->[ service ]")
LOG.info("Delay startup by %s seconds.", DELAY)
if not xbmcvfs.exists(ADDON_DATA):
xbmcvfs.mkdirs(ADDON_DATA)
while True:
if not settings('enableAddon.bool'):
LOG.warn("Jellyfin for Kodi is not enabled.")
break
if settings('enableAddon.bool'):
try:
session = ServiceManager()
session.start()
session.join() # Block until the thread exits.
@ -92,5 +94,8 @@ if __name__ == "__main__":
LOG.exception(error)
break
else:
LOG.warn("Jellyfin for Kodi is not enabled.")
break
LOG.info("--<[ service ]")