mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 02:06:09 +00:00
Merge branch 'database_changes' of https://github.com/MediaBrowser/Emby.Kodi.git into database_changes
This commit is contained in:
commit
ba4a00c53a
4 changed files with 105 additions and 39 deletions
53
default.py
53
default.py
|
@ -2,6 +2,7 @@ import xbmcaddon
|
||||||
import xbmcplugin
|
import xbmcplugin
|
||||||
import xbmc
|
import xbmc
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
|
import xbmcvfs
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
import json
|
import json
|
||||||
|
@ -12,11 +13,14 @@ cwd = addonSettings.getAddonInfo('path')
|
||||||
BASE_RESOURCE_PATH = xbmc.translatePath( os.path.join( cwd, 'resources', 'lib' ) )
|
BASE_RESOURCE_PATH = xbmc.translatePath( os.path.join( cwd, 'resources', 'lib' ) )
|
||||||
sys.path.append(BASE_RESOURCE_PATH)
|
sys.path.append(BASE_RESOURCE_PATH)
|
||||||
|
|
||||||
|
|
||||||
WINDOW = xbmcgui.Window(10000)
|
WINDOW = xbmcgui.Window(10000)
|
||||||
|
|
||||||
import Utils as utils
|
import Utils as utils
|
||||||
from PlaybackUtils import PlaybackUtils
|
from PlaybackUtils import PlaybackUtils
|
||||||
from DownloadUtils import DownloadUtils
|
from DownloadUtils import DownloadUtils
|
||||||
|
from ReadEmbyDB import ReadEmbyDB
|
||||||
|
from API import API
|
||||||
|
|
||||||
try:
|
try:
|
||||||
params = utils.get_params(sys.argv[2])
|
params = utils.get_params(sys.argv[2])
|
||||||
|
@ -32,6 +36,55 @@ if mode == "play":
|
||||||
result = DownloadUtils().downloadUrl(url)
|
result = DownloadUtils().downloadUrl(url)
|
||||||
item = PlaybackUtils().PLAY(result, setup="default")
|
item = PlaybackUtils().PLAY(result, setup="default")
|
||||||
|
|
||||||
|
|
||||||
|
#get extrafanart for listitem - this will only be used for skins that actually call the listitem's path + fanart dir...
|
||||||
|
elif "extrafanart" in sys.argv[0]:
|
||||||
|
itemPath = ""
|
||||||
|
embyId = ""
|
||||||
|
|
||||||
|
try:
|
||||||
|
#only do this if the listitem has actually changed
|
||||||
|
itemPath = xbmc.getInfoLabel("ListItem.FileNameAndPath")
|
||||||
|
|
||||||
|
if not itemPath:
|
||||||
|
itemPath = xbmc.getInfoLabel("ListItem.Path")
|
||||||
|
|
||||||
|
if ("/tvshows/" in itemPath or "/musicvideos/" in itemPath or "/movies/" in itemPath):
|
||||||
|
embyId = itemPath.split("/")[-2]
|
||||||
|
|
||||||
|
#we need to store the images locally for this to work because of the caching system in xbmc
|
||||||
|
fanartDir = xbmc.translatePath("special://thumbnails/emby/" + embyId + "/")
|
||||||
|
|
||||||
|
if not xbmcvfs.exists(fanartDir):
|
||||||
|
#download the images to the cache directory
|
||||||
|
xbmcvfs.mkdir(fanartDir)
|
||||||
|
item = ReadEmbyDB().getFullItem(embyId)
|
||||||
|
if item != None:
|
||||||
|
if item.has_key("BackdropImageTags"):
|
||||||
|
if(len(item["BackdropImageTags"]) > 1):
|
||||||
|
totalbackdrops = len(item["BackdropImageTags"])
|
||||||
|
for index in range(1,totalbackdrops):
|
||||||
|
backgroundUrl = API().getArtwork(item, "Backdrop",str(index))
|
||||||
|
fanartFile = os.path.join(fanartDir,"fanart" + str(index) + ".jpg")
|
||||||
|
li = xbmcgui.ListItem(str(index), path=fanartFile)
|
||||||
|
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=fanartFile, listitem=li)
|
||||||
|
xbmcvfs.copy(backgroundUrl,fanartFile)
|
||||||
|
|
||||||
|
else:
|
||||||
|
#use existing cached images
|
||||||
|
dirs, files = xbmcvfs.listdir(fanartDir)
|
||||||
|
count = 1
|
||||||
|
for file in files:
|
||||||
|
count +=1
|
||||||
|
li = xbmcgui.ListItem(file, path=os.path.join(fanartDir,file))
|
||||||
|
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=os.path.join(fanartDir,file), listitem=li)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
#always do endofdirectory to prevent errors in the logs
|
||||||
|
xbmcplugin.endOfDirectory(int(sys.argv[1]))
|
||||||
|
|
||||||
|
|
||||||
elif sys.argv[1] == "reset":
|
elif sys.argv[1] == "reset":
|
||||||
utils.reset()
|
utils.reset()
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -76,17 +76,19 @@ class PlaybackUtils():
|
||||||
WINDOW.setProperty(playurl+"deleteurl", "")
|
WINDOW.setProperty(playurl+"deleteurl", "")
|
||||||
WINDOW.setProperty(playurl+"deleteurl", deleteurl)
|
WINDOW.setProperty(playurl+"deleteurl", deleteurl)
|
||||||
|
|
||||||
'''if seekTime != 0:
|
#show the additional resume dialog if launched from a widget
|
||||||
displayTime = str(datetime.timedelta(seconds=seekTime))
|
if xbmc.getCondVisibility("Window.IsActive(home)"):
|
||||||
display_list = [ self.language(30106) + ' ' + displayTime, self.language(30107)]
|
if seekTime != 0:
|
||||||
resumeScreen = xbmcgui.Dialog()
|
displayTime = str(datetime.timedelta(seconds=seekTime))
|
||||||
resume_result = resumeScreen.select(self.language(30105), display_list)
|
display_list = [ self.language(30106) + ' ' + displayTime, self.language(30107)]
|
||||||
if resume_result == 0:
|
resumeScreen = xbmcgui.Dialog()
|
||||||
WINDOW.setProperty(playurl+"seektime", str(seekTime))
|
resume_result = resumeScreen.select(self.language(30105), display_list)
|
||||||
|
if resume_result == 0:
|
||||||
|
WINDOW.setProperty(playurl+"seektime", str(seekTime))
|
||||||
|
else:
|
||||||
|
WINDOW.clearProperty(playurl+"seektime")
|
||||||
else:
|
else:
|
||||||
WINDOW.clearProperty(playurl+"seektime")
|
WINDOW.clearProperty(playurl+"seektime")
|
||||||
else:
|
|
||||||
WINDOW.clearProperty(playurl+"seektime")'''
|
|
||||||
|
|
||||||
if result.get("Type")=="Episode":
|
if result.get("Type")=="Episode":
|
||||||
WINDOW.setProperty(playurl+"refresh_id", result.get("SeriesId"))
|
WINDOW.setProperty(playurl+"refresh_id", result.get("SeriesId"))
|
||||||
|
@ -117,7 +119,8 @@ class PlaybackUtils():
|
||||||
elif setup == "default":
|
elif setup == "default":
|
||||||
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listItem)
|
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listItem)
|
||||||
#artwork only works from widgets with both resolvedurl and player command
|
#artwork only works from widgets with both resolvedurl and player command
|
||||||
xbmc.Player().play(playurl,listItem)
|
if xbmc.getCondVisibility("Window.IsActive(home)"):
|
||||||
|
xbmc.Player().play(playurl,listItem)
|
||||||
|
|
||||||
def setArt(self, list,name,path):
|
def setArt(self, list,name,path):
|
||||||
if name=='thumb' or name=='fanart_image' or name=='small_poster' or name=='tiny_poster' or name == "medium_landscape" or name=='medium_poster' or name=='small_fanartimage' or name=='medium_fanartimage' or name=='fanart_noindicators':
|
if name=='thumb' or name=='fanart_image' or name=='small_poster' or name=='tiny_poster' or name == "medium_landscape" or name=='medium_poster' or name=='small_fanartimage' or name=='medium_fanartimage' or name=='fanart_noindicators':
|
||||||
|
|
|
@ -226,33 +226,43 @@ class ReadEmbyDB():
|
||||||
doUtils = DownloadUtils()
|
doUtils = DownloadUtils()
|
||||||
|
|
||||||
viewsUrl = "{server}/mediabrowser/Users/{UserId}/Views?format=json&ImageTypeLimit=1"
|
viewsUrl = "{server}/mediabrowser/Users/{UserId}/Views?format=json&ImageTypeLimit=1"
|
||||||
jsonData = doUtils.downloadUrl(viewsUrl)
|
result = doUtils.downloadUrl(viewsUrl)
|
||||||
collections=[]
|
collections=[]
|
||||||
|
|
||||||
if (jsonData != ""):
|
if (result == ""):
|
||||||
views = views[u'Items']
|
return []
|
||||||
|
|
||||||
for view in views:
|
result = result[u'Items']
|
||||||
if (view[u'Type'] == 'UserView'): # Need to grab the real main node
|
|
||||||
newViewsUrl = "{server}/mediabrowser/Users/{UserId}/items?ParentId=%s&SortBy=SortName&SortOrder=Ascending&format=json&ImageTypeLimit=1" % view[u'Id']
|
|
||||||
jsonData = doUtils.downloadUrl(newViewsUrl)
|
|
||||||
if (jsonData != ""):
|
|
||||||
newViews = newViews[u'Items']
|
|
||||||
for newView in newViews:
|
|
||||||
# There are multiple nodes in here like 'Latest', 'NextUp' - below we grab the full node.
|
|
||||||
if newView[u'CollectionType'] == "MovieMovies" or newView[u'CollectionType'] == "TvShowSeries":
|
|
||||||
view=newView
|
|
||||||
if (view[u'ChildCount'] != 0):
|
|
||||||
Name = view[u'Name']
|
|
||||||
|
|
||||||
total = str(view[u'ChildCount'])
|
for view in result:
|
||||||
|
if (view[u'Type'] == 'UserView'): # Need to grab the real main node
|
||||||
|
newViewsUrl = "{server}/mediabrowser/Users/{UserId}/items?ParentId=%s&SortBy=SortName&SortOrder=Ascending&format=json&ImageTypeLimit=1" % view[u'Id']
|
||||||
|
newViews = doUtils.downloadUrl(newViewsUrl)
|
||||||
|
if (result == ""):
|
||||||
|
return []
|
||||||
|
newViews = newViews[u'Items']
|
||||||
|
print str(newViews)
|
||||||
|
for newView in newViews:
|
||||||
|
# There are multiple nodes in here like 'Latest', 'NextUp' - below we grab the full node.
|
||||||
|
if newView[u'CollectionType'] != None:
|
||||||
|
if newView[u'CollectionType'] == "MovieMovies" or newView[u'CollectionType'] == "TvShowSeries":
|
||||||
|
view=newView
|
||||||
|
if (view[u'ChildCount'] != 0):
|
||||||
|
Name = view[u'Name']
|
||||||
|
|
||||||
|
total = str(view[u'ChildCount'])
|
||||||
|
try:
|
||||||
itemtype = view[u'CollectionType']
|
itemtype = view[u'CollectionType']
|
||||||
if itemtype == None:
|
except:
|
||||||
itemtype = "movies" # User may not have declared the type
|
itemtype = "movies"
|
||||||
if itemtype == type:
|
if itemtype == "MovieMovies":
|
||||||
collections.append( {'title' : Name,
|
itemtype = "movies"
|
||||||
'type' : type,
|
if itemtype == "TvShowSeries":
|
||||||
'id' : view[u'Id']})
|
itemtype = "tvshows"
|
||||||
|
if itemtype == type:
|
||||||
|
collections.append( {'title' : Name,
|
||||||
|
'type' : type,
|
||||||
|
'id' : view[u'Id']})
|
||||||
return collections
|
return collections
|
||||||
|
|
||||||
def getBoxSets(self):
|
def getBoxSets(self):
|
||||||
|
|
|
@ -114,8 +114,8 @@ class WriteKodiDB():
|
||||||
|
|
||||||
#### ADD OR UPDATE THE FILE AND PATH ###########
|
#### ADD OR UPDATE THE FILE AND PATH ###########
|
||||||
#### NOTE THAT LASTPLAYED AND PLAYCOUNT ARE STORED AT THE FILE ENTRY
|
#### NOTE THAT LASTPLAYED AND PLAYCOUNT ARE STORED AT THE FILE ENTRY
|
||||||
path = "plugin://plugin.video.emby/movies/"
|
path = "plugin://plugin.video.emby/movies/%s/" % MBitem["Id"]
|
||||||
filename = "plugin://plugin.video.emby/movies/?id=%s&mode=play" % MBitem["Id"]
|
filename = "plugin://plugin.video.emby/movies/%s/?id=%s&mode=play" % (MBitem["Id"],MBitem["Id"])
|
||||||
|
|
||||||
#create the path
|
#create the path
|
||||||
cursor.execute("SELECT idPath as pathid FROM path WHERE strPath = ?",(path,))
|
cursor.execute("SELECT idPath as pathid FROM path WHERE strPath = ?",(path,))
|
||||||
|
@ -257,8 +257,8 @@ class WriteKodiDB():
|
||||||
|
|
||||||
#### ADD OR UPDATE THE FILE AND PATH ###########
|
#### ADD OR UPDATE THE FILE AND PATH ###########
|
||||||
#### NOTE THAT LASTPLAYED AND PLAYCOUNT ARE STORED AT THE FILE ENTRY
|
#### NOTE THAT LASTPLAYED AND PLAYCOUNT ARE STORED AT THE FILE ENTRY
|
||||||
path = "plugin://plugin.video.emby/musicvideos/"
|
path = "plugin://plugin.video.emby/musicvideos/%s/" % MBitem["Id"]
|
||||||
filename = "plugin://plugin.video.emby/musicvideos/?id=%s&mode=play" % MBitem["Id"]
|
filename = "plugin://plugin.video.emby/musicvideos/%s/?id=%s&mode=play" % (MBitem["Id"], MBitem["Id"])
|
||||||
|
|
||||||
#create the path
|
#create the path
|
||||||
cursor.execute("SELECT idPath as pathid FROM path WHERE strPath = ?",(path,))
|
cursor.execute("SELECT idPath as pathid FROM path WHERE strPath = ?",(path,))
|
||||||
|
|
Loading…
Reference in a new issue