From e8f1382916100e87ecc2247f22a6ae6fd014042e Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Tue, 1 Mar 2016 16:18:12 +0100 Subject: [PATCH] Add PMS collection tags to movies --- resources/lib/PlexAPI.py | 22 ++++++++++++++-------- resources/lib/PlexFunctions.py | 2 +- resources/lib/itemtypes.py | 15 ++++++++------- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/resources/lib/PlexAPI.py b/resources/lib/PlexAPI.py index 34781e58..04face0a 100644 --- a/resources/lib/PlexAPI.py +++ b/resources/lib/PlexAPI.py @@ -1519,6 +1519,16 @@ class API(): 'UserRating': userrating } + def getCollections(self): + """ + Returns a list of PMS collection tags + """ + collections = [] + for child in self.item: + if child.tag == 'Collection': + collections.append(child.attrib['tag']) + return collections + def getPeople(self): """ Returns a dict of lists of people found. @@ -1574,14 +1584,10 @@ class API(): name_id = child.attrib['id'] Type = child.tag Type = people_of_interest[Type] - try: - url = child.attrib['thumb'] - except KeyError: - url = None - try: - Role = child.attrib['role'] - except KeyError: - Role = None + + url = child.attrib.get('thumb') + Role = child.attrib.get('role') + people.append({ 'Name': name, 'Type': Type, diff --git a/resources/lib/PlexFunctions.py b/resources/lib/PlexFunctions.py index 4ae4e25d..c371ac2c 100644 --- a/resources/lib/PlexFunctions.py +++ b/resources/lib/PlexFunctions.py @@ -31,7 +31,7 @@ def ConvertPlexToKodiTime(plexTime): def GetItemClassFromType(itemType): classes = { 'movie': 'Movies', - 'episodes': 'TVShows', + 'season': 'TVShows', 'episode': 'TVShows', 'show': 'TVShows', 'artist': 'Music', diff --git a/resources/lib/itemtypes.py b/resources/lib/itemtypes.py index d6cd7162..243b88f0 100644 --- a/resources/lib/itemtypes.py +++ b/resources/lib/itemtypes.py @@ -325,9 +325,9 @@ class Movies(Items): update_item = False self.logMsg("movieid: %s missing from Kodi, repairing the entry." % movieid, 1) - if not viewtag or not viewid: - # Get view tag from emby - viewtag, viewid, mediatype = self.emby.getView_embyId(itemid) + # if not viewtag or not viewid: + # # Get view tag from emby + # viewtag, viewid, mediatype = self.emby.getView_embyId(itemid) # fileId information checksum = API.getChecksum() @@ -349,6 +349,7 @@ class Movies(Items): shortplot = None tagline = API.getTagline() votecount = None + collections = API.getCollections() rating = API.getAudienceRating() year = API.getYear() @@ -491,11 +492,11 @@ class Movies(Items): kodi_db.addStreams(fileid, streams, runtime) # Process studios kodi_db.addStudios(movieid, studios, "movie") - # Process tags: view, emby tags + # Process tags: view, Plex collection tags tags = [viewtag] - # tags.extend(item['Tags']) - # if userdata['Favorite']: - # tags.append("Favorite movies") + tags.extend(collections) + if userdata['Favorite']: + tags.append("Favorite movies") kodi_db.addTags(movieid, tags, "movie") # Process playstates kodi_db.addPlaystate(fileid, resume, runtime, playcount, dateplayed)