def Start(): # # make this plugin show up in the 'Video' section # # in Plex. The L() function pulls the string out of the strings # # file in the Contents/Strings/ folder in the bundle # # see also: # # http://dev.plexapp.com/docs/mod_Plugin.html # # http://dev.plexapp.com/docs/Bundle.html#the-strings-directory Plugin.AddPrefixHandler(VIDEO_PREFIX, MainMenu, NAME, ICON, ART) Plugin.AddViewGroup("InfoList", viewMode="InfoList", mediaType="items") Plugin.AddViewGroup("List", viewMode="List", mediaType="items") # # set some defaults so that you don't have to # # pass these parameters to these object types # # every single time # # see also: # # http://dev.plexapp.com/docs/Objects.html MediaContainer.title1 = NAME MediaContainer.viewGroup = "List" MediaContainer.art = Resource.Load(ART) DirectoryItem.thumb = Resource.Load(ICON) VideoItem.thumb = Resource.Load(ICON) HTTP.CacheTime = CACHE_1HOUR check_login_token()
def __handleInternalRequest(pathNouns, _path, **kwargs): # # Handle a request internally # if len(pathNouns) > 1: if pathNouns[1] == "resources": if len(pathNouns) == 3: ext = pathNouns[2][pathNouns[2].rfind("."):] PMS.Log("(Framework) Getting resource named '%s'" % pathNouns[2]) resource = Resource.Load(pathNouns[2]) return Objects.DataObject(resource, Resource.MimeTypeForExtension(ext)) if pathNouns[1] == "sharedresources": if len(pathNouns) == 3: ext = pathNouns[2][pathNouns[2].rfind("."):] PMS.Log("(Framework) Getting shared resource named '%s'" % pathNouns[2]) resource = Resource.LoadShared(pathNouns[2]) return Objects.DataObject(resource, Resource.MimeTypeForExtension(ext)) elif pathNouns[1] == "function" and len(pathNouns) >= 3: name = pathNouns[2] pos = name.rfind(".") if pos > -1: name = name[:pos] PMS.Log(name) if name not in __reservedFunctionNames: if len(pathNouns) == 4: kwargs['query'] = pathNouns[3] result = __callNamed(name, **kwargs) #PMS.Log(result) return result elif pathNouns[1] == "prefs": if len(pathNouns) == 2: return Prefs.__container() else: Prefs.__setAll(kwargs) result = __callNamed("ValidatePrefs", addToLog=False) if result: return result else: return ''
def __handleInternalRequest(pathNouns, path, **kwargs): # # Handle a request internally # if len(pathNouns) > 1: if pathNouns[1] == "resources": if len(pathNouns) == 3: if Resource.__publicResources.has_key(pathNouns[2]): PMS.Log("(Framework) Getting resource named '%s'" % pathNouns[2]) resource = Resource.Load(pathNouns[2]) return Objects.DataObject( resource, Resource.__publicResources[pathNouns[2]]) if pathNouns[1] == "sharedresources": if len(pathNouns) == 3: if Resource.__publicSharedResources.has_key(pathNouns[2]): PMS.Log("(Framework) Getting shared resource named '%s'" % pathNouns[2]) resource = Resource.LoadShared(pathNouns[2]) return Objects.DataObject( resource, Resource.__publicSharedResources[pathNouns[2]]) elif pathNouns[1] == "function" and len(pathNouns) >= 4: name = pathNouns[2] if name not in __reservedFunctionNames: encodedArgs = pathNouns[3] pos = encodedArgs.rfind(".") if pos > -1: encodedArgs = encodedArgs[:pos] fkwargs = pickle.loads(D(encodedArgs)) # Override encoded kwargs with kwargs passed in the URL for key in kwargs: fkwargs[key] = kwargs[key] if len(pathNouns) == 4: return __callNamed(name, **fkwargs) elif len(pathNouns) == 5: return __callNamed(name, query=pathNouns[4], **fkwargs) elif pathNouns[1] == "prefs": if len(pathNouns) == 2: return Prefs.__container() else: Prefs.__setAll(kwargs) return __callNamed("ValidatePrefs", addToLog=False)