Quick cleanup

Changing the rest of logging to utils. Changed xbmc.Player() to one
instance.
This commit is contained in:
angelblue05 2015-04-12 11:39:02 -05:00
parent 060a6f1323
commit d142637122
1 changed files with 21 additions and 16 deletions

View File

@ -1,6 +1,7 @@
import xbmcaddon import xbmcaddon
import xbmc import xbmc
import xbmcgui import xbmcgui
import os import os
import threading import threading
import json import json
@ -14,12 +15,10 @@ import KodiMonitor
import Utils as utils import Utils as utils
from LibrarySync import LibrarySync from LibrarySync import LibrarySync
from Player import Player from Player import Player
from DownloadUtils import DownloadUtils
from ConnectionManager import ConnectionManager from ConnectionManager import ConnectionManager
from ClientInformation import ClientInformation from ClientInformation import ClientInformation
from WebSocketClient import WebSocketThread from WebSocketClient import WebSocketThread
from UserClient import UserClient from UserClient import UserClient
librarySync = LibrarySync()
class Service(): class Service():
@ -28,6 +27,7 @@ class Service():
newWebSocketThread = None newWebSocketThread = None
newUserClient = None newUserClient = None
librarySync = LibrarySync()
clientInfo = ClientInformation() clientInfo = ClientInformation()
addonName = clientInfo.getAddonName() addonName = clientInfo.getAddonName()
className = None className = None
@ -65,6 +65,7 @@ class Service():
ws = WebSocketThread() ws = WebSocketThread()
lastFile = None lastFile = None
xbmcplayer = xbmc.Player()
while not self.KodiMonitor.abortRequested(): while not self.KodiMonitor.abortRequested():
@ -72,11 +73,11 @@ class Service():
# Abort was requested while waiting. We should exit # Abort was requested while waiting. We should exit
break break
if xbmc.Player().isPlaying(): if xbmcplayer.isPlaying():
try: try:
playTime = xbmc.Player().getTime() playTime = xbmcplayer.getTime()
totalTime = xbmc.Player().getTotalTime() totalTime = xbmcplayer.getTotalTime()
currentFile = xbmc.Player().getPlayingFile() currentFile = xbmcplayer.getPlayingFile()
if(player.played_information.get(currentFile) != None): if(player.played_information.get(currentFile) != None):
player.played_information[currentFile]["currentPosition"] = playTime player.played_information[currentFile]["currentPosition"] = playTime
@ -88,7 +89,7 @@ class Service():
try: try:
player.reportPlayback() player.reportPlayback()
except Exception, msg: except Exception, msg:
xbmc.log("MB3 Sync Service -> Exception reporting progress : " + msg) self.logMsg("Exception reporting progress: %s" % msg, 0)
pass pass
lastProgressUpdate = datetime.today() lastProgressUpdate = datetime.today()
# only try autoplay when there's 20 seconds or less remaining and only once! # only try autoplay when there's 20 seconds or less remaining and only once!
@ -97,7 +98,7 @@ class Service():
player.autoPlayPlayback() player.autoPlayPlayback()
except Exception, e: except Exception, e:
xbmc.log("MB3 Sync Service -> Exception in Playback Monitor Service : " + str(e)) self.logMsg("Exception in Playback Monitor Service: %s" % e, 0)
pass pass
else: else:
if (self.newUserClient == None): if (self.newUserClient == None):
@ -113,11 +114,13 @@ class Service():
#full sync #full sync
if(startupComplete == False): if(startupComplete == False):
xbmc.log("Doing_Db_Sync: syncDatabase (Started)") librarySync = self.librarySync
self.logMsg("Doing_Db_Sync: syncDatabase (Started)", 1)
libSync = librarySync.syncDatabase() libSync = librarySync.syncDatabase()
xbmc.log("Doing_Db_Sync: syncDatabase (Finished) " + str(libSync)) self.logMsg("Doing_Db_Sync: syncDatabase (Finished) %s" % libSync, 1)
countSync = librarySync.updatePlayCounts() countSync = librarySync.updatePlayCounts()
xbmc.log("Doing_Db_Sync: updatePlayCounts (Finished) " + str(countSync)) self.logMsg("Doing_Db_Sync: updatePlayCounts (Finished) %s" % countSync, 1)
# Force refresh newly set thumbnails # Force refresh newly set thumbnails
xbmc.executebuiltin("UpdateLibrary(video)") xbmc.executebuiltin("UpdateLibrary(video)")
@ -129,14 +132,16 @@ class Service():
break break
else: else:
xbmc.log("Not authenticated yet") self.logMsg("Not authenticated yet", 2)
utils.logMsg("MB3 Sync Service", "stopping Service",0) self.logMsg("Stopping Service", 0)
# If user reset library database. # If user reset library database
WINDOW = xbmcgui.Window(10000) WINDOW = xbmcgui.Window(10000)
addon = xbmcaddon.Addon('plugin.video.emby')
if WINDOW.getProperty("SyncInstallRunDone") == "false": if WINDOW.getProperty("SyncInstallRunDone") == "false":
addon = xbmcaddon.Addon('plugin.video.emby') # Reset the initial sync
addon.setSetting("SyncInstallRunDone", "false") addon.setSetting("SyncInstallRunDone", "false")
if (self.newWebSocketThread != None): if (self.newWebSocketThread != None):