New setting: Show+SxxExx to Recently Added

- Fixes #12
This commit is contained in:
tomkat83 2016-04-27 10:37:24 +02:00
parent 7be7fe7e01
commit 0d96f6bf4f
5 changed files with 47 additions and 28 deletions

View file

@ -391,7 +391,7 @@
<string id="39045">Appearance Tweaks</string>
<string id="39046">TV Shows</string>
<string id="39047">On Deck: Append show title to episode</string>
<string id="39048">On Deck: Append season- and episode-number (e.g. S3E2)</string>
<string id="39048">On Deck: Append season- and episode-number SxxExx</string>
<string id="39049">Nothing works? Try a full reset!</string>
<string id="39050">[COLOR yellow]Choose Plex Server from a list[/COLOR]</string>
<string id="39051">Wait before sync new/changed PMS item [s]</string>
@ -402,6 +402,8 @@
<string id="39056">Used by Sync and when attempting to Direct Play</string>
<string id="39057">Customize Paths</string>
<string id="39058">Extend Plex TV Series "On Deck" view to all shows</string>
<string id="39059">Recently Added: Append show title to episode</string>
<string id="39060">Recently Added: Append season- and episode-number SxxExx</string>
<!-- Plex Entrypoint.py -->
<string id="39200">Log-out Plex Home User </string>

View file

@ -329,7 +329,7 @@
<string id="39045">Erscheinung</string>
<string id="39046">TV Serien</string>
<string id="39047">"Aktuell": Serien- an Episoden-Titel anfügen</string>
<string id="39048">"Aktuell": Staffel und Episode anfügen (z.B. S3E2)</string>
<string id="39048">"Aktuell": Staffel und Episode anfügen, SxxExx</string>
<string id="39049">Nichts funktioniert? Setze mal alles zurück!</string>
<string id="39050">[COLOR yellow]Plex Server aus Liste auswählen[/COLOR]</string>
<string id="39051">Warten bevor neue/geänderte PMS Einträge gesynct werden [s]</string>
@ -340,6 +340,8 @@
<string id="39056">Verwendet für Synchronisierung sowie beim Versuch, Direct Play zu nutzen</string>
<string id="39057">Pfade ändern</string>
<string id="39058">Standard Plex Ansicht "Aktuell" auf alle TV Shows erweitern</string>
<string id="39059">"Zuletzt hinzugefügt": Serien- an Episoden-Titel anfügen</string>
<string id="39060">"Zuletzt hinzugefügt": Staffel und Episode anfügen, SxxExx</string>

View file

@ -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
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

View file

@ -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,
'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'],

View file

@ -127,10 +127,12 @@
<category label="39045"><!-- Appearance Tweaks -->
<setting id="connectMsg" type="bool" label="30249" default="true" />
<setting type="lsep" label="39046" />
<setting type="lsep" label="39046" /><!-- TV Shows -->
<setting id="OnDeckTVextended" type="bool" label="39058" default="true" /><!-- Extend Plex TV Series "On Deck" view to all shows -->
<setting id="OnDeckTvAppendShow" type="bool" label="39047" default="false" /><!--On Deck view: Append show title to episode-->
<setting id="OnDeckTvAppendSeason" type="bool" label="39048" default="false" /><!--On Deck view: Append season number to episode-->
<setting id="RecentTvAppendShow" type="bool" label="39059" default="false" /><!--Recently added: Append show title to episode-->
<setting id="RecentTvAppendSeason" type="bool" label="39060" default="false" /><!--Recently Added: Append season- and episode-number SxxExx-->
</category>
<category label="30022"><!-- Advanced -->