diff --git a/addon.xml b/addon.xml index cf14026e..f6a82d42 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ diff --git a/changelog.txt b/changelog.txt index 03f8f2c7..baa14c63 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +version 2.2.8 +- Fix to photos not displaying directories without picutres. +- Fix to grouped views causing crash + version 2.2.7 - Prevent Kodi screensaver during the initial sync diff --git a/default.py b/default.py index e4b5173b..0cc69761 100644 --- a/default.py +++ b/default.py @@ -51,7 +51,6 @@ class Main: 'reset': utils.reset, 'resetauth': entrypoint.resetAuth, - 'extrafanart': entrypoint.getExtraFanArt, 'play': entrypoint.doPlayback, 'passwords': utils.passwordsXML, 'adduser': entrypoint.addUser, @@ -70,8 +69,15 @@ class Main: 'doPlexTvLogin': entrypoint.doPlexTvLogin } - if "extrafanart" in sys.argv[0]: - entrypoint.getExtraFanArt() + if "/extrafanart" in sys.argv[0]: + embypath = sys.argv[2][1:] + embyid = params.get('id',[""])[0] + entrypoint.getExtraFanArt(embyid,embypath) + + if "/Extras" in sys.argv[0] or "/VideoFiles" in sys.argv[0]: + embypath = sys.argv[2][1:] + embyid = params.get('id',[""])[0] + entrypoint.getVideoFiles(embyid,embypath) if modes.get(mode): # Simple functions diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py index 7046b9c1..07f8b84f 100644 --- a/resources/lib/entrypoint.py +++ b/resources/lib/entrypoint.py @@ -572,10 +572,10 @@ def BrowseContent(viewname, type="", folderid=""): if not folderid: views = emby.getViews(type) for view in views: - if view.get("name") == viewname: + if view.get("name") == viewname.decode('utf-8'): folderid = view.get("id") - utils.logMsg("BrowseContent","viewname: %s - type: %s - folderid: %s - filter: %s" %(viewname, type, folderid, filter)) + utils.logMsg("BrowseContent","viewname: %s - type: %s - folderid: %s - filter: %s" %(viewname.decode('utf-8'), type.decode('utf-8'), folderid.decode('utf-8'), filter.decode('utf-8'))) #set the correct params for the content type #only proceed if we have a folderid if folderid: @@ -584,7 +584,7 @@ def BrowseContent(viewname, type="", folderid=""): itemtype = "Video,Folder,PhotoAlbum" elif type.lower() == "photos": xbmcplugin.setContent(int(sys.argv[1]), 'files') - itemtype = "Photo,PhotoAlbum" + itemtype = "Photo,PhotoAlbum,Folder" else: itemtype = "" @@ -610,14 +610,13 @@ def BrowseContent(viewname, type="", folderid=""): li = createListItemFromEmbyItem(item,art,doUtils) if item.get("IsFolder") == True: #for folders we add an additional browse request, passing the folderId - path = "%s?id=%s&mode=browsecontent&type=%s&folderid=%s" % (sys.argv[0], viewname, type, item.get("Id")) + path = "%s?id=%s&mode=browsecontent&type=%s&folderid=%s" % (sys.argv[0].decode('utf-8'), viewname.decode('utf-8'), type.decode('utf-8'), item.get("Id").decode('utf-8')) xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=path, listitem=li, isFolder=True) else: #playable item, set plugin path and mediastreams xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=li.getProperty("path"), listitem=li) - xbmcplugin.endOfDirectory(handle=int(sys.argv[1])) if filter == "recent": xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_DATE) else: @@ -626,6 +625,8 @@ def BrowseContent(viewname, type="", folderid=""): xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_RATING) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_RUNTIME) + xbmcplugin.endOfDirectory(handle=int(sys.argv[1])) + ##### CREATE LISTITEM FROM EMBY METADATA ##### def createListItemFromEmbyItem(item,art=artwork.Artwork(),doUtils=downloadutils.DownloadUtils()): API = api.API(item) @@ -1066,28 +1067,45 @@ def getRecentEpisodes(tagname, limit): xbmcplugin.endOfDirectory(handle=int(sys.argv[1])) +##### GET VIDEO EXTRAS FOR LISTITEM ##### +def getVideoFiles(embyId,embyPath): + #returns the video files for the item as plugin listing, can be used for browsing the actual files or videoextras etc. + emby = embyserver.Read_EmbyServer() + if not embyId: + if "plugin.video.emby" in embyPath: + embyId = embyPath.split("/")[-2] + if embyId: + item = emby.getItem(embyId) + putils = playutils.PlayUtils(item) + if putils.isDirectPlay(): + #only proceed if we can access the files directly. TODO: copy local on the fly if accessed outside + filelocation = putils.directPlay() + if not filelocation.endswith("/"): + filelocation = filelocation.rpartition("/")[0] + dirs, files = xbmcvfs.listdir(filelocation) + for file in files: + file = filelocation + file + li = xbmcgui.ListItem(file, path=file) + xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=file, listitem=li) + for dir in dirs: + dir = filelocation + dir + li = xbmcgui.ListItem(dir, path=dir) + xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=dir, listitem=li, isFolder=True) + xbmcplugin.endOfDirectory(int(sys.argv[1])) + ##### GET EXTRAFANART FOR LISTITEM ##### -def getExtraFanArt(): +def getExtraFanArt(embyId,embyPath): emby = embyserver.Read_EmbyServer() art = artwork.Artwork() - embyId = "" # Get extrafanart for listitem # will be called by skinhelper script to get the extrafanart try: # for tvshows we get the embyid just from the path - if xbmc.getCondVisibility("Container.Content(tvshows) | Container.Content(seasons) | Container.Content(episodes)"): - itemPath = xbmc.getInfoLabel("ListItem.Path").decode('utf-8') - if "plugin.video.plexkodiconnect" in itemPath: - embyId = itemPath.split("/")[-2] - else: - #for movies we grab the emby id from the params - itemPath = xbmc.getInfoLabel("ListItem.FileNameAndPath").decode('utf-8') - if "plugin.video.plexkodiconnect" in itemPath: - params = urlparse.parse_qs(itemPath) - embyId = params.get('id') - if embyId: embyId = embyId[0] + if not embyId: + if "plugin.video.emby" in embyPath: + embyId = embyPath.split("/")[-2] if embyId: #only proceed if we actually have a emby id @@ -1131,7 +1149,7 @@ def getExtraFanArt(): url=fanartFile, listitem=li) except Exception as e: - utils.logMsg("EMBY", "Error getting extrafanart: %s" % e, 1) + utils.logMsg("EMBY", "Error getting extrafanart: %s" % e, 0) # Always do endofdirectory to prevent errors in the logs xbmcplugin.endOfDirectory(int(sys.argv[1])) diff --git a/resources/lib/musicutils.py b/resources/lib/musicutils.py index 92fbaf66..c58cb245 100644 --- a/resources/lib/musicutils.py +++ b/resources/lib/musicutils.py @@ -214,7 +214,7 @@ def getSongTags(file): except Exception as e: #file in use ? - logMsg("Exception in getSongTags %s" %e,0) + utils.logMsg("Exception in getSongTags", str(e),0) rating = None #remove tempfile if needed.... diff --git a/resources/lib/read_embyserver.py b/resources/lib/read_embyserver.py index d92d05c7..9f907e73 100644 --- a/resources/lib/read_embyserver.py +++ b/resources/lib/read_embyserver.py @@ -262,14 +262,14 @@ class Read_EmbyServer(): retry = 0 while utils.window('emby_online') != "true": # Wait server to come back online - if retry == 3: + if retry == 5: log("Unable to reconnect to server. Abort process.", 1) - return + return items retry += 1 if xbmc.Monitor().waitForAbort(1): # Abort was requested while waiting. - return + return items else: # Request succeeded index += jump @@ -321,18 +321,18 @@ class Read_EmbyServer(): # Filter view types continue - # 11/10/2015 Review key, when it's added to server. Currently unavailable. - itemtype = item.get('OriginalCollectionType', item.get('CollectionType')) + # 3/4/2016 OriginalCollectionType is added + itemtype = item.get('OriginalCollectionType', item.get('CollectionType', "mixed")) # 11/29/2015 Remove this once OriginalCollectionType is added to stable server. # Assumed missing is mixed then. - if itemtype is None: + '''if itemtype is None: url = "{server}/emby/Library/MediaFolders?format=json" result = doUtils(url) for folder in result['Items']: if itemId == folder['Id']: - itemtype = folder.get('CollectionType', "mixed") + itemtype = folder.get('CollectionType', "mixed")''' if name not in ('Collections', 'Trailers'):