parent
f2dd8617f3
commit
133482001c
2 changed files with 33 additions and 83 deletions
|
@ -37,7 +37,6 @@ import xml.etree.ElementTree as etree
|
||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
from urllib import urlencode, quote_plus, unquote
|
from urllib import urlencode, quote_plus, unquote
|
||||||
import requests
|
|
||||||
|
|
||||||
import xbmcaddon
|
import xbmcaddon
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
|
@ -47,7 +46,7 @@ import xbmcvfs
|
||||||
import clientinfo
|
import clientinfo
|
||||||
import utils
|
import utils
|
||||||
import downloadutils
|
import downloadutils
|
||||||
import embydb_functions as embydb
|
import requests
|
||||||
from PlexFunctions import PlexToKodiTimefactor, PMSHttpsEnabled
|
from PlexFunctions import PlexToKodiTimefactor, PMSHttpsEnabled
|
||||||
|
|
||||||
|
|
||||||
|
@ -2146,31 +2145,13 @@ class API():
|
||||||
|
|
||||||
Returns XBMC listitem for this PMS library item
|
Returns XBMC listitem for this PMS library item
|
||||||
"""
|
"""
|
||||||
|
people = self.getPeople()
|
||||||
|
userdata = self.getUserData()
|
||||||
title, sorttitle = self.getTitle()
|
title, sorttitle = self.getTitle()
|
||||||
|
|
||||||
if listItem is None:
|
if listItem is None:
|
||||||
listItem = xbmcgui.ListItem(title)
|
listItem = xbmcgui.ListItem()
|
||||||
else:
|
|
||||||
listItem.setLabel(title)
|
|
||||||
|
|
||||||
listItem.setProperty('IsPlayable', 'true')
|
|
||||||
listItem.setProperty('IsFolder', 'false')
|
|
||||||
|
|
||||||
typus = self.getType()
|
|
||||||
if typus == 'movie':
|
|
||||||
listItem.setProperty('DBTYPE', 'movie')
|
|
||||||
elif typus == 'episode':
|
|
||||||
listItem.setProperty('DBTYPE', 'episode')
|
|
||||||
|
|
||||||
with embydb.GetEmbyDB() as emby_db:
|
|
||||||
try:
|
|
||||||
dbid = emby_db.getItem_byId(self.getRatingKey())[0]
|
|
||||||
listItem.setProperty('dbid', str(dbid))
|
|
||||||
except TypeError:
|
|
||||||
pass
|
|
||||||
self.logMsg('ratingKey: %s, dbid: %s' % (self.getRatingKey(), str(dbid)))
|
|
||||||
people = self.getPeople()
|
|
||||||
userdata = self.getUserData()
|
|
||||||
metadata = {
|
metadata = {
|
||||||
'genre': self.joinList(self.getGenres()),
|
'genre': self.joinList(self.getGenres()),
|
||||||
'year': self.getYear(),
|
'year': self.getYear(),
|
||||||
|
@ -2179,6 +2160,7 @@ class API():
|
||||||
'cast': people['Cast'],
|
'cast': people['Cast'],
|
||||||
'director': self.joinList(people.get('Director')),
|
'director': self.joinList(people.get('Director')),
|
||||||
'plot': self.getPlot(),
|
'plot': self.getPlot(),
|
||||||
|
'title': title,
|
||||||
'sorttitle': sorttitle,
|
'sorttitle': sorttitle,
|
||||||
'duration': userdata['Runtime'],
|
'duration': userdata['Runtime'],
|
||||||
'studio': self.joinList(self.getStudios()),
|
'studio': self.joinList(self.getStudios()),
|
||||||
|
@ -2190,38 +2172,24 @@ class API():
|
||||||
'mpaa': self.getMpaa(),
|
'mpaa': self.getMpaa(),
|
||||||
'aired': self.getPremiereDate()
|
'aired': self.getPremiereDate()
|
||||||
}
|
}
|
||||||
|
try:
|
||||||
if userdata['Resume'] > 0:
|
PercentPlayed = userdata['Resume'] / userdata['Runtime'] * 100.0
|
||||||
listItem.setProperty('resumetime', str(userdata['Resume']))
|
except ZeroDivisionError:
|
||||||
if userdata['Runtime'] > 0:
|
PercentPlayed = 0.0
|
||||||
listItem.setProperty('totaltime', str(userdata['Runtime']))
|
if PercentPlayed > 0:
|
||||||
|
metadata['PercentPlayed'] = PercentPlayed
|
||||||
|
|
||||||
if self.getType() == "episode":
|
if self.getType() == "episode":
|
||||||
# Only for tv shows
|
# Only for tv shows
|
||||||
key, show, season, episode = self.getEpisodeDetails()
|
key, show, season, episode = self.getEpisodeDetails()
|
||||||
metadata['episode'] = int(episode)
|
metadata['episode'] = episode
|
||||||
metadata['season'] = int(season)
|
metadata['season'] = season
|
||||||
metadata['tvshowtitle'] = show
|
metadata['tvshowtitle'] = show
|
||||||
try:
|
|
||||||
listItem.setProperty('episodeno', "s%.2de%.2d"
|
|
||||||
% (int(season), int(episode)))
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
listItem.setIconImage('DefaultTVShows.png')
|
|
||||||
elif self.getType() == "movie":
|
|
||||||
listItem.setIconImage('DefaultMovies.png')
|
|
||||||
elif self.getType() == "clip":
|
|
||||||
listItem.setIconImage('DefaultVideo.png')
|
|
||||||
|
|
||||||
artwork = self.getAllArtwork()
|
listItem.setProperty('IsPlayable', 'true')
|
||||||
if artwork.get('Primary'):
|
listItem.setProperty('IsFolder', 'false')
|
||||||
listItem.setThumbnailImage(artwork.get('Primary'))
|
listItem.setProperty('embyid', self.getRatingKey())
|
||||||
elif self.getType() == "movie":
|
listItem.setLabel(title)
|
||||||
listItem.setThumbnailImage('DefaultMovies.png')
|
|
||||||
elif self.getType() == "episode":
|
|
||||||
listItem.setThumbnailImage('DefaultTVShows.png')
|
|
||||||
|
|
||||||
# Very resource intensive
|
|
||||||
listItem.setInfo('video', infoLabels=metadata)
|
listItem.setInfo('video', infoLabels=metadata)
|
||||||
return listItem
|
return listItem
|
||||||
|
|
||||||
|
|
|
@ -1031,7 +1031,6 @@ def createListItem(item):
|
||||||
li.setIconImage('DefaultTVShows.png')
|
li.setIconImage('DefaultTVShows.png')
|
||||||
li.setProperty('dbid', str(item['episodeid']))
|
li.setProperty('dbid', str(item['episodeid']))
|
||||||
li.setProperty('fanart_image', item['art'].get('tvshow.fanart',''))
|
li.setProperty('fanart_image', item['art'].get('tvshow.fanart',''))
|
||||||
li.setLabel(title)
|
|
||||||
for key, value in item['streamdetails'].iteritems():
|
for key, value in item['streamdetails'].iteritems():
|
||||||
for stream in value:
|
for stream in value:
|
||||||
li.addStreamInfo(key, stream)
|
li.addStreamInfo(key, stream)
|
||||||
|
@ -1492,12 +1491,6 @@ def getOnDeck(viewid, mediatype, tagname, limit):
|
||||||
if counter >= 300:
|
if counter >= 300:
|
||||||
break
|
break
|
||||||
xbmc.sleep(100)
|
xbmc.sleep(100)
|
||||||
# Wait till full lib sync done
|
|
||||||
while utils.window('emby_dbScan') == 'true':
|
|
||||||
counter += 1
|
|
||||||
if counter >= 300:
|
|
||||||
break
|
|
||||||
xbmc.sleep(100)
|
|
||||||
xml = downloadutils.DownloadUtils().downloadUrl(
|
xml = downloadutils.DownloadUtils().downloadUrl(
|
||||||
'{server}/library/sections/%s/onDeck' % viewid)
|
'{server}/library/sections/%s/onDeck' % viewid)
|
||||||
if xml in (None, 401):
|
if xml in (None, 401):
|
||||||
|
@ -1506,34 +1499,23 @@ def getOnDeck(viewid, mediatype, tagname, limit):
|
||||||
params = {
|
params = {
|
||||||
'mode': "play"
|
'mode': "play"
|
||||||
}
|
}
|
||||||
counter = 0
|
with embydb.GetEmbyDB() as emby_db:
|
||||||
for item in xml:
|
for item in xml:
|
||||||
counter += 1
|
API = PlexAPI.API(item)
|
||||||
if counter > 1:
|
listitem = API.CreateListItemFromPlexItem()
|
||||||
break
|
API.AddStreamInfo(listitem)
|
||||||
API = PlexAPI.API(item)
|
pbutils.PlaybackUtils(item).setArtwork(listitem)
|
||||||
listitem = API.CreateListItemFromPlexItem()
|
plexID = API.getRatingKey()
|
||||||
pbutils.PlaybackUtils(item).setArtwork(listitem)
|
|
||||||
API.AddStreamInfo(listitem)
|
|
||||||
plexID = API.getRatingKey()
|
|
||||||
with embydb.GetEmbyDB() as emby_db:
|
|
||||||
try:
|
try:
|
||||||
dbid = emby_db.getItem_byId(plexID)[0]
|
dbid = emby_db.getItem_byId(plexID)[0]
|
||||||
except TypeError:
|
except TypeError:
|
||||||
dbid = None
|
dbid = None
|
||||||
params['id'] = plexID
|
params['id'] = plexID
|
||||||
params['dbid'] = dbid
|
params['dbid'] = dbid
|
||||||
path = "%s?%s" % (url, urllib.urlencode(params))
|
xbmcplugin.addDirectoryItem(
|
||||||
listitem.setProperty('path', path)
|
handle=int(sys.argv[1]),
|
||||||
listitem.setProperty('file', path)
|
url="%s?%s" % (url, urllib.urlencode(params)),
|
||||||
listitem.setProperty('FileNameAndPath', path)
|
listitem=listitem)
|
||||||
props = ('dbid', 'DBTYPE', 'path',)
|
|
||||||
for thing in props:
|
|
||||||
utils.logMsg('%s: %s' % (thing, listitem.getProperty(thing)), 1)
|
|
||||||
xbmcplugin.addDirectoryItem(
|
|
||||||
handle=int(sys.argv[1]),
|
|
||||||
url=path,
|
|
||||||
listitem=listitem)
|
|
||||||
return xbmcplugin.endOfDirectory(
|
return xbmcplugin.endOfDirectory(
|
||||||
handle=int(sys.argv[1]),
|
handle=int(sys.argv[1]),
|
||||||
cacheToDisc=True if utils.settings('enableTextureCache') == 'true'
|
cacheToDisc=True if utils.settings('enableTextureCache') == 'true'
|
||||||
|
@ -1628,7 +1610,7 @@ def getOnDeck(viewid, mediatype, tagname, limit):
|
||||||
continue
|
continue
|
||||||
for episode in episodes:
|
for episode in episodes:
|
||||||
# There will always be only 1 episode ('limit=1')
|
# There will always be only 1 episode ('limit=1')
|
||||||
listitem = createListItem(episode)
|
li = createListItem(episode)
|
||||||
# Fix some skin shortcomings
|
# Fix some skin shortcomings
|
||||||
title = episode.get('title', '')
|
title = episode.get('title', '')
|
||||||
if utils.settings('OnDeckTvAppendSeason') == 'true':
|
if utils.settings('OnDeckTvAppendSeason') == 'true':
|
||||||
|
@ -1641,11 +1623,11 @@ def getOnDeck(viewid, mediatype, tagname, limit):
|
||||||
show = episode.get('showtitle')
|
show = episode.get('showtitle')
|
||||||
if show:
|
if show:
|
||||||
title = show + ' - ' + title
|
title = show + ' - ' + title
|
||||||
listitem.setLabel(title)
|
li.setLabel(title)
|
||||||
xbmcplugin.addDirectoryItem(
|
xbmcplugin.addDirectoryItem(
|
||||||
handle=int(sys.argv[1]),
|
handle=int(sys.argv[1]),
|
||||||
url=episode['file'],
|
url=episode['file'],
|
||||||
listitem=listitem,
|
listitem=li,
|
||||||
isFolder=False)
|
isFolder=False)
|
||||||
|
|
||||||
count += 1
|
count += 1
|
||||||
|
|
Loading…
Reference in a new issue