mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-26 02:36:10 +00:00
parent
d142637122
commit
d737af606b
1 changed files with 16 additions and 21 deletions
35
service.py
35
service.py
|
@ -1,7 +1,6 @@
|
||||||
import xbmcaddon
|
import xbmcaddon
|
||||||
import xbmc
|
import xbmc
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
import json
|
import json
|
||||||
|
@ -15,10 +14,12 @@ 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():
|
||||||
|
@ -27,7 +28,6 @@ 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,7 +65,6 @@ class Service():
|
||||||
ws = WebSocketThread()
|
ws = WebSocketThread()
|
||||||
|
|
||||||
lastFile = None
|
lastFile = None
|
||||||
xbmcplayer = xbmc.Player()
|
|
||||||
|
|
||||||
while not self.KodiMonitor.abortRequested():
|
while not self.KodiMonitor.abortRequested():
|
||||||
|
|
||||||
|
@ -73,11 +72,11 @@ class Service():
|
||||||
# Abort was requested while waiting. We should exit
|
# Abort was requested while waiting. We should exit
|
||||||
break
|
break
|
||||||
|
|
||||||
if xbmcplayer.isPlaying():
|
if xbmc.Player().isPlaying():
|
||||||
try:
|
try:
|
||||||
playTime = xbmcplayer.getTime()
|
playTime = xbmc.Player().getTime()
|
||||||
totalTime = xbmcplayer.getTotalTime()
|
totalTime = xbmc.Player().getTotalTime()
|
||||||
currentFile = xbmcplayer.getPlayingFile()
|
currentFile = xbmc.Player().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
|
||||||
|
@ -89,7 +88,7 @@ class Service():
|
||||||
try:
|
try:
|
||||||
player.reportPlayback()
|
player.reportPlayback()
|
||||||
except Exception, msg:
|
except Exception, msg:
|
||||||
self.logMsg("Exception reporting progress: %s" % msg, 0)
|
xbmc.log("MB3 Sync Service -> Exception reporting progress : " + msg)
|
||||||
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!
|
||||||
|
@ -98,7 +97,7 @@ class Service():
|
||||||
player.autoPlayPlayback()
|
player.autoPlayPlayback()
|
||||||
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
self.logMsg("Exception in Playback Monitor Service: %s" % e, 0)
|
xbmc.log("MB3 Sync Service -> Exception in Playback Monitor Service : " + str(e))
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if (self.newUserClient == None):
|
if (self.newUserClient == None):
|
||||||
|
@ -114,13 +113,11 @@ class Service():
|
||||||
|
|
||||||
#full sync
|
#full sync
|
||||||
if(startupComplete == False):
|
if(startupComplete == False):
|
||||||
librarySync = self.librarySync
|
xbmc.log("Doing_Db_Sync: syncDatabase (Started)")
|
||||||
|
|
||||||
self.logMsg("Doing_Db_Sync: syncDatabase (Started)", 1)
|
|
||||||
libSync = librarySync.syncDatabase()
|
libSync = librarySync.syncDatabase()
|
||||||
self.logMsg("Doing_Db_Sync: syncDatabase (Finished) %s" % libSync, 1)
|
xbmc.log("Doing_Db_Sync: syncDatabase (Finished) " + str(libSync))
|
||||||
countSync = librarySync.updatePlayCounts()
|
countSync = librarySync.updatePlayCounts()
|
||||||
self.logMsg("Doing_Db_Sync: updatePlayCounts (Finished) %s" % countSync, 1)
|
xbmc.log("Doing_Db_Sync: updatePlayCounts (Finished) " + str(countSync))
|
||||||
|
|
||||||
# Force refresh newly set thumbnails
|
# Force refresh newly set thumbnails
|
||||||
xbmc.executebuiltin("UpdateLibrary(video)")
|
xbmc.executebuiltin("UpdateLibrary(video)")
|
||||||
|
@ -132,16 +129,14 @@ class Service():
|
||||||
break
|
break
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.logMsg("Not authenticated yet", 2)
|
xbmc.log("Not authenticated yet")
|
||||||
|
|
||||||
self.logMsg("Stopping Service", 0)
|
utils.logMsg("MB3 Sync Service", "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":
|
||||||
# Reset the initial sync
|
addon = xbmcaddon.Addon('plugin.video.emby')
|
||||||
addon.setSetting("SyncInstallRunDone", "false")
|
addon.setSetting("SyncInstallRunDone", "false")
|
||||||
|
|
||||||
if (self.newWebSocketThread != None):
|
if (self.newWebSocketThread != None):
|
||||||
|
|
Loading…
Reference in a new issue