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..bebb1dc6 100644 --- a/addon.xml +++ b/addon.xml @@ -1,11 +1,11 @@ - + - - + + video audio image @@ -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 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 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)