mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-24 17:56:11 +00:00
add support for native extrafanart
This commit is contained in:
parent
4b9cae3f2f
commit
72ca06e417
2 changed files with 58 additions and 5 deletions
55
default.py
55
default.py
|
@ -2,6 +2,7 @@ import xbmcaddon
|
|||
import xbmcplugin
|
||||
import xbmc
|
||||
import xbmcgui
|
||||
import xbmcvfs
|
||||
import os
|
||||
import threading
|
||||
import json
|
||||
|
@ -12,11 +13,14 @@ cwd = addonSettings.getAddonInfo('path')
|
|||
BASE_RESOURCE_PATH = xbmc.translatePath( os.path.join( cwd, 'resources', 'lib' ) )
|
||||
sys.path.append(BASE_RESOURCE_PATH)
|
||||
|
||||
|
||||
WINDOW = xbmcgui.Window(10000)
|
||||
|
||||
import Utils as utils
|
||||
from PlaybackUtils import PlaybackUtils
|
||||
from DownloadUtils import DownloadUtils
|
||||
from ReadEmbyDB import ReadEmbyDB
|
||||
from API import API
|
||||
|
||||
try:
|
||||
params = utils.get_params(sys.argv[2])
|
||||
|
@ -32,8 +36,57 @@ if mode == "play":
|
|||
result = DownloadUtils().downloadUrl(url)
|
||||
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":
|
||||
utils.reset()
|
||||
else:
|
||||
else:
|
||||
xbmc.executebuiltin('Addon.OpenSettings(plugin.video.emby)')
|
||||
|
||||
|
|
|
@ -114,8 +114,8 @@ class WriteKodiDB():
|
|||
|
||||
#### ADD OR UPDATE THE FILE AND PATH ###########
|
||||
#### NOTE THAT LASTPLAYED AND PLAYCOUNT ARE STORED AT THE FILE ENTRY
|
||||
path = "plugin://plugin.video.emby/movies/"
|
||||
filename = "plugin://plugin.video.emby/movies/?id=%s&mode=play" % MBitem["Id"]
|
||||
path = "plugin://plugin.video.emby/movies/%s/" % MBitem["Id"]
|
||||
filename = "plugin://plugin.video.emby/movies/%s/?id=%s&mode=play" % (MBitem["Id"],MBitem["Id"])
|
||||
|
||||
#create the 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 ###########
|
||||
#### NOTE THAT LASTPLAYED AND PLAYCOUNT ARE STORED AT THE FILE ENTRY
|
||||
path = "plugin://plugin.video.emby/musicvideos/"
|
||||
filename = "plugin://plugin.video.emby/musicvideos/?id=%s&mode=play" % MBitem["Id"]
|
||||
path = "plugin://plugin.video.emby/musicvideos/%s/" % MBitem["Id"]
|
||||
filename = "plugin://plugin.video.emby/musicvideos/%s/?id=%s&mode=play" % (MBitem["Id"], MBitem["Id"])
|
||||
|
||||
#create the path
|
||||
cursor.execute("SELECT idPath as pathid FROM path WHERE strPath = ?",(path,))
|
||||
|
|
Loading…
Reference in a new issue