From e9824158efc53cf18180e1f07d7eb0bb5bb8b98b Mon Sep 17 00:00:00 2001 From: croneter Date: Sat, 2 Nov 2019 17:14:46 +0100 Subject: [PATCH 1/4] Fix UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal --- addon.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addon.xml b/addon.xml index 3acec88d..cc188314 100644 --- a/addon.xml +++ b/addon.xml @@ -4,8 +4,8 @@ - - + + video audio image From ab77ddbe8bb2d2702cab9f5dc8562ee471eb1294 Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 3 Nov 2019 14:24:20 +0100 Subject: [PATCH 2/4] Fix resume for Kodi on low powered devices, e.g. Raspberry Pi --- resources/lib/playback.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/resources/lib/playback.py b/resources/lib/playback.py index 45903217..245e6eca 100644 --- a/resources/lib/playback.py +++ b/resources/lib/playback.py @@ -27,6 +27,7 @@ from . import app LOG = getLogger('PLEX.playback') # Do we need to return ultimately with a setResolvedUrl? RESOLVE = True +TRY_TO_SEEK_FOR = 300 # =30 seconds ############################################################################### @@ -586,7 +587,7 @@ def threaded_playback(kodi_playlist, startpos, offset): # PKC needs to quit return i += 1 - if i > 200: + if i > TRY_TO_SEEK_FOR: LOG.error('Could not seek to %s', offset) return i = 0 @@ -594,10 +595,12 @@ def threaded_playback(kodi_playlist, startpos, offset): while 'error' in answ: # Kodi sometimes returns {u'message': u'Failed to execute method.', # u'code': -32100} if user quickly switches videos - i += 1 - if i > 10: - LOG.error('Failed to seek to %s', offset) + if app.APP.monitor.waitForAbort(0.1): + # PKC needs to quit + return + i += 1 + if i > TRY_TO_SEEK_FOR: + LOG.error('Failed to seek to %s. Error: %s', offset, answ) return - app.APP.monitor.waitForAbort(0.1) answ = js.seek_to(offset * 1000) LOG.debug('Seek to offset %s successful', offset) From 4b46b11a598ed8cff234889194a1727c3b2d86ce Mon Sep 17 00:00:00 2001 From: croneter Date: Sun, 3 Nov 2019 14:28:40 +0100 Subject: [PATCH 3/4] Stable and beta version bump 2.10.1 --- README.md | 4 ++-- addon.xml | 9 +++++++-- changelog.txt | 5 +++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index eb839862..94677884 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![stable version](https://img.shields.io/badge/stable_version-2.10.0-blue.svg?maxAge=60&style=flat) ](https://github.com/croneter/binary_repo/raw/master/stable/repository.plexkodiconnect/repository.plexkodiconnect-1.0.2.zip) -[![beta version](https://img.shields.io/badge/beta_version-2.10.0-red.svg?maxAge=60&style=flat) ](https://github.com/croneter/binary_repo/raw/master/beta/repository.plexkodiconnectbeta/repository.plexkodiconnectbeta-1.0.2.zip) +[![stable version](https://img.shields.io/badge/stable_version-2.10.1-blue.svg?maxAge=60&style=flat) ](https://github.com/croneter/binary_repo/raw/master/stable/repository.plexkodiconnect/repository.plexkodiconnect-1.0.2.zip) +[![beta version](https://img.shields.io/badge/beta_version-2.10.1-red.svg?maxAge=60&style=flat) ](https://github.com/croneter/binary_repo/raw/master/beta/repository.plexkodiconnectbeta/repository.plexkodiconnectbeta-1.0.2.zip) [![Installation](https://img.shields.io/badge/wiki-installation-brightgreen.svg?maxAge=60&style=flat)](https://github.com/croneter/PlexKodiConnect/wiki/Installation) [![FAQ](https://img.shields.io/badge/wiki-FAQ-brightgreen.svg?maxAge=60&style=flat)](https://github.com/croneter/PlexKodiConnect/wiki/faq) diff --git a/addon.xml b/addon.xml index 24607d7d..78aa3060 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@ - + @@ -83,7 +83,12 @@ Natūralioji „Plex“ integracija į „Kodi“ Prijunkite „Kodi“ prie „Plex Medija Serverio“. Šiame papildinyje daroma prielaida, kad valdote visus savo vaizdo įrašus naudodami „Plex“ (ir nė vieno su „Kodi“). Galite prarasti jau saugomus „Kodi“ vaizdo įrašų ir muzikos duomenų bazių duomenis (kadangi šis papildinys juos tiesiogiai pakeičia). Naudokite savo pačių rizika! Naudokite savo pačių rizika - version 2.10.0: + version 2.10.1: +- Fix resume for Kodi on low powered devices, e.g. Raspberry Pi +- Fix resume when using an external player +- Fix UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal + +version 2.10.0: - version 2.9.12 - 2.9.14 for everyone - Get rid of some obsolete code for the ContextMonitor we dropped diff --git a/changelog.txt b/changelog.txt index 34b5542a..1b740134 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,8 @@ +version 2.10.1: +- Fix resume for Kodi on low powered devices, e.g. Raspberry Pi +- Fix resume when using an external player +- Fix UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal + version 2.10.0: - version 2.9.12 - 2.9.14 for everyone - Get rid of some obsolete code for the ContextMonitor we dropped From b6d6482c4a6809ebc4fec6e86b560880c88f7332 Mon Sep 17 00:00:00 2001 From: croneter Date: Sat, 2 Nov 2019 15:58:22 +0100 Subject: [PATCH 4/4] Fix resume when using an external player --- resources/lib/app/playstate.py | 3 ++- resources/lib/kodimonitor.py | 46 ++++++++++++++++++++++++++-------- 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/resources/lib/app/playstate.py b/resources/lib/app/playstate.py index 688ee401..13d61ac3 100644 --- a/resources/lib/app/playstate.py +++ b/resources/lib/app/playstate.py @@ -35,7 +35,8 @@ class PlayState(object): 'volume': 100, 'muted': False, 'playmethod': None, - 'playcount': None + 'playcount': None, + 'external_player': False # bool - xbmc.Player().isExternalPlayer() } def __init__(self): diff --git a/resources/lib/kodimonitor.py b/resources/lib/kodimonitor.py index 8e722580..ba41cc4d 100644 --- a/resources/lib/kodimonitor.py +++ b/resources/lib/kodimonitor.py @@ -349,6 +349,11 @@ class KodiMonitor(xbmc.Monitor): status['plex_type'] = plex_type status['playmethod'] = item.playmethod status['playcount'] = item.playcount + try: + status['external_player'] = app.APP.player.isExternalPlayer() == 1 + except AttributeError: + # Kodi version < 17 + pass LOG.debug('Set the player state: %s', status) if not app.SYNC.direct_paths: _notify_upnext(item) @@ -403,17 +408,22 @@ def _record_playstate(status, ended): LOG.debug('No playstate update due to Plex id not found: %s', status) return totaltime = float(timing.kodi_time_to_millis(status['totaltime'])) / 1000 - if ended: - progress = 0.99 - time = v.IGNORE_SECONDS_AT_START + 1 + if status['external_player']: + _external_player_correct_plex_watch_count(db_item) + progress = 0.0 + time = 0.0 else: - time = float(timing.kodi_time_to_millis(status['time'])) / 1000 - try: - progress = time / totaltime - except ZeroDivisionError: - progress = 0.0 - LOG.debug('Playback progress %s (%s of %s seconds)', - progress, time, totaltime) + if ended: + progress = 0.99 + time = v.IGNORE_SECONDS_AT_START + 1 + else: + time = float(timing.kodi_time_to_millis(status['time'])) / 1000 + try: + progress = time / totaltime + except ZeroDivisionError: + progress = 0.0 + LOG.debug('Playback progress %s (%s of %s seconds)', + progress, time, totaltime) playcount = status['playcount'] last_played = timing.kodi_now() if playcount is None: @@ -455,6 +465,22 @@ def _record_playstate(status, ended): backgroundthread.BGThreader.addTasksToFront([task]) +def _external_player_correct_plex_watch_count(db_item): + """ + Kodi won't safe playstate at all for external players + + There's currently no way to get a resumpoint if an external player is + in use We are just checking whether we should mark video as + completely watched or completely unwatched (according to + playcountminimumtime set in playercorefactory.xml) + See https://kodi.wiki/view/External_players + """ + with kodi_db.KodiVideoDB() as kodidb: + playcount = kodidb.get_playcount(db_item['kodi_fileid']) + LOG.debug('External player detected. Playcount: %s', playcount) + PF.scrobble(db_item['plex_id'], 'watched' if playcount else 'unwatched') + + def _clean_file_table(): """ If we associate a playing video e.g. pointing to plugin://... to an existing