merge with my changes

This commit is contained in:
shaun 2016-10-15 14:37:35 +11:00
commit 5d725c9f0b
7 changed files with 54 additions and 34 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.emby"
name="Emby"
version="2.2.46"
version="2.2.48"
provider-name="Emby.media">
<requires>
<import addon="xbmc.python" version="2.19.0"/>

View file

@ -263,9 +263,15 @@ class ConnectionManager(object):
log.debug("MultiGroup : %s" % str(MULTI_GROUP))
log.debug("Sending UDP Data: %s" % MESSAGE)
sock.sendto(MESSAGE, MULTI_GROUP)
servers = []
try:
sock.sendto(MESSAGE, MULTI_GROUP)
except Exception as error:
log.error(error)
return servers
while True:
try:
data, addr = sock.recvfrom(1024) # buffer size

View file

@ -35,14 +35,12 @@ class ConnectManager(object):
self.__dict__ = self._shared_state
if not self.state and not window('emby_currUser'):
client_info = clientinfo.ClientInfo()
self.emby = embyserver.Read_EmbyServer()
version = client_info.get_version()
device_name = client_info.get_device_name()
device_id = client_info.get_device_id()
self._connect = connectionmanager.ConnectionManager(appName="Kodi",
appVersion=version,
deviceName=device_name,
@ -54,16 +52,22 @@ class ConnectManager(object):
xbmcvfs.mkdirs(path)
self._connect.setFilePath(path)
if window('emby_state.json'):
self.state = window('emby_state.json')
elif not self.state:
self.state = self._connect.connect()
log.info("Started with: %s", self.state)
window('emby_state.json', value=self.state)
def update_state(self):
self.state = self._connect.connect({'updateDateLastAccessed': False})
return self.state
return self.get_state()
def get_state(self):
window('emby_state.json', value=self.state)
return self.state
def get_server(self, server):

View file

@ -7,6 +7,7 @@ import clientinfo
import md5
import xbmc
import platform
import xbmcgui
from utils import window, settings, language as lang
log = logging.getLogger("EMBY."+__name__)
@ -32,6 +33,10 @@ class GoogleAnalytics():
self.device_id = md5.new(self.device_id).hexdigest()
self.user_name = md5.new(self.user_name).hexdigest()
# resolution
self.height = xbmcgui.Window(10000).getHeight()
self.width = xbmcgui.Window(10000).getWidth()
def getUserAgentOS(self):
return platform.system()
@ -100,6 +105,9 @@ class GoogleAnalytics():
data['ec'] = eventCategory # Event Category
data['ea'] = eventAction # Event Action
# add width and height
data['sr'] = str(self.width) + "x" + str(self.height)
if(eventLabel != None):
data['el'] = eventLabel # Event Label

View file

@ -81,9 +81,6 @@ class LibrarySync(threading.Thread):
# Run at start up - optional to use the server plugin
if settings('SyncInstallRunDone') == "true":
ga.sendEventData("SyncAction", "FastSync")
# Validate views
self.refreshViews()
completed = False
@ -97,11 +94,13 @@ class LibrarySync(threading.Thread):
if plugin['Name'] == "Emby.Kodi Sync Queue":
log.debug("Found server plugin.")
self.isFastSync = True
ga.sendEventData("SyncAction", "FastSync")
completed = self.fastSync()
break
if not completed:
# Fast sync failed or server plugin is not found
ga.sendEventData("SyncAction", "Sync")
completed = ManualSync().sync()
else:
# Install sync is not completed

View file

@ -477,6 +477,9 @@ class Player(xbmc.Player):
self.played_info.clear()
ga = GoogleAnalytics()
ga.sendEventData("PlayAction", "Stopped")
def stopPlayback(self, data):
log.debug("stopPlayback called")

View file

@ -67,7 +67,7 @@ class Service(object):
# Reset window props for profile switch
properties = [
"emby_online", "emby_serverStatus", "emby_onWake",
"emby_online", "emby_state.json" "emby_serverStatus", "emby_onWake",
"emby_syncRunning", "emby_dbCheck", "emby_kodiScan",
"emby_shouldStop", "emby_currUser", "emby_dbScan", "emby_sessionId",
"emby_initialScan", "emby_customplaylist", "emby_playbackProps"
@ -120,6 +120,14 @@ class Service(object):
# If an item is playing
if self.kodi_player.isPlaying():
# ping metrics server to keep sessions alive while playing
# ping every 5 min
timeSinceLastPing = time.time() - self.lastMetricPing
if(timeSinceLastPing > 300):
self.lastMetricPing = time.time()
ga = GoogleAnalytics()
ga.sendEventData("PlayAction", "PlayPing")
self._report_progress()
elif not self.startup:
@ -140,14 +148,6 @@ class Service(object):
# or Kodi is shut down.
self._server_online_check()
# ping metrics server to keep sessions alive
# ping every 3 min
timeSinceLastPing = time.time() - self.lastMetricPing
if(timeSinceLastPing > 180):
self.lastMetricPing = time.time()
ga = GoogleAnalytics()
ga.sendEventData("Application", "Ping")
if self.monitor.waitForAbort(1):
# Abort was requested while waiting. We should exit
break
@ -297,8 +297,8 @@ class Service(object):
def shutdown(self):
ga = GoogleAnalytics()
ga.sendEventData("Application", "Shutdown")
#ga = GoogleAnalytics()
#ga.sendEventData("Application", "Shutdown")
if self.userclient_running:
self.userclient_thread.stop_client()