From 22a0cfc6f0060cf37d20f540d66447d477d0efb0 Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Sun, 13 Mar 2016 13:59:24 +0100 Subject: [PATCH 1/7] Increase download timeout to 30s Should take care of missing PMS replies if we request all elements of a certain large library --- resources/lib/downloadutils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/lib/downloadutils.py b/resources/lib/downloadutils.py index 4b75b252..d7e1b387 100644 --- a/resources/lib/downloadutils.py +++ b/resources/lib/downloadutils.py @@ -37,7 +37,7 @@ class DownloadUtils(): # Requests session s = None - timeout = 10 + timeout = 30 def __init__(self): From 9b99028fb194fa50a64f6ecc4a87c4ec8ef1fc2b Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Sun, 13 Mar 2016 14:06:42 +0100 Subject: [PATCH 2/7] Update node names to reflect plex In progress -> On Deck --- resources/language/English/strings.xml | 6 +++--- resources/language/German/strings.xml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml index 283c52bf..f7a65d32 100644 --- a/resources/language/English/strings.xml +++ b/resources/language/English/strings.xml @@ -145,14 +145,14 @@ Recently Added TV Shows - In Progress TV Shows + On Deck TV Shows All Music Channels Recently Added Movies Recently Added Episodes Recently Added Albums - In Progress Movies - In Progress Episodes + On Deck Movies + On Deck Episodes Next Episodes Favorite Movies Favorite Shows diff --git a/resources/language/German/strings.xml b/resources/language/German/strings.xml index e8d7aca7..5025cf0c 100644 --- a/resources/language/German/strings.xml +++ b/resources/language/German/strings.xml @@ -173,14 +173,14 @@ Addresse : Zuletzt hinzugefügte Serien - Begonnene Serien + Aktuell Serien Alles an Musik Kanäle Zuletzt hinzugefügte Filme Zuletzt hinzugefügte Episoden Zuletzt hinzugefügte Alben - Begonnene Filme - Begonnene Episoden + Aktuelle Filme + Aktuelle Episoden Nächste Episoden Favorisierte Filme Favorisierte Serien From 53c07d4b506756fe3fe8bbe4e2eb6e3b41bad1bf Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Sun, 13 Mar 2016 14:50:29 +0100 Subject: [PATCH 3/7] Fix Recently Added Plex time was not converted to Kodi time --- resources/lib/PlexAPI.py | 2 +- resources/lib/utils.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/resources/lib/PlexAPI.py b/resources/lib/PlexAPI.py index b65e9e4d..00567cfa 100644 --- a/resources/lib/PlexAPI.py +++ b/resources/lib/PlexAPI.py @@ -1513,7 +1513,7 @@ class API(): """ Returns the date when this library item was created """ - return utils.DateToKodi(self.item.attrib.get('addedAt', None)) + return utils.DateToKodi(self.item.attrib.get('addedAt')) def getUserData(self): """ diff --git a/resources/lib/utils.py b/resources/lib/utils.py index 53ac5c38..343efd05 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -7,7 +7,8 @@ import inspect import json import pstats import sqlite3 -from datetime import datetime, time, timedelta +from datetime import datetime, timedelta +import time import unicodedata import xml.etree.ElementTree as etree from functools import wraps @@ -545,7 +546,7 @@ def startProfiling(): return pr def stopProfiling(pr, profileName): - + from datetime import time pr.disable() ps = pstats.Stats(pr) From d300cc60d6b300f787b4cbafcb542d28b4f91853 Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Sun, 13 Mar 2016 16:06:54 +0100 Subject: [PATCH 4/7] Fix tv show season posters not showing --- resources/lib/PlexAPI.py | 67 +++++++++--------------------------- resources/lib/itemtypes.py | 18 ++++++++-- resources/lib/librarysync.py | 10 +++++- 3 files changed, 41 insertions(+), 54 deletions(-) diff --git a/resources/lib/PlexAPI.py b/resources/lib/PlexAPI.py index 00567cfa..71a5bc67 100644 --- a/resources/lib/PlexAPI.py +++ b/resources/lib/PlexAPI.py @@ -2044,15 +2044,15 @@ class API(): """ item = self.item.attrib - maxHeight = 10000 - maxWidth = 10000 - customquery = "" + # maxHeight = 10000 + # maxWidth = 10000 + # customquery = "" - if utils.settings('compressArt') == "true": - customquery = "&Quality=90" + # if utils.settings('compressArt') == "true": + # customquery = "&Quality=90" - if utils.settings('enableCoverArt') == "false": - customquery += "&EnableImageEnhancers=false" + # if utils.settings('enableCoverArt') == "false": + # customquery += "&EnableImageEnhancers=false" allartworks = { 'Primary': "", @@ -2083,54 +2083,21 @@ class API(): # Process parent items if the main item is missing artwork if parentInfo: - # Process parent backdrops if not allartworks['Backdrop']: - - parentId = item.get('ParentBackdropItemId') - if parentId: - # If there is a parentId, go through the parent backdrop list - parentbackdrops = item['ParentBackdropImageTags'] + background = item.get('parentArt') + if background: + background = "%s%s" % (self.server, background) + background = self.addPlexCredentialsToUrl(background) + allartworks['Backdrop'].append(background) - backdropIndex = 0 - for parentbackdroptag in parentbackdrops: - artwork = ( - "%s/emby/Items/%s/Images/Backdrop/%s?" - "MaxWidth=%s&MaxHeight=%s&Format=original&Tag=%s%s" - % (self.server, parentId, backdropIndex, - maxWidth, maxHeight, parentbackdroptag, customquery)) - allartworks['Backdrop'].append(artwork) - backdropIndex += 1 - - # Process the rest of the artwork - parentartwork = ['Logo', 'Art', 'Thumb'] - for parentart in parentartwork: - - if not allartworks[parentart]: - - parentId = item.get('Parent%sItemId' % parentart) - if parentId: - - parentTag = item['Parent%sImageTag' % parentart] - artwork = ( - "%s/emby/Items/%s/Images/%s/0?" - "MaxWidth=%s&MaxHeight=%s&Format=original&Tag=%s%s" - % (self.server, parentId, parentart, - maxWidth, maxHeight, parentTag, customquery)) - allartworks[parentart] = artwork - - # Parent album works a bit differently if not allartworks['Primary']: + primary = item['parentThumb'] + if primary: + primary = "%s%s" % (self.server, primary) + primary = self.addPlexCredentialsToUrl(primary) + allartworks['Primary'] = primary - parentId = item.get('AlbumId') - if parentId and item.get('AlbumPrimaryImageTag'): - - parentTag = item['AlbumPrimaryImageTag'] - artwork = ( - "%s/emby/Items/%s/Images/Primary/0?" - "MaxWidth=%s&MaxHeight=%s&Format=original&Tag=%s%s" - % (self.server, parentId, maxWidth, maxHeight, parentTag, customquery)) - allartworks['Primary'] = artwork return allartworks def getTranscodeVideoPath(self, action, quality={}): diff --git a/resources/lib/itemtypes.py b/resources/lib/itemtypes.py index e674b28e..7cc65bed 100644 --- a/resources/lib/itemtypes.py +++ b/resources/lib/itemtypes.py @@ -1141,9 +1141,8 @@ class TVShows(Items): # skip this item for now return - def run_add_updateSeason(self, item, viewid=None, viewtag=None): + def run_add_updateSeason(self, item, viewtag=None, viewid=None): API = PlexAPI.API(item) - showid = viewid itemid = API.getRatingKey() if not itemid: self.logMsg('Error getting itemid for season, skipping', -1) @@ -1153,6 +1152,18 @@ class TVShows(Items): kodi_db = self.kodi_db artwork = self.artwork seasonnum = API.getIndex() + # Get parent tv show Plex id + plexshowid = item.attrib.get('parentRatingKey') + # Get Kodi showid + emby_dbitem = emby_db.getItem_byId(plexshowid) + try: + showid = emby_dbitem[0] + except: + self.logMsg('Could not find parent tv show for season %s. ' + 'Skipping season for now.' + % (itemid), -1) + return + seasonid = kodi_db.addSeason(showid, seasonnum) checksum = API.getChecksum() # Check whether Season already exists @@ -1165,6 +1176,7 @@ class TVShows(Items): # Process artwork allartworks = API.getAllArtwork() + self.logMsg('TV id: %s, Seasonid: %s' % (viewid, seasonid), 1) artwork.addArtwork(allartworks, seasonid, "season", kodicursor) if update_item: @@ -1172,7 +1184,7 @@ class TVShows(Items): emby_db.updateReference(itemid, checksum) else: # Create the reference in emby table - emby_db.addReference(itemid, seasonid, "Season", "season", parentid=showid, checksum=checksum) + emby_db.addReference(itemid, seasonid, "Season", "season", parentid=viewid, checksum=checksum) def add_updateEpisode(self, item, viewtag=None, viewid=None): try: diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index 9394fe8e..5e030133 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -1218,6 +1218,10 @@ class LibrarySync(Thread): # COPY for later use allPlexTvShowsId = self.allPlexElementsId.copy() + # Process self.updatelist + self.GetAndProcessXMLs(itemType) + self.logMsg("GetAndProcessXMLs completed for tv shows", 1) + # PROCESS TV Seasons ##### # Cycle through tv shows for tvShowId in allPlexTvShowsId: @@ -1238,6 +1242,10 @@ class LibrarySync(Thread): self.logMsg("Analyzed all seasons of TV show with Plex Id %s" % tvShowId, 1) + # Process self.updatelist + self.GetAndProcessXMLs(itemType) + self.logMsg("GetAndProcessXMLs completed for seasons", 1) + # PROCESS TV Episodes ##### # Cycle through tv shows for view in views: @@ -1261,7 +1269,7 @@ class LibrarySync(Thread): # Process self.updatelist self.GetAndProcessXMLs(itemType) - self.logMsg("GetAndProcessXMLs completed", 1) + self.logMsg("GetAndProcessXMLs completed for episodes", 1) # Refresh season info # Cycle through tv shows with itemtypes.TVShows() as TVshow: From b79705719d126e1ae819705953342ae6daa7139e Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Sun, 13 Mar 2016 16:12:25 +0100 Subject: [PATCH 5/7] Increase image caching timeouts to 5s --- resources/lib/image_cache_thread.py | 2 +- resources/lib/itemtypes.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/lib/image_cache_thread.py b/resources/lib/image_cache_thread.py index 2f6aacbf..69003b69 100644 --- a/resources/lib/image_cache_thread.py +++ b/resources/lib/image_cache_thread.py @@ -40,7 +40,7 @@ class image_cache_thread(threading.Thread): "http://%s:%s/image/image://%s" % (self.xbmc_host, self.xbmc_port, self.urlToProcess)), auth=(self.xbmc_username, self.xbmc_password), - timeout=(2, 2)) + timeout=(5, 5)) # We don't need the result except: pass diff --git a/resources/lib/itemtypes.py b/resources/lib/itemtypes.py index 7cc65bed..458b072b 100644 --- a/resources/lib/itemtypes.py +++ b/resources/lib/itemtypes.py @@ -1176,7 +1176,6 @@ class TVShows(Items): # Process artwork allartworks = API.getAllArtwork() - self.logMsg('TV id: %s, Seasonid: %s' % (viewid, seasonid), 1) artwork.addArtwork(allartworks, seasonid, "season", kodicursor) if update_item: From a2aac17fc409d0fe66eac5a3e3a2928a306c789b Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Sun, 13 Mar 2016 16:20:13 +0100 Subject: [PATCH 6/7] Fix TV shows episode artwork not caching --- resources/lib/itemtypes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/lib/itemtypes.py b/resources/lib/itemtypes.py index 458b072b..77ce3015 100644 --- a/resources/lib/itemtypes.py +++ b/resources/lib/itemtypes.py @@ -1445,8 +1445,8 @@ class TVShows(Items): people = API.getPeopleList() kodi_db.addPeople(episodeid, people, "episode") # Process artwork - artworks = API.getAllArtwork() - artwork.addOrUpdateArt(artworks['Primary'], episodeid, "episode", "thumb", kodicursor) + allartworks = API.getAllArtwork() + artwork.addArtwork(allartworks, episodeid, "episode", kodicursor) # Process stream details streams = API.getMediaStreams() kodi_db.addStreams(fileid, streams, runtime) From 94e3da09f3d1753c974296b1f9d83e923f26295c Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Sun, 13 Mar 2016 16:22:17 +0100 Subject: [PATCH 7/7] Version bump --- addon.xml | 2 +- changelog.txt | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/addon.xml b/addon.xml index 84e2d72d..eaa8153d 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ diff --git a/changelog.txt b/changelog.txt index 7f407da9..69ddd90c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,11 @@ +version 1.0.9 +- Fix Recently Added +- Update node names to reflect plex +- Fix tv show season posters not showing +- Fix TV shows episode artwork not caching +- Increase download timeout to 30s +- Increase image caching timeouts to 5s + version 1.0.8 - Redesigned fast incremential sync - Workaround to sync Kodi time with PMS time