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