From 0d96f6bf4f9c118d09374632d430a870215dd2ad Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Wed, 27 Apr 2016 10:37:24 +0200 Subject: [PATCH] New setting: Show+SxxExx to Recently Added - Fixes #12 --- resources/language/English/strings.xml | 4 ++- resources/language/German/strings.xml | 4 ++- resources/lib/PlexAPI.py | 16 ++++++--- resources/lib/entrypoint.py | 47 ++++++++++++++------------ resources/settings.xml | 4 ++- 5 files changed, 47 insertions(+), 28 deletions(-) diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml index 348a9994..08f0d98d 100644 --- a/resources/language/English/strings.xml +++ b/resources/language/English/strings.xml @@ -391,7 +391,7 @@ Appearance Tweaks TV Shows On Deck: Append show title to episode - On Deck: Append season- and episode-number (e.g. S3E2) + On Deck: Append season- and episode-number SxxExx Nothing works? Try a full reset! [COLOR yellow]Choose Plex Server from a list[/COLOR] Wait before sync new/changed PMS item [s] @@ -402,6 +402,8 @@ Used by Sync and when attempting to Direct Play Customize Paths Extend Plex TV Series "On Deck" view to all shows + Recently Added: Append show title to episode + Recently Added: Append season- and episode-number SxxExx Log-out Plex Home User diff --git a/resources/language/German/strings.xml b/resources/language/German/strings.xml index a9ebfb47..4283d477 100644 --- a/resources/language/German/strings.xml +++ b/resources/language/German/strings.xml @@ -329,7 +329,7 @@ Erscheinung TV Serien "Aktuell": Serien- an Episoden-Titel anfügen - "Aktuell": Staffel und Episode anfügen (z.B. S3E2) + "Aktuell": Staffel und Episode anfügen, SxxExx Nichts funktioniert? Setze mal alles zurück! [COLOR yellow]Plex Server aus Liste auswählen[/COLOR] Warten bevor neue/geänderte PMS Einträge gesynct werden [s] @@ -340,6 +340,8 @@ Verwendet für Synchronisierung sowie beim Versuch, Direct Play zu nutzen Pfade ändern Standard Plex Ansicht "Aktuell" auf alle TV Shows erweitern + "Zuletzt hinzugefügt": Serien- an Episoden-Titel anfügen + "Zuletzt hinzugefügt": Staffel und Episode anfügen, SxxExx diff --git a/resources/lib/PlexAPI.py b/resources/lib/PlexAPI.py index c306f7f4..8466ba29 100644 --- a/resources/lib/PlexAPI.py +++ b/resources/lib/PlexAPI.py @@ -2122,12 +2122,15 @@ class API(): self.logMsg('Found external subs: %s' % externalsubs) return externalsubs - def CreateListItemFromPlexItem(self, listItem=None): + def CreateListItemFromPlexItem(self, listItem=None, + appendShowTitle=False, appendSxxExx=False): """ Call on a child level of PMS xml response (e.g. in a for loop) - listItem: existing xbmcgui.ListItem to work with - otherwise, a new one is created + listItem : existing xbmcgui.ListItem to work with + otherwise, a new one is created + appendShowTitle : True to append TV show title to episode title + appendSxxExx : True to append SxxExx to episode title Returns XBMC listitem for this PMS library item """ @@ -2147,7 +2150,6 @@ class API(): 'cast': people['Cast'], 'director': self.joinList(people.get('Director')), 'plot': self.getPlot(), - 'title': title, 'sorttitle': sorttitle, 'duration': userdata['Runtime'], 'studio': self.joinList(self.getStudios()), @@ -2171,7 +2173,11 @@ class API(): if season and episode: listItem.setProperty('episodeno', "s%.2de%.2d" % (season, episode)) + if appendSxxExx is True: + title = "S%.2dE%.2d - %s" % (season, episode, title) listItem.setIconImage('DefaultTVShows.png') + if appendShowTitle is True: + title = show + ' - ' + title elif self.getType() == "movie": listItem.setIconImage('DefaultMovies.png') else: @@ -2188,6 +2194,8 @@ class API(): except TypeError: pass # Expensive operation + metadata['title'] = title + listItem.setLabel(title) listItem.setInfo('video', infoLabels=metadata) return listItem diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py index 4575ae9f..921750d9 100644 --- a/resources/lib/entrypoint.py +++ b/resources/lib/entrypoint.py @@ -975,15 +975,12 @@ def BrowseChannels(itemid, folderid=None): xbmcplugin.endOfDirectory(handle=int(sys.argv[1])) ##### LISTITEM SETUP FOR VIDEONODES ##### -def createListItem(item): - +def createListItem(item, appendShowTitle=False, appendSxxExx=False): title = item['title'] li = xbmcgui.ListItem(title) li.setProperty('IsPlayable', "true") - - metadata = { - 'Title': title, + metadata = { 'duration': str(item['runtime']/60), 'Plot': item['plot'], 'Playcount': item['playcount'] @@ -999,12 +996,16 @@ def createListItem(item): if season and episode: li.setProperty('episodeno', "s%.2de%.2d" % (season, episode)) + if appendSxxExx is True: + title = "S%.2dE%.2d - %s" % (season, episode, title) if "firstaired" in item: metadata['Premiered'] = item['firstaired'] if "showtitle" in item: metadata['TVshowTitle'] = item['showtitle'] + if appendShowTitle is True: + title = item['showtitle'] + ' - ' + title if "rating" in item: metadata['Rating'] = str(round(float(item['rating']),1)) @@ -1025,6 +1026,9 @@ def createListItem(item): metadata['Cast'] = cast metadata['CastAndRole'] = castandrole + metadata['Title'] = title + li.setLabel(title) + li.setInfo(type="Video", infoLabels=metadata) li.setProperty('resumetime', str(item['resume']['position'])) li.setProperty('totaltime', str(item['resume']['total'])) @@ -1215,6 +1219,10 @@ def getRecentEpisodes(viewid, mediatype, tagname, limit): # if the addon is called with recentepisodes parameter, # we return the recentepisodes list of the given tagname xbmcplugin.setContent(int(sys.argv[1]), 'episodes') + appendShowTitle = True if \ + utils.settings('RecentTvAppendShow') == 'true' else False + appendSxxExx = True if \ + utils.settings('RecentTvAppendSeason') == 'true' else False # First we get a list of all the TV shows - filtered by tag query = { 'jsonrpc': "2.0", @@ -1263,7 +1271,9 @@ def getRecentEpisodes(viewid, mediatype, tagname, limit): else: for episode in episodes: if episode['tvshowid'] in allshowsIds: - li = createListItem(episode) + li = createListItem(episode, + appendShowTitle=appendShowTitle, + appendSxxExx=appendSxxExx) xbmcplugin.addDirectoryItem( handle=int(sys.argv[1]), url=episode['file'], @@ -1484,6 +1494,10 @@ def getOnDeck(viewid, mediatype, tagname, limit): limit: Max. number of items to retrieve, e.g. 50 """ xbmcplugin.setContent(int(sys.argv[1]), 'episodes') + appendShowTitle = True if \ + utils.settings('OnDeckTvAppendShow') == 'true' else False + appendSxxExx = True if \ + utils.settings('OnDeckTvAppendSeason') == 'true' else False if utils.settings('OnDeckTVextended') == 'false': # Chances are that this view is used on Kodi startup # Wait till we've connected to a PMS. At most 30s @@ -1503,7 +1517,9 @@ def getOnDeck(viewid, mediatype, tagname, limit): } for item in xml: API = PlexAPI.API(item) - listitem = API.CreateListItemFromPlexItem() + listitem = API.CreateListItemFromPlexItem( + appendShowTitle=appendShowTitle, + appendSxxExx=appendSxxExx) API.AddStreamInfo(listitem) pbutils.PlaybackUtils(item).setArtwork(listitem) params['id'] = API.getRatingKey() @@ -1606,20 +1622,9 @@ def getOnDeck(viewid, mediatype, tagname, limit): continue for episode in episodes: # There will always be only 1 episode ('limit=1') - li = createListItem(episode) - # Fix some skin shortcomings - title = episode.get('title', '') - if utils.settings('OnDeckTvAppendSeason') == 'true': - seasonid = episode.get('season') - episodeid = episode.get('episode') - if seasonid and episodeid: - title = ('S' + str(seasonid) + 'E' + str(episodeid) - + ' - ' + title) - if utils.settings('OnDeckTvAppendShow') == 'true': - show = episode.get('showtitle') - if show: - title = show + ' - ' + title - li.setLabel(title) + li = createListItem(episode, + appendShowTitle=appendShowTitle, + appendSxxExx=appendSxxExx) xbmcplugin.addDirectoryItem( handle=int(sys.argv[1]), url=episode['file'], diff --git a/resources/settings.xml b/resources/settings.xml index 9229984e..5dc36709 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -127,10 +127,12 @@ - + + +