From 643899ce494a81b5bf31066b40aa8eb72607b5a2 Mon Sep 17 00:00:00 2001 From: RickDB Date: Mon, 17 Jul 2017 12:30:12 +0200 Subject: [PATCH 1/8] Updated playcount check in KodiMonitor, if playcount was empty / null it would incorrectly mark it as watched. While updating play state make sure offset never exceeds item duration. --- resources/lib/itemtypes.py | 6 ++++++ resources/lib/kodimonitor.py | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/resources/lib/itemtypes.py b/resources/lib/itemtypes.py index 4cfa311a..f244844b 100644 --- a/resources/lib/itemtypes.py +++ b/resources/lib/itemtypes.py @@ -158,6 +158,12 @@ class Items(object): # If the playback was stopped, check whether we need to increment the # playcount. PMS won't tell us the playcount via websockets if item['state'] in ('stopped', 'ended'): + + # If offset exceeds duration skip update + if item['viewOffset'] > item['duration']: + log.error("Error while updating play state, viewOffset exceeded duration") + return + complete = float(item['viewOffset']) / float(item['duration']) log.info('Item %s stopped with completion rate %s percent.' 'Mark item played at %s percent.' diff --git a/resources/lib/kodimonitor.py b/resources/lib/kodimonitor.py index 579c9033..fde49a13 100644 --- a/resources/lib/kodimonitor.py +++ b/resources/lib/kodimonitor.py @@ -92,6 +92,7 @@ class KodiMonitor(Monitor): # Manually marking as watched/unwatched playcount = data.get('playcount') item = data.get('item') + try: kodiid = item['id'] item_type = item['type'] @@ -114,7 +115,7 @@ class KodiMonitor(Monitor): window('plex_skipWatched%s' % itemid, clear=True) else: # notify the server - if playcount != 0: + if playcount > 0: scrobble(itemid, 'watched') else: scrobble(itemid, 'unwatched') From 3cb4b538876cc2a30a55d6e9d8fd2acad0d6d16d Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Wed, 2 Aug 2017 18:26:48 +0200 Subject: [PATCH 2/8] Add Kodi info screen for episodes in context menu --- 8356 | 0 FETCH_HEAD | 0 develop | 0 resources/language/resource.language.en_gb/strings.po | 5 +++++ resources/lib/PlexAPI.py | 2 ++ resources/lib/entrypoint.py | 1 + script-plex-connect-server.xml} | 0 7 files changed, 8 insertions(+) create mode 100644 8356 create mode 100644 FETCH_HEAD create mode 100644 develop create mode 100644 script-plex-connect-server.xml} diff --git a/8356 b/8356 new file mode 100644 index 00000000..e69de29b diff --git a/FETCH_HEAD b/FETCH_HEAD new file mode 100644 index 00000000..e69de29b diff --git a/develop b/develop new file mode 100644 index 00000000..e69de29b diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index 6a5d051c..a2297406 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -83,6 +83,11 @@ msgctxt "#30017" msgid "Unauthorized for PMS" msgstr "" +# Kodi context menu entry for movie and episode information screen +msgctxt "#30018" +msgid "Information" +msgstr "" + msgctxt "#30022" msgid "Advanced" msgstr "" diff --git a/resources/lib/PlexAPI.py b/resources/lib/PlexAPI.py index 6f1c1661..6b8773cd 100644 --- a/resources/lib/PlexAPI.py +++ b/resources/lib/PlexAPI.py @@ -2534,6 +2534,8 @@ class API(): # Expensive operation metadata['title'] = title listItem.setInfo('video', infoLabels=metadata) + # Add context menu entry for information screen + listItem.addContextMenuItems([(lang(30018), 'XBMC.Action(Info)',)]) return listItem def add_video_streams(self, listItem): diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py index eaf360fb..a72d3a9c 100644 --- a/resources/lib/entrypoint.py +++ b/resources/lib/entrypoint.py @@ -255,6 +255,7 @@ def createListItem(item, appendShowTitle=False, appendSxxExx=False): li.setArt({'icon': 'DefaultTVShows.png'}) li.setProperty('dbid', str(item['episodeid'])) li.setProperty('fanart_image', item['art'].get('tvshow.fanart','')) + li.addContextMenuItems([(lang(30018), 'XBMC.Action(Info)',)]) for key, value in item['streamdetails'].iteritems(): for stream in value: li.addStreamInfo(key, stream) diff --git a/script-plex-connect-server.xml} b/script-plex-connect-server.xml} new file mode 100644 index 00000000..e69de29b From 18b2781210e8ad74e86fc2a281bbe3f87d2e62d0 Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Wed, 2 Aug 2017 18:30:29 +0200 Subject: [PATCH 3/8] Revert "Add Kodi info screen for episodes in context menu" This reverts commit 3cb4b538876cc2a30a55d6e9d8fd2acad0d6d16d. --- 8356 | 0 FETCH_HEAD | 0 develop | 0 resources/language/resource.language.en_gb/strings.po | 5 ----- resources/lib/PlexAPI.py | 2 -- resources/lib/entrypoint.py | 1 - script-plex-connect-server.xml} | 0 7 files changed, 8 deletions(-) delete mode 100644 8356 delete mode 100644 FETCH_HEAD delete mode 100644 develop delete mode 100644 script-plex-connect-server.xml} diff --git a/8356 b/8356 deleted file mode 100644 index e69de29b..00000000 diff --git a/FETCH_HEAD b/FETCH_HEAD deleted file mode 100644 index e69de29b..00000000 diff --git a/develop b/develop deleted file mode 100644 index e69de29b..00000000 diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index a2297406..6a5d051c 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -83,11 +83,6 @@ msgctxt "#30017" msgid "Unauthorized for PMS" msgstr "" -# Kodi context menu entry for movie and episode information screen -msgctxt "#30018" -msgid "Information" -msgstr "" - msgctxt "#30022" msgid "Advanced" msgstr "" diff --git a/resources/lib/PlexAPI.py b/resources/lib/PlexAPI.py index 6b8773cd..6f1c1661 100644 --- a/resources/lib/PlexAPI.py +++ b/resources/lib/PlexAPI.py @@ -2534,8 +2534,6 @@ class API(): # Expensive operation metadata['title'] = title listItem.setInfo('video', infoLabels=metadata) - # Add context menu entry for information screen - listItem.addContextMenuItems([(lang(30018), 'XBMC.Action(Info)',)]) return listItem def add_video_streams(self, listItem): diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py index a72d3a9c..eaf360fb 100644 --- a/resources/lib/entrypoint.py +++ b/resources/lib/entrypoint.py @@ -255,7 +255,6 @@ def createListItem(item, appendShowTitle=False, appendSxxExx=False): li.setArt({'icon': 'DefaultTVShows.png'}) li.setProperty('dbid', str(item['episodeid'])) li.setProperty('fanart_image', item['art'].get('tvshow.fanart','')) - li.addContextMenuItems([(lang(30018), 'XBMC.Action(Info)',)]) for key, value in item['streamdetails'].iteritems(): for stream in value: li.addStreamInfo(key, stream) diff --git a/script-plex-connect-server.xml} b/script-plex-connect-server.xml} deleted file mode 100644 index e69de29b..00000000 From 26f0c6e55652fa12cc1ad350fcb1a2f8450532df Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Wed, 2 Aug 2017 18:31:52 +0200 Subject: [PATCH 4/8] Add Kodi info screen for episodes in context menu --- resources/language/resource.language.en_gb/strings.po | 5 +++++ resources/lib/PlexAPI.py | 2 ++ resources/lib/entrypoint.py | 1 + 3 files changed, 8 insertions(+) diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index 6a5d051c..a2297406 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -83,6 +83,11 @@ msgctxt "#30017" msgid "Unauthorized for PMS" msgstr "" +# Kodi context menu entry for movie and episode information screen +msgctxt "#30018" +msgid "Information" +msgstr "" + msgctxt "#30022" msgid "Advanced" msgstr "" diff --git a/resources/lib/PlexAPI.py b/resources/lib/PlexAPI.py index 6f1c1661..6b8773cd 100644 --- a/resources/lib/PlexAPI.py +++ b/resources/lib/PlexAPI.py @@ -2534,6 +2534,8 @@ class API(): # Expensive operation metadata['title'] = title listItem.setInfo('video', infoLabels=metadata) + # Add context menu entry for information screen + listItem.addContextMenuItems([(lang(30018), 'XBMC.Action(Info)',)]) return listItem def add_video_streams(self, listItem): diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py index eaf360fb..a72d3a9c 100644 --- a/resources/lib/entrypoint.py +++ b/resources/lib/entrypoint.py @@ -255,6 +255,7 @@ def createListItem(item, appendShowTitle=False, appendSxxExx=False): li.setArt({'icon': 'DefaultTVShows.png'}) li.setProperty('dbid', str(item['episodeid'])) li.setProperty('fanart_image', item['art'].get('tvshow.fanart','')) + li.addContextMenuItems([(lang(30018), 'XBMC.Action(Info)',)]) for key, value in item['streamdetails'].iteritems(): for stream in value: li.addStreamInfo(key, stream) From 64fe06400833cdf54d7743d47a32e294f3a4dc1a Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Wed, 2 Aug 2017 18:54:05 +0200 Subject: [PATCH 5/8] Fix Kodi TypeError with ListItems --- resources/lib/PlexAPI.py | 8 ++++++-- resources/lib/entrypoint.py | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/resources/lib/PlexAPI.py b/resources/lib/PlexAPI.py index 6b8773cd..930c2e1c 100644 --- a/resources/lib/PlexAPI.py +++ b/resources/lib/PlexAPI.py @@ -2534,8 +2534,12 @@ class API(): # Expensive operation metadata['title'] = title listItem.setInfo('video', infoLabels=metadata) - # Add context menu entry for information screen - listItem.addContextMenuItems([(lang(30018), 'XBMC.Action(Info)',)]) + try: + # Add context menu entry for information screen + listItem.addContextMenuItems([(lang(30018), 'XBMC.Action(Info)',)]) + except TypeError: + # Kodi fuck-up + pass return listItem def add_video_streams(self, listItem): diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py index a72d3a9c..2c83ba1d 100644 --- a/resources/lib/entrypoint.py +++ b/resources/lib/entrypoint.py @@ -255,7 +255,11 @@ def createListItem(item, appendShowTitle=False, appendSxxExx=False): li.setArt({'icon': 'DefaultTVShows.png'}) li.setProperty('dbid', str(item['episodeid'])) li.setProperty('fanart_image', item['art'].get('tvshow.fanart','')) - li.addContextMenuItems([(lang(30018), 'XBMC.Action(Info)',)]) + try: + li.addContextMenuItems([(lang(30018), 'XBMC.Action(Info)',)]) + except TypeError: + # Kodi fuck-up + pass for key, value in item['streamdetails'].iteritems(): for stream in value: li.addStreamInfo(key, stream) From c3a6bd99b677459474b85d999cb443a656b8d53a Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Wed, 2 Aug 2017 19:07:29 +0200 Subject: [PATCH 6/8] Fix PKC asking for trailers not working - Fixes #328 --- resources/lib/playbackutils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/lib/playbackutils.py b/resources/lib/playbackutils.py index 1ca853d4..388b0dc5 100644 --- a/resources/lib/playbackutils.py +++ b/resources/lib/playbackutils.py @@ -129,6 +129,7 @@ class PlaybackUtils(): trailers = xbmcgui.Dialog().yesno( lang(29999), "Play trailers?") + trailers = True if trailers else False else: trailers = True # Post to the PMS. REUSE THE PLAYQUEUE! From 61ea145d496ea893a7410e6c7079601ab0c3aadb Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Wed, 2 Aug 2017 19:57:53 +0200 Subject: [PATCH 7/8] Update addon.xml --- addon.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon.xml b/addon.xml index 105a8729..04d6d22e 100644 --- a/addon.xml +++ b/addon.xml @@ -1,5 +1,5 @@ - + From e5d4e44951a850301dc4d11224d9867d6a1fd298 Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Wed, 2 Aug 2017 20:01:13 +0200 Subject: [PATCH 8/8] Change string ID --- resources/language/resource.language.en_gb/strings.po | 10 +++++----- resources/lib/PlexAPI.py | 2 +- resources/lib/entrypoint.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index a2297406..018cfd44 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -83,11 +83,6 @@ msgctxt "#30017" msgid "Unauthorized for PMS" msgstr "" -# Kodi context menu entry for movie and episode information screen -msgctxt "#30018" -msgid "Information" -msgstr "" - msgctxt "#30022" msgid "Advanced" msgstr "" @@ -108,6 +103,11 @@ msgctxt "#30031" msgid "I own this Plex Media Server" msgstr "" +# Kodi context menu entry for movie and episode information screen +msgctxt "#30032" +msgid "Information" +msgstr "" + msgctxt "#30035" msgid "Number of recent Music Albums to show:" msgstr "" diff --git a/resources/lib/PlexAPI.py b/resources/lib/PlexAPI.py index 930c2e1c..65db0967 100644 --- a/resources/lib/PlexAPI.py +++ b/resources/lib/PlexAPI.py @@ -2536,7 +2536,7 @@ class API(): listItem.setInfo('video', infoLabels=metadata) try: # Add context menu entry for information screen - listItem.addContextMenuItems([(lang(30018), 'XBMC.Action(Info)',)]) + listItem.addContextMenuItems([(lang(30032), 'XBMC.Action(Info)',)]) except TypeError: # Kodi fuck-up pass diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py index 2c83ba1d..5dfc93d2 100644 --- a/resources/lib/entrypoint.py +++ b/resources/lib/entrypoint.py @@ -256,7 +256,7 @@ def createListItem(item, appendShowTitle=False, appendSxxExx=False): li.setProperty('dbid', str(item['episodeid'])) li.setProperty('fanart_image', item['art'].get('tvshow.fanart','')) try: - li.addContextMenuItems([(lang(30018), 'XBMC.Action(Info)',)]) + li.addContextMenuItems([(lang(30032), 'XBMC.Action(Info)',)]) except TypeError: # Kodi fuck-up pass