From d3840ed27b64bfd524309a05e9d7a1c3868dde48 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Mon, 11 Jun 2018 23:06:30 -0500 Subject: [PATCH] Ping server session every 4min30 To keep the session alive under active player --- resources/lib/service_entry.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/resources/lib/service_entry.py b/resources/lib/service_entry.py index f8ae83a0..2f97f85f 100644 --- a/resources/lib/service_entry.py +++ b/resources/lib/service_entry.py @@ -46,7 +46,6 @@ class Service(object): library_thread = None last_progress = datetime.today() - lastMetricPing = time.time() def __init__(self): @@ -129,6 +128,9 @@ class Service(object): # Verify if user is set and has access to the server if user_client.get_user() is not None and user_client.get_access(): + if self.kodi_player.isPlaying(): + self._report_progress() + # If an item is playing if not self.startup: self.startup = self._startup() @@ -278,7 +280,6 @@ class Service(object): # Abort was requested while waiting. We should exit break - """ def _report_progress(self): # Update and report playback progress kodi_player = self.kodi_player @@ -292,27 +293,16 @@ class Service(object): difference = datetime.today() - self.last_progress difference_seconds = difference.seconds - # Report progress to Emby server - if difference_seconds > 9: - kodi_player.reportPlayback() - self.last_progress = datetime.today() - - elif window('emby_command') == "true": - # Received a remote control command that - # requires updating immediately - window('emby_command', clear=True) + # Ping session every 4-5 minutes + if difference_seconds > 270: kodi_player.reportPlayback() self.last_progress = datetime.today() except Exception as error: log.exception(error) - """ def shutdown(self): - #ga = GoogleAnalytics() - #ga.sendEventData("Application", "Shutdown") - if self.monitor.special_monitor: self.monitor.special_monitor.stop_monitor()