New settings option: default Plex On Deck TV Shows

This commit is contained in:
tomkat83 2016-04-18 11:23:05 +02:00
parent 2d2dd0fa12
commit 49a5f274e6
5 changed files with 54 additions and 8 deletions

View file

@ -401,6 +401,7 @@
<string id="39055">Searching for Plex Server</string>
<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>
<!-- Plex Entrypoint.py -->
<string id="39200">Log-out Plex Home User </string>

View file

@ -339,6 +339,7 @@
<string id="39055">Suche Plex Server</string>
<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>

View file

@ -322,10 +322,14 @@ class DownloadUtils():
# And now deal with the consequences of the exceptions
if authenticate is True:
# Make the addon aware of status
window('countError',
value=str(int(window('countError')) + 1))
if int(window('countError')) >= self.connectionAttempts:
self.logMsg('Failed to connect to %s too many times. Declare '
'PMS dead' % url, -1)
window('emby_online', value="false")
return False
try:
window('countError',
value=str(int(window('countError')) + 1))
if int(window('countError')) >= self.connectionAttempts:
self.logMsg('Failed to connect to %s too many times. '
'Declare PMS dead' % url, -1)
window('emby_online', value="false")
except:
# 'countError' not yet set
pass
return None

View file

@ -1481,9 +1481,48 @@ def getOnDeck(viewid, mediatype, tagname, limit):
tagname: Name of the Plex library, e.g. "My Movies"
limit: Max. number of items to retrieve, e.g. 50
"""
xbmcplugin.setContent(int(sys.argv[1]), 'episodes')
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
counter = 0
while utils.window('plex_authenticated') != 'true':
counter += 1
if counter >= 300:
break
xbmc.sleep(100)
xml = downloadutils.DownloadUtils().downloadUrl(
'{server}/library/sections/%s/onDeck' % viewid)
if xml in (None, 401):
return xbmcplugin.endOfDirectory(int(sys.argv[1]))
url = "plugin://plugin.video.plexkodiconnect.tvshows/"
params = {
'mode': "play"
}
with embydb.GetEmbyDB() as emby_db:
for item in xml:
API = PlexAPI.API(item)
listitem = API.CreateListItemFromPlexItem()
API.AddStreamInfo(listitem)
pbutils.PlaybackUtils(item).setArtwork(listitem)
plexID = API.getRatingKey()
try:
dbid = emby_db.getItem_byId(plexID)[0]
except TypeError:
dbid = None
params['id'] = plexID
params['dbid'] = dbid
xbmcplugin.addDirectoryItem(
handle=int(sys.argv[1]),
url="%s?%s" % (url, urllib.urlencode(params)),
listitem=listitem)
return xbmcplugin.endOfDirectory(
handle=int(sys.argv[1]),
cacheToDisc=True if utils.settings('enableTextureCache') == 'true'
else False)
# if the addon is called with nextup parameter,
# we return the nextepisodes list of the given tagname
xbmcplugin.setContent(int(sys.argv[1]), 'episodes')
# First we get a list of all the TV shows - filtered by tag
query = {
'jsonrpc': "2.0",

View file

@ -128,6 +128,7 @@
<category label="39045"><!-- Appearance Tweaks -->
<setting id="connectMsg" type="bool" label="30249" default="true" />
<setting type="lsep" label="39046" />
<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-->
</category>