mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
merge with my changes
This commit is contained in:
commit
5d725c9f0b
7 changed files with 54 additions and 34 deletions
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<addon id="plugin.video.emby"
|
<addon id="plugin.video.emby"
|
||||||
name="Emby"
|
name="Emby"
|
||||||
version="2.2.46"
|
version="2.2.48"
|
||||||
provider-name="Emby.media">
|
provider-name="Emby.media">
|
||||||
<requires>
|
<requires>
|
||||||
<import addon="xbmc.python" version="2.19.0"/>
|
<import addon="xbmc.python" version="2.19.0"/>
|
||||||
|
|
|
@ -263,9 +263,15 @@ class ConnectionManager(object):
|
||||||
|
|
||||||
log.debug("MultiGroup : %s" % str(MULTI_GROUP))
|
log.debug("MultiGroup : %s" % str(MULTI_GROUP))
|
||||||
log.debug("Sending UDP Data: %s" % MESSAGE)
|
log.debug("Sending UDP Data: %s" % MESSAGE)
|
||||||
sock.sendto(MESSAGE, MULTI_GROUP)
|
|
||||||
|
|
||||||
servers = []
|
servers = []
|
||||||
|
|
||||||
|
try:
|
||||||
|
sock.sendto(MESSAGE, MULTI_GROUP)
|
||||||
|
except Exception as error:
|
||||||
|
log.error(error)
|
||||||
|
return servers
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
data, addr = sock.recvfrom(1024) # buffer size
|
data, addr = sock.recvfrom(1024) # buffer size
|
||||||
|
|
|
@ -35,35 +35,39 @@ class ConnectManager(object):
|
||||||
|
|
||||||
self.__dict__ = self._shared_state
|
self.__dict__ = self._shared_state
|
||||||
|
|
||||||
if not self.state and not window('emby_currUser'):
|
client_info = clientinfo.ClientInfo()
|
||||||
client_info = clientinfo.ClientInfo()
|
self.emby = embyserver.Read_EmbyServer()
|
||||||
self.emby = embyserver.Read_EmbyServer()
|
|
||||||
|
|
||||||
version = client_info.get_version()
|
version = client_info.get_version()
|
||||||
device_name = client_info.get_device_name()
|
device_name = client_info.get_device_name()
|
||||||
device_id = client_info.get_device_id()
|
device_id = client_info.get_device_id()
|
||||||
|
self._connect = connectionmanager.ConnectionManager(appName="Kodi",
|
||||||
self._connect = connectionmanager.ConnectionManager(appName="Kodi",
|
appVersion=version,
|
||||||
appVersion=version,
|
deviceName=device_name,
|
||||||
deviceName=device_name,
|
deviceId=device_id)
|
||||||
deviceId=device_id)
|
path = xbmc.translatePath(
|
||||||
path = xbmc.translatePath(
|
|
||||||
"special://profile/addon_data/plugin.video.emby/").decode('utf-8')
|
"special://profile/addon_data/plugin.video.emby/").decode('utf-8')
|
||||||
|
|
||||||
if not xbmcvfs.exists(path):
|
if not xbmcvfs.exists(path):
|
||||||
xbmcvfs.mkdirs(path)
|
xbmcvfs.mkdirs(path)
|
||||||
|
|
||||||
self._connect.setFilePath(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()
|
self.state = self._connect.connect()
|
||||||
log.info("Started with: %s", self.state)
|
log.info("Started with: %s", self.state)
|
||||||
|
window('emby_state.json', value=self.state)
|
||||||
|
|
||||||
|
|
||||||
def update_state(self):
|
def update_state(self):
|
||||||
|
|
||||||
self.state = self._connect.connect({'updateDateLastAccessed': False})
|
self.state = self._connect.connect({'updateDateLastAccessed': False})
|
||||||
return self.state
|
return self.get_state()
|
||||||
|
|
||||||
def get_state(self):
|
def get_state(self):
|
||||||
|
window('emby_state.json', value=self.state)
|
||||||
return self.state
|
return self.state
|
||||||
|
|
||||||
def get_server(self, server):
|
def get_server(self, server):
|
||||||
|
|
|
@ -7,6 +7,7 @@ import clientinfo
|
||||||
import md5
|
import md5
|
||||||
import xbmc
|
import xbmc
|
||||||
import platform
|
import platform
|
||||||
|
import xbmcgui
|
||||||
from utils import window, settings, language as lang
|
from utils import window, settings, language as lang
|
||||||
|
|
||||||
log = logging.getLogger("EMBY."+__name__)
|
log = logging.getLogger("EMBY."+__name__)
|
||||||
|
@ -31,6 +32,10 @@ class GoogleAnalytics():
|
||||||
# use md5 for client and user for analytics
|
# use md5 for client and user for analytics
|
||||||
self.device_id = md5.new(self.device_id).hexdigest()
|
self.device_id = md5.new(self.device_id).hexdigest()
|
||||||
self.user_name = md5.new(self.user_name).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):
|
def getUserAgentOS(self):
|
||||||
|
|
||||||
|
@ -99,6 +104,9 @@ class GoogleAnalytics():
|
||||||
data['t'] = 'event' # action type
|
data['t'] = 'event' # action type
|
||||||
data['ec'] = eventCategory # Event Category
|
data['ec'] = eventCategory # Event Category
|
||||||
data['ea'] = eventAction # Event Action
|
data['ea'] = eventAction # Event Action
|
||||||
|
|
||||||
|
# add width and height
|
||||||
|
data['sr'] = str(self.width) + "x" + str(self.height)
|
||||||
|
|
||||||
if(eventLabel != None):
|
if(eventLabel != None):
|
||||||
data['el'] = eventLabel # Event Label
|
data['el'] = eventLabel # Event Label
|
||||||
|
|
|
@ -81,9 +81,6 @@ class LibrarySync(threading.Thread):
|
||||||
|
|
||||||
# Run at start up - optional to use the server plugin
|
# Run at start up - optional to use the server plugin
|
||||||
if settings('SyncInstallRunDone') == "true":
|
if settings('SyncInstallRunDone') == "true":
|
||||||
|
|
||||||
ga.sendEventData("SyncAction", "FastSync")
|
|
||||||
|
|
||||||
# Validate views
|
# Validate views
|
||||||
self.refreshViews()
|
self.refreshViews()
|
||||||
completed = False
|
completed = False
|
||||||
|
@ -97,11 +94,13 @@ class LibrarySync(threading.Thread):
|
||||||
if plugin['Name'] == "Emby.Kodi Sync Queue":
|
if plugin['Name'] == "Emby.Kodi Sync Queue":
|
||||||
log.debug("Found server plugin.")
|
log.debug("Found server plugin.")
|
||||||
self.isFastSync = True
|
self.isFastSync = True
|
||||||
|
ga.sendEventData("SyncAction", "FastSync")
|
||||||
completed = self.fastSync()
|
completed = self.fastSync()
|
||||||
break
|
break
|
||||||
|
|
||||||
if not completed:
|
if not completed:
|
||||||
# Fast sync failed or server plugin is not found
|
# Fast sync failed or server plugin is not found
|
||||||
|
ga.sendEventData("SyncAction", "Sync")
|
||||||
completed = ManualSync().sync()
|
completed = ManualSync().sync()
|
||||||
else:
|
else:
|
||||||
# Install sync is not completed
|
# Install sync is not completed
|
||||||
|
|
|
@ -476,6 +476,9 @@ class Player(xbmc.Player):
|
||||||
xbmcvfs.delete("%s%s" % (path, file))
|
xbmcvfs.delete("%s%s" % (path, file))
|
||||||
|
|
||||||
self.played_info.clear()
|
self.played_info.clear()
|
||||||
|
|
||||||
|
ga = GoogleAnalytics()
|
||||||
|
ga.sendEventData("PlayAction", "Stopped")
|
||||||
|
|
||||||
def stopPlayback(self, data):
|
def stopPlayback(self, data):
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ class Service(object):
|
||||||
# Reset window props for profile switch
|
# Reset window props for profile switch
|
||||||
properties = [
|
properties = [
|
||||||
|
|
||||||
"emby_online", "emby_serverStatus", "emby_onWake",
|
"emby_online", "emby_state.json" "emby_serverStatus", "emby_onWake",
|
||||||
"emby_syncRunning", "emby_dbCheck", "emby_kodiScan",
|
"emby_syncRunning", "emby_dbCheck", "emby_kodiScan",
|
||||||
"emby_shouldStop", "emby_currUser", "emby_dbScan", "emby_sessionId",
|
"emby_shouldStop", "emby_currUser", "emby_dbScan", "emby_sessionId",
|
||||||
"emby_initialScan", "emby_customplaylist", "emby_playbackProps"
|
"emby_initialScan", "emby_customplaylist", "emby_playbackProps"
|
||||||
|
@ -120,6 +120,14 @@ class Service(object):
|
||||||
|
|
||||||
# If an item is playing
|
# If an item is playing
|
||||||
if self.kodi_player.isPlaying():
|
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()
|
self._report_progress()
|
||||||
|
|
||||||
elif not self.startup:
|
elif not self.startup:
|
||||||
|
@ -139,14 +147,6 @@ class Service(object):
|
||||||
# Wait until Emby server is online
|
# Wait until Emby server is online
|
||||||
# or Kodi is shut down.
|
# or Kodi is shut down.
|
||||||
self._server_online_check()
|
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):
|
if self.monitor.waitForAbort(1):
|
||||||
# Abort was requested while waiting. We should exit
|
# Abort was requested while waiting. We should exit
|
||||||
|
@ -297,8 +297,8 @@ class Service(object):
|
||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
|
|
||||||
ga = GoogleAnalytics()
|
#ga = GoogleAnalytics()
|
||||||
ga.sendEventData("Application", "Shutdown")
|
#ga.sendEventData("Application", "Shutdown")
|
||||||
|
|
||||||
if self.userclient_running:
|
if self.userclient_running:
|
||||||
self.userclient_thread.stop_client()
|
self.userclient_thread.stop_client()
|
||||||
|
|
Loading…
Reference in a new issue