diff --git a/resources/lib/entrypoint.py b/resources/lib/entrypoint.py index 3675f718..0bad6244 100644 --- a/resources/lib/entrypoint.py +++ b/resources/lib/entrypoint.py @@ -30,7 +30,7 @@ import playbackutils as pbutils import playutils import api from views import Playlist, VideoNodes -from utils import window, settings, dialog, language as lang +from utils import window, settings, dialog, language as lang, plugin_path ################################################################################################# @@ -85,7 +85,7 @@ def doMainListing(): ''' if path: - if xbmc.getCondVisibility("Window.IsActive(Pictures)") and node == "photos": + if xbmc.getCondVisibility("Window.IsActive(Pictures)") and node in ("photos", "homevideos"): addDirectoryItem(label, path) elif xbmc.getCondVisibility("Window.IsActive(Videos)") and node != "photos": addDirectoryItem(label, path) @@ -620,11 +620,8 @@ def BrowseContent(viewname, browse_type="", folderid=""): #only proceed if we have a folderid if folderid: if browse_type.lower() == "homevideos": - xbmcplugin.setContent(int(sys.argv[1]), 'episodes') - itemtype = "Video,Folder,PhotoAlbum" - elif browse_type.lower() == "photos": xbmcplugin.setContent(int(sys.argv[1]), 'files') - itemtype = "Photo,PhotoAlbum,Folder" + itemtype = "Video,Folder,PhotoAlbum,Photo" else: itemtype = "" @@ -653,7 +650,14 @@ def BrowseContent(viewname, browse_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].decode('utf-8'), viewname.decode('utf-8'), browse_type.decode('utf-8'), item.get("Id").decode('utf-8')) + params = { + + 'id': viewname.encode('utf-8'), + 'mode': "browsecontent", + 'type': browse_type, + 'folderid': item['Id'] + } + path = plugin_path("plugin://plugin.video.emby/", params) xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=path, listitem=li, isFolder=True) else: #playable item, set plugin path and mediastreams diff --git a/resources/lib/objects/tvshows.py b/resources/lib/objects/tvshows.py index 826bf806..43707252 100644 --- a/resources/lib/objects/tvshows.py +++ b/resources/lib/objects/tvshows.py @@ -3,14 +3,13 @@ ################################################################################################## import logging -import urllib from ntpath import dirname import api import embydb_functions as embydb import _kodi_tvshows from _common import Items, catch_except -from utils import window, settings, language as lang +from utils import window, settings, language as lang, plugin_path ################################################################################################## @@ -630,7 +629,7 @@ class TVShows(Items): 'dbid': episodeid, 'mode': "play" } - filename = "%s?%s" % (path, urllib.urlencode(params)) + filename = plugin_path(path, params) ##### UPDATE THE EPISODE ##### if update_item: diff --git a/resources/lib/utils.py b/resources/lib/utils.py index 335616fa..71e5922c 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -10,6 +10,7 @@ import StringIO import os import sys import time +import urllib import unicodedata import xml.etree.ElementTree as etree from datetime import datetime @@ -77,6 +78,9 @@ def dialog(type_, *args, **kwargs): } return types[type_](*args, **kwargs) +def plugin_path(plugin, params): + return "%s?%s" % (plugin, urllib.urlencode(params)) + class JSONRPC(object): diff --git a/resources/lib/views.py b/resources/lib/views.py index bc120c66..63fb5039 100644 --- a/resources/lib/views.py +++ b/resources/lib/views.py @@ -14,7 +14,7 @@ import xbmcvfs import read_embyserver as embyserver import embydb_functions as embydb -from utils import window, language as lang, indent as xml_indent +from utils import window, language as lang, indent as xml_indent, plugin_path ################################################################################################# @@ -635,22 +635,50 @@ class VideoNodes(object): # Set window properties if (mediatype == "homevideos" or mediatype == "photos") and nodetype == "all": - # Custom query - path = ("plugin://plugin.video.emby/?id=%s&mode=browsecontent&type=%s" - % (tagname, mediatype)) + params = { + + 'id': tagname.encode('utf-8'), + 'mode': "browsecontent", + 'type': mediatype + } + path = plugin_path("plugin://plugin.video.emby/", params) + elif (mediatype == "homevideos" or mediatype == "photos"): - # Custom query - path = ("plugin://plugin.video.emby/?id=%s&mode=browsecontent&type=%s&folderid=%s" - % (tagname, mediatype, nodetype)) + params = { + + 'id': tagname.encode('utf-8'), + 'mode': "browsecontent", + 'type': mediatype, + 'folderid': nodetype + } + path = plugin_path("plugin://plugin.video.emby/", params) + elif nodetype == "nextepisodes": - # Custom query - path = "plugin://plugin.video.emby/?id=%s&mode=nextup&limit=25" % tagname + params = { + + 'id': tagname.encode('utf-8'), + 'mode': "nextup", + 'limit': 25 + } + path = plugin_path("plugin://plugin.video.emby/", params) + elif KODI == 14 and nodetype == "recentepisodes": - # Custom query - path = "plugin://plugin.video.emby/?id=%s&mode=recentepisodes&limit=25" % tagname + params = { + + 'id': tagname.encode('utf-8'), + 'mode': "recentepisodes", + 'limit': 25 + } + path = plugin_path("plugin://plugin.video.emby/", params) + elif KODI == 14 and nodetype == "inprogressepisodes": - # Custom query - path = "plugin://plugin.video.emby/?id=%s&mode=inprogressepisodes&limit=25"% tagname + params = { + + 'id': tagname.encode('utf-8'), + 'mode': "inprogressepisodes", + 'limit': 25 + } + path = plugin_path("plugin://plugin.video.emby/", params) else: path = "library://video/emby/%s/%s.xml" % (viewid, nodetype)