Beispiel #1
0
    def __init__(self):
        
        utils.logMsg('started loading pluginentry')
        
        #get params
        action = None
        params = urlparse.parse_qs(sys.argv[2][1:].decode("utf-8"))
        utils.logMsg("Parameter string: %s" % sys.argv[2])
        
        if params:        
            path=params.get("path",None)
            if path: path = path[0]
            limit=params.get("limit",None)
            if limit: limit = int(limit[0])
            else: limit = 25
            action=params.get("action",None)
            if action: action = action[0].upper()
        
        if action:
            if action == "LAUNCHPVR":
                xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem())
                xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "id": 0, "method": "Player.Open", "params": { "item": {"channelid": %d} } }' %int(path))
            if action == "PLAYRECORDING":
                xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem())
                #retrieve the recording and play as listitem to get resume working
                json_result = utils.getJSON('PVR.GetRecordingDetails', '{"recordingid": %d, "properties": [ %s ]}' %(int(path),plugincontent.fields_pvrrecordings))
                if json_result:
                    xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "recordingid": %d } }, "id": 1 }' % int(path))
                    if json_result["resume"].get("position"):
                        for i in range(25):
                            if xbmc.getCondVisibility("Player.HasVideo"):
                                break
                            xbmc.sleep(250)
                        xbmc.Player().seekTime(json_result["resume"].get("position"))
            elif action == "LAUNCH":
                xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem())
                path = sys.argv[2].split("&path=")[1]
                xbmc.executebuiltin("Action(Close)")
                xbmc.executebuiltin(path)
            elif action == "PLAYALBUM":
                xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem())
                xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "albumid": %d } }, "id": 1 }' % int(path))
            elif action == "SMARTSHORTCUTS":
                skinshortcuts.getSmartShortcuts(path)
            elif action == "BACKGROUNDS":
                skinshortcuts.getBackgrounds()
            elif action == "WIDGETS":
                skinshortcuts.getWidgets(path)
            elif action == "GETTHUMB":
                plugincontent.getThumb(path)
            elif action == "EXTRAFANART":
                plugincontent.getExtraFanArt(path)
            elif action == "GETCAST":
                movie=params.get("movie",None)
                if movie: movie = movie[0]
                tvshow=params.get("tvshow",None)
                if tvshow: tvshow = tvshow[0]
                movieset=params.get("movieset",None)
                if movieset: movieset = movieset[0]
                episode=params.get("episode",None)
                if episode: episode = episode[0]
                downloadthumbs=params.get("downloadthumbs",False)
                if downloadthumbs: downloadthumbs = downloadthumbs[0]=="true"
                plugincontent.getCast(movie,tvshow,movieset,episode,downloadthumbs)
            else:
                #get a widget listing
                refresh=params.get("reload",None)
                if refresh: refresh = refresh[0].upper()
                optionalParam = None
                imdbid=params.get("imdbid","")
                if imdbid: optionalParam = imdbid[0]
                genre=params.get("genre","")
                if genre: optionalParam = genre[0]
                browse=params.get("browse","")
                if browse: optionalParam = browse[0]
                reversed=params.get("reversed","")
                if reversed: optionalParam = reversed[0]
                type=params.get("type","")
                if type: optionalParam = type[0]
                name=params.get("name","")
                if name: optionalParam = name[0]
                randomize=params.get("randomize","")
                if randomize: randomize = randomize[0]
                randomize = randomize == "true"
                plugincontent.getPluginListing(action,limit,refresh,optionalParam,randomize)

        else:
            #do plugin main listing...
            plugincontent.doMainListing(params.get("content_type",[""])[0])
    def __init__(self):
        
        utils.logMsg('started loading pluginentry')
        
        #get params
        action = None
        params = urlparse.parse_qs(sys.argv[2][1:].decode("utf-8"))
        utils.logMsg("Parameter string: %s" % sys.argv[2])
        
        if params:        
            path=params.get("path",None)
            if path: path = path[0]
            limit=params.get("limit",None)
            if limit: limit = int(limit[0])
            else: limit = 25
            action=params.get("action",None)
            if action: action = action[0].upper()
        
        if action:
            if action == "LAUNCHPVR":
                xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem())
                xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "id": 0, "method": "Player.Open", "params": { "item": {"channelid": %d} } }' %int(path))
            if action == "PLAYRECORDING":
                xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem())
                #retrieve the recording and play as listitem to get resume working
                json_result = utils.getJSON('PVR.GetRecordingDetails', '{"recordingid": %d, "properties": [ %s ]}' %(int(path),plugincontent.fields_pvrrecordings))
                if json_result:
                    xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "recordingid": %d } }, "id": 1 }' % int(path))
                    if json_result["resume"].get("position"):
                        for i in range(25):
                            if xbmc.getCondVisibility("Player.HasVideo"):
                                break
                            xbmc.sleep(250)
                        xbmc.Player().seekTime(json_result["resume"].get("position"))
            elif action == "LAUNCH":
                xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem())
                path = sys.argv[2].split("&path=")[1]
                xbmc.sleep(150)
                xbmc.executebuiltin(path)
            elif action == "PLAYALBUM":
                xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem())
                xbmc.sleep(150)
                xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "albumid": %d } }, "id": 1 }' % int(path))
            elif action == "SMARTSHORTCUTS":
                skinshortcuts.getSmartShortcuts(path)
            elif action == "BACKGROUNDS":
                skinshortcuts.getBackgrounds()
            elif action == "WIDGETS":
                skinshortcuts.getWidgets(path)
            elif action == "GETTHUMB":
                plugincontent.getThumb(path)
            elif action == "EXTRAFANART":
                plugincontent.getExtraFanArt(path)
            elif action == "GETCAST":
                movie=params.get("movie",None)
                if movie: movie = movie[0]
                tvshow=params.get("tvshow",None)
                if tvshow: tvshow = tvshow[0]
                movieset=params.get("movieset",None)
                if movieset: movieset = movieset[0]
                episode=params.get("episode",None)
                if episode: episode = episode[0]
                downloadthumbs=params.get("downloadthumbs",False)
                if downloadthumbs: downloadthumbs = downloadthumbs[0]=="true"
                plugincontent.getCast(movie,tvshow,movieset,episode,downloadthumbs)
            elif action == "ALPHABET":
                allLetters = []
                if xbmc.getInfoLabel("Container.NumItems"):
                    for i in range(int(xbmc.getInfoLabel("Container.NumItems"))):
                        allLetters.append(xbmc.getInfoLabel("Listitem(%s).SortLetter"%i).upper())
                    
                    startNumber = ""
                    for number in ["2","3","4","5","6","7","8","9"]:
                        if number in allLetters:
                            startNumber = number
                            break
                    
                    for letter in [startNumber,"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]:
                        if letter == startNumber:
                            label = "#"
                        else: label = letter
                        li = xbmcgui.ListItem(label=label)
                        if not letter in allLetters:
                            path = "noop"
                            li.setProperty("NotAvailable","true")
                        else:
                            path = "plugin://script.skin.helper.service/?action=alphabetletter&letter=%s" %letter
                        xbmcplugin.addDirectoryItem(int(sys.argv[1]), path, li)
                xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
            elif action == "ALPHABETLETTER":
                letter=params.get("letter",None)
                if letter: 
                    letter = letter[0]
                    if letter in ["A", "B", "C", "2"]:
                        jumpcmd = "2"
                    elif letter in ["D", "E", "F", "3"]:
                        jumpcmd = "3"
                    elif letter in ["G", "H", "I", "4"]:
                        jumpcmd = "4"
                    elif letter in ["J", "K", "L", "5"]:
                        jumpcmd = "5"
                    elif letter in ["M", "N", "O", "6"]:
                        jumpcmd = "6"
                    elif letter in ["P", "Q", "R", "S", "7"]:
                        jumpcmd = "7"
                    elif letter in ["T", "U", "V", "8"]:
                        jumpcmd = "8"
                    elif letter in ["W", "X", "Y", "Z", "9"]:
                        jumpcmd = "9"
                    else:
                        return

                    xbmc.executebuiltin("SetFocus(50)")
                    for i in range(6):
                        xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Input.ExecuteAction", "params": { "action": "jumpsms%s" }, "id": 1 }' % (jumpcmd))
                        xbmc.sleep(50)
                        if xbmc.getInfoLabel("ListItem.Sortletter").upper() == letter:
                            break

            else:
                #get a widget listing
                refresh=params.get("reload",None)
                if refresh: refresh = refresh[0].upper()
                optionalParam = None
                imdbid=params.get("imdbid","")
                if imdbid: optionalParam = imdbid[0]
                genre=params.get("genre","")
                if genre: optionalParam = genre[0]
                browse=params.get("browse","")
                if browse: optionalParam = browse[0]
                reversed=params.get("reversed","")
                if reversed: optionalParam = reversed[0]
                type=params.get("type","")
                if type: optionalParam = type[0]
                name=params.get("name","")
                if name: optionalParam = name[0]
                randomize=params.get("randomize","")
                if randomize: randomize = randomize[0]
                randomize = randomize == "true"
                plugincontent.getPluginListing(action,limit,refresh,optionalParam,randomize)

        else:
            #do plugin main listing...
            plugincontent.doMainListing()
Beispiel #3
0
    def __init__(self):
        
        utils.logMsg('started loading script entry')
        params = self.getParams()
        
        if params:
            action = params.get("ACTION","").upper()

            if action =="ADDSHORTCUT":
                mainmodule.addShortcutWorkAround()
            
            elif action == "MUSICSEARCH":
                mainmodule.musicSearch()
            
            elif action == "SETVIEW":
                mainmodule.setView()
            
            elif action == "SEARCHYOUTUBE":
                title = params.get("TITLE",None)
                windowHeader = params.get("HEADER","")
                autoplay = params.get("AUTOPLAY","")
                windowed = params.get("WINDOWED","")
                mainmodule.searchYouTube(title,windowHeader,autoplay,windowed)
            
            elif action == "SETFOCUS":
                control = params.get("CONTROL",None)
                xbmc.sleep(50)
                xbmc.executebuiltin("Control.SetFocus(%s)"%control)
            
            elif action == "SETFORCEDVIEW":
                contenttype = params.get("CONTENTTYPE",None)
                mainmodule.setForcedView(contenttype)
                
            elif action == "SETSKINSETTING":
                setting = params.get("SETTING","")
                windowHeader = params.get("HEADER","")
                mainmodule.setSkinSetting(setting,windowHeader)
                
            elif action == "SETSKINCONSTANT":
                setting = params.get("SETTING","")
                windowHeader = params.get("HEADER","")
                mainmodule.setSkinConstant(setting,windowHeader)
                
            elif action == "SETSKINSHORTCUTSPROPERTY":
                setting = params.get("SETTING","")
                windowHeader = params.get("HEADER","")
                property = params.get("PROPERTY","")
                mainmodule.setSkinShortCutsProperty(setting,windowHeader,property)
            
            elif action == "TOGGLEKODISETTING":
                kodisetting = params.get("SETTING")
                mainmodule.toggleKodiSetting(kodisetting)
            
            elif action == "ENABLEVIEWS":
                mainmodule.enableViews()
                
            elif action == "SPLASHSCREEN":
                file = params.get("FILE","")
                duration = params.get("DURATION","")
                if duration:
                    mainmodule.show_splash(file,int(duration))
                else:
                    mainmodule.show_splash(file)
            
            elif action == "VIDEOSEARCH":
                from resources.lib.SearchDialog import SearchDialog
                searchDialog = SearchDialog("script-skin_helper_service-CustomSearch.xml", utils.ADDON_PATH, "Default", "1080i")
                searchDialog.doModal()
                resultAction = searchDialog.action
                del searchDialog
                if resultAction:
                    if "jsonrpc" in resultAction:
                        xbmc.executeJSONRPC(resultAction)
                    else:
                        xbmc.executebuiltin(resultAction)
            
            elif action == "SHOWINFO":
                xbmc.executebuiltin( "ActivateWindow(busydialog)" )
                from resources.lib.InfoDialog import GUI
                item = None
                if params.get("MOVIEID"):
                    item = utils.getJSON('VideoLibrary.GetMovieDetails', '{ "movieid": %s, "properties": [ %s ] }' %(params.get("MOVIEID"),utils.fields_movies))
                    content = "movies"
                elif params.get("EPISODEID"):
                    item = utils.getJSON('VideoLibrary.GetEpisodeDetails', '{ "episodeid": %s, "properties": [ %s ] }' %(params.get("EPISODEID"),utils.fields_episodes))
                    content = "episodes"
                elif params.get("TVSHOWID"):
                    item = utils.getJSON('VideoLibrary.GetTVShowDetails', '{ "tvshowid": %s, "properties": [ %s ] }' %(params.get("TVSHOWID"),utils.fields_tvshows))
                    content = "tvshows"
                if item:
                    liz = utils.prepareListItem(item)
                    liz = utils.createListItem(item)
                    liz.setProperty("json",repr(item))
                    info_dialog = GUI( "script-skin_helper_service-CustomInfo.xml" , utils.ADDON_PATH, "Default", "1080i", listitem=liz, content=content )
                    info_dialog.doModal()
                    resultAction = info_dialog.action
                    del info_dialog
                    if resultAction:
                        if "jsonrpc" in resultAction:
                            xbmc.executeJSONRPC(resultAction)
                        else:
                            xbmc.executebuiltin(resultAction)
                xbmc.executebuiltin( "Dialog.Close(busydialog)" )
            
            elif action == "COLORPICKER":
                from resources.lib.ColorPicker import ColorPicker
                colorPicker = ColorPicker("script-skin_helper_service-ColorPicker.xml", utils.ADDON_PATH, "Default", "1080i")
                colorPicker.skinString = params.get("SKINSTRING","")
                colorPicker.winProperty = params.get("WINPROPERTY","")
                colorPicker.activePalette = params.get("PALETTE","")
                colorPicker.headerLabel = params.get("HEADER","")
                propname = params.get("SHORTCUTPROPERTY","")
                colorPicker.shortcutProperty = propname
                colorPicker.doModal()
                if propname and not isinstance(colorPicker.result, int):
                    mainmodule.waitForSkinShortcutsWindow()
                    xbmc.sleep(400)
                    currentWindow = xbmcgui.Window( xbmcgui.getCurrentWindowDialogId() )
                    currentWindow.setProperty("customProperty",propname)
                    currentWindow.setProperty("customValue",colorPicker.result[0])
                    xbmc.executebuiltin("SendClick(404)")
                    xbmc.sleep(250)
                    currentWindow.setProperty("customProperty",propname+".name")
                    currentWindow.setProperty("customValue",colorPicker.result[1])
                    xbmc.executebuiltin("SendClick(404)")
                del colorPicker
            
            elif action == "COLORTHEMES":
                from resources.lib.ColorThemes import ColorThemes
                colorThemes = ColorThemes("DialogSelect.xml", utils.ADDON_PATH)
                colorThemes.daynight = params.get("DAYNIGHT",None)
                colorThemes.doModal()
                del colorThemes
            
            elif action == "CONDITIONALBACKGROUNDS":
                from resources.lib.ConditionalBackgrounds import ConditionalBackgrounds
                conditionalBackgrounds = ConditionalBackgrounds("DialogSelect.xml", utils.ADDON_PATH)
                conditionalBackgrounds.doModal()
                del conditionalBackgrounds
            
            elif action == "CREATECOLORTHEME":
                import resources.lib.ColorThemes as colorThemes
                colorThemes.createColorTheme()
            
            elif action == "RESTORECOLORTHEME":
                import resources.lib.ColorThemes as colorThemes
                colorThemes.restoreColorTheme()
            
            elif action == "OVERLAYTEXTURE":    
                mainmodule.selectOverlayTexture()
            
            elif action == "BUSYTEXTURE":    
                mainmodule.selectBusyTexture()
                
            elif action == "CACHEALLMUSICART": 
                import resources.lib.ArtworkUtils as artworkutils
                artworkutils.preCacheAllMusicArt()

            elif action == "RESETCACHE":
                path = params.get("PATH")
                if path == "pvr":
                    path = utils.WINDOW.getProperty("SkinHelper.pvrthumbspath").decode("utf-8")
                    utils.WINDOW.setProperty("resetPvrArtCache","reset")
                elif path == "music":
                    path = "special://profile/addon_data/script.skin.helper.service/musicart/"
                    utils.WINDOW.setProperty("resetMusicArtCache","reset")
                elif path == "wallbackgrounds":
                    path = "special://profile/addon_data/script.skin.helper.service/wallbackgrounds/"
                    utils.WINDOW.setProperty("resetWallArtCache","reset")
                else: path = None
                
                if path:
                    success = True
                    ret = xbmcgui.Dialog().yesno(heading=utils.ADDON.getLocalizedString(32089), line1=utils.ADDON.getLocalizedString(32090)+path)
                    if ret:
                        success = utils.recursiveDelete(path)
                        if success:
                            xbmcgui.Dialog().ok(heading=utils.ADDON.getLocalizedString(32089), line1=utils.ADDON.getLocalizedString(32091))
                        else:
                            xbmcgui.Dialog().ok(heading=utils.ADDON.getLocalizedString(32089), line1=utils.ADDON.getLocalizedString(32092))
                    
            elif action == "BACKUP":
                import resources.lib.BackupRestore as backup
                filter = params.get("FILTER","")
                silent = params.get("SILENT",None)
                promptfilename = params.get("PROMPTFILENAME","false")
                backup.backup(filter,silent,promptfilename.lower())
            
            elif action == "RESTORE":
                import resources.lib.BackupRestore as backup
                silent = params.get("SILENT",None)
                backup.restore(silent)
            
            elif action == "RESET":
                import resources.lib.BackupRestore as backup
                filter = params.get("FILTER","")
                silent = params.get("SILENT","") == "true"
                backup.reset(filter,silent)
                xbmc.Monitor().waitForAbort(2)
                mainmodule.correctSkinSettings()
            
            elif action == "DIALOGOK":
                headerMsg = params.get("HEADER")
                bodyMsg = params.get("MESSAGE")
                if bodyMsg.startswith(" "): bodyMsg = bodyMsg[1:]
                if headerMsg.startswith(" "): headerMsg = headerMsg[1:]
                xbmcgui.Dialog().ok(heading=headerMsg, line1=bodyMsg)
                
            elif action == "DIALOGYESNO":
                headerMsg = params.get("HEADER")
                bodyMsg = params.get("MESSAGE")
                yesactions = params.get("YESACTION","").split("|")
                noactions = params.get("NOACTION","").split("|")
                if bodyMsg.startswith(" "): bodyMsg = bodyMsg[1:]
                if headerMsg.startswith(" "): headerMsg = headerMsg[1:]
                if xbmcgui.Dialog().yesno(heading=headerMsg, line1=bodyMsg):
                    for action in yesactions:
                        xbmc.executebuiltin(action.encode("utf-8"))
                else:
                    for action in noactions:
                        xbmc.executebuiltin(action.encode("utf-8"))
                
            elif action == "TEXTVIEWER":
                headerMsg = params.get("HEADER","")
                bodyMsg = params.get("MESSAGE","")
                if bodyMsg.startswith(" "): bodyMsg = bodyMsg[1:]
                if headerMsg.startswith(" "): headerMsg = headerMsg[1:]
                xbmcgui.Dialog().textviewer(headerMsg, bodyMsg)

            elif action == "FILEEXISTS":
                filename = params.get("FILE")
                skinstring = params.get("SKINSTRING")
                windowprop = params.get("WINDOWPROP")
                if xbmcvfs.exists(filename):
                    if windowprop:
                        utils.WINDOW.setProperty(windowprop,"exists")
                    if skinstring:
                        xbmc.executebuiltin("Skin.SetString(%s,exists)" %skinstring)
                else:
                    if windowprop:
                        utils.WINDOW.clearProperty(windowprop)
                    if skinstring:
                        xbmc.executebuiltin("Skin.Reset(%s)" %skinstring)
            
            elif action == "STRIPSTRING":
                splitchar = params.get("SPLITCHAR")
                string = params.get("STRING")
                output = params.get("OUTPUT")
                index = params.get("INDEX",0)
                string = string.split(splitchar)[int(index)]
                utils.WINDOW.setProperty(output, string)
                
            elif action == "GETPLAYERFILENAME":
                output = params.get("OUTPUT")
                filename = xbmc.getInfoLabel("Player.FileNameAndPath")
                if not filename: filename = xbmc.getInfoLabel("Player.FileName")
                if "filename=" in filename:
                    url_params = dict(urlparse.parse_qsl(filename))
                    filename = url_params.get("filename")
                utils.WINDOW.setProperty(output, filename)
                
            elif action == "GETFILENAME":
                output = params.get("OUTPUT")
                filename = xbmc.getInfoLabel("ListItem.FileNameAndPath")
                if not filename: filename = xbmc.getInfoLabel("ListItem.FileName")
                if not filename: filename = xbmc.getInfoLabel("Container(999).ListItem.FileName")
                if not filename: filename = xbmc.getInfoLabel("Container(999).ListItem.FileNameAndPath")
                if "filename=" in filename:
                    url_params = dict(urlparse.parse_qsl(filename))
                    filename = url_params.get("filename")
                utils.WINDOW.setProperty(output, filename)
                
            elif action == "CHECKRESOURCEADDONS":
                ADDONSLIST = params.get("ADDONSLIST")
                mainmodule.checkResourceAddons(ADDONSLIST)
 def __init__(self):
     
     utils.logMsg('started loading pluginentry')
     
     #get params
     params = urlparse.parse_qs(sys.argv[2][1:].decode("utf-8"))
     utils.logMsg("Parameter string: %s" % sys.argv[2])
     
     if params:        
         path=params.get("path",None)
         if path: path = path[0]
         limit=params.get("limit",None)
         if limit: limit = int(limit[0])
         else: limit = 25
         action=params.get("action",None)
         if action: action = action[0].upper()
     
         if action:
             if action == "LAUNCHPVR":
                 xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "id": 0, "method": "Player.Open", "params": { "item": {"channelid": %d} } }' %int(path))
                 xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem())
             if action == "PLAYRECORDING":
                 #retrieve the recording and play as listitem to get resume working
                 json_result = utils.getJSON('PVR.GetRecordingDetails', '{"recordingid": %d, "properties": [ %s ]}' %(int(path),plugincontent.fields_pvrrecordings))
                 if json_result:
                     xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "recordingid": %d } }, "id": 1 }' % int(path))
                     if json_result["resume"].get("position"):
                         for i in range(25):
                             if xbmc.getCondVisibility("Player.HasVideo"):
                                 break
                             xbmc.sleep(250)
                         xbmc.Player().seekTime(json_result["resume"].get("position"))
                 xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem())
             elif action == "LAUNCH":
                 path = sys.argv[2].split("&path=")[1]
                 xbmc.executebuiltin("Action(Close)")
                 xbmc.executebuiltin(path)
                 xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem())
             elif action == "PLAYALBUM":
                 xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "albumid": %d } }, "id": 1 }' % int(path))
                 xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem())
             elif action == "SMARTSHORTCUTS":
                 skinshortcuts.getSmartShortcuts(path)
             elif action == "BACKGROUNDS":
                 skinshortcuts.getBackgrounds()
             elif action == "WIDGETS":
                 skinshortcuts.getWidgets(path)
             elif action == "GETTHUMB":
                 plugincontent.getThumb(path)
             elif action == "EXTRAFANART":
                 plugincontent.getExtraFanArt(path)
             elif action == "GETCAST":
                 movie=params.get("movie",None)
                 if movie: movie = movie[0]
                 tvshow=params.get("tvshow",None)
                 if tvshow: tvshow = tvshow[0]
                 movieset=params.get("movieset",None)
                 if movieset: movieset = movieset[0]
                 episode=params.get("episode",None)
                 if episode: episode = episode[0]
                 downloadthumbs=params.get("downloadthumbs",False)
                 if downloadthumbs: downloadthumbs = downloadthumbs[0]=="true"
                 plugincontent.getCast(movie,tvshow,movieset,episode,downloadthumbs)
             else:
                 #get a widget listing
                 refresh=params.get("reload",None)
                 if refresh: refresh = refresh[0].upper()
                 optionalParam = None
                 imdbid=params.get("imdbid","")
                 if imdbid: optionalParam = imdbid[0]
                 genre=params.get("genre","")
                 if genre: optionalParam = genre[0]
                 browse=params.get("browse","")
                 if browse: optionalParam = browse[0]
                 reversed=params.get("reversed","")
                 if reversed: optionalParam = reversed[0]
                 name=params.get("name","")
                 if name: optionalParam = name[0]
                 randomize=params.get("randomize","")
                 if randomize: randomize = randomize[0]
                 randomize = randomize == "true"
                 plugincontent.getPluginListing(action,limit,refresh,optionalParam,randomize)
 
     else:
         #do plugin main listing...
         plugincontent.doMainListing()
Beispiel #5
0
    def create_cache(self):
        updateActorMovie = None
        updateActorTvShow = None
        updateDirectorMovie = None
        #--- ---------------CACHE ----------------------------------------------
        Titre = None
        self.dp = None

        self.GlobalCache = utils.GetCache(None, cache_path + "total")
        if self.check_update(
                WINDOW.getProperty("Movies.count"),
                "films") or not xbmcvfs.exists(cache_path +
                                               "films") or self.PurgeCache:
            self.dpupdate(0, "Films")
            json_result = utils.getJSON("VideoLibrary.GetMovies",
                                        '{"properties":["setid"]}')
            self.Data["resultats"] = json_result
            utils.SaveFile(cache_path + "films", self.Data)
            self.GlobalCache["films"] = self.Data.get("total")
            updateActorMovie = True

        if self.check_update(
                WINDOW.getProperty("TVShows.count"),
                "tvshows") or not xbmcvfs.exists(cache_path +
                                                 "tvshows") or self.PurgeCache:
            self.dpupdate(16, "tvshows")
            json_result = utils.getJSON("VideoLibrary.GetTvShows",
                                        '{"properties":["episode"]}')
            self.Data["resultats"] = json_result
            utils.SaveFile(cache_path + "tvshows", self.Data)
            self.GlobalCache["tvshows"] = self.Data.get("total")
            updateActorTvShow = True

        if self.check_update(
                WINDOW.getProperty("Episodes.count"), "episodes"
        ) or not xbmcvfs.exists(cache_path + "episodes") or self.PurgeCache:
            self.dpupdate(32, "Episodes")
            json_result = utils.getJSON("VideoLibrary.GetEpisodes",
                                        '{"properties":["tvshowid"]}')
            self.Data["resultats"] = json_result
            utils.SaveFile(cache_path + "episodes", self.Data)
            self.GlobalCache["episodes"] = self.Data.get("total")

        ListeActors = []
        if updateActorMovie or not xbmcvfs.exists(
                cache_path + "acteurs") or self.PurgeCache:
            self.dpupdate(48, "Acteurs")
            json_result = utils.getJSON(
                "Files.GetDirectory",
                '{"directory":"videodb://movies/actors"}')

            if json_result:
                for item in json_result:
                    ListeActors.append({
                        "actormovieid": item.get("id"),
                        "label": item["label"]
                    })
                self.GlobalCache["actormovie"] = len(ListeActors)

        if updateActorTvShow or not xbmcvfs.exists(
                cache_path + "acteurs") or self.PurgeCache:
            self.dpupdate(58, "Acteurs")
            json_result = utils.getJSON(
                "Files.GetDirectory",
                '{"directory":"videodb://tvshows/actors"}')
            if json_result:
                for item in json_result:
                    ListeActors.append({
                        "actortvshowid": item.get("id"),
                        "label": item["label"]
                    })
                self.GlobalCache["actortv"] = len(ListeActors)
            self.Data["resultats"] = ListeActors
            utils.SaveFile(cache_path + "acteurs", self.Data)
        Listedirectors = []
        if updateActorMovie or not xbmcvfs.exists(
                cache_path + "realisateurs") or self.PurgeCache:
            self.dpupdate(64, "Realisateurs")
            json_result = utils.getJSON(
                "Files.GetDirectory",
                '{"directory":"videodb://movies/directors"}')

            if json_result:
                for item in json_result:
                    Listedirectors.append({
                        "directormovieid": item.get("id"),
                        "label": item["label"]
                    })
                self.GlobalCache["directormovie"] = len(Listedirectors)

        if updateActorTvShow or not xbmcvfs.exists(
                cache_path + "realisateurs") or self.PurgeCache:
            json_result = utils.getJSON(
                "Files.GetDirectory",
                '{"directory":"videodb://tvshows/directors"}')
            if json_result:
                for item in json_result:
                    Listedirectors.append({
                        "directortvshowid": item.get("id"),
                        "label": item["label"]
                    })
                self.GlobalCache["directortv"] = len(Listedirectors)
            self.Data["resultats"] = Listedirectors
            utils.SaveFile(cache_path + "realisateurs", self.Data)

        if self.check_update(
                WINDOW.getProperty("Music.Artistscount"), "artistes"
        ) or not xbmcvfs.exists(cache_path + "artistes") or self.PurgeCache:
            self.dpupdate(80, "Artistes")
            json_result = utils.getJSON("AudioLibrary.GetArtists", '{}')
            self.Data["resultats"] = json_result
            utils.SaveFile(cache_path + "artistes", self.Data)
            self.GlobalCache["artistes"] = self.Data.get("total")

        if self.check_update(
                WINDOW.getProperty("Music.Albumscount"),
                "albums") or not xbmcvfs.exists(cache_path +
                                                "albums") or self.PurgeCache:
            self.dpupdate(96, "Albums")
            json_result = utils.getJSON("AudioLibrary.GetAlbums",
                                        '{"properties":["artistid"]}')
            self.Data["resultats"] = json_result
            utils.SaveFile(cache_path + "albums", self.Data)
            self.GlobalCache["albums"] = self.Data.get("total")

        if (xbmc.getCondVisibility("Window.IsVisible(10040)") and
                not xbmcvfs.exists(cache_path + "addons")) or self.PurgeCache:
            self.dpupdate(99, "Addons")
            json_result = utils.getJSON("Addons.GetAddons",
                                        '{"properties":["name"]}')
            Listeaddons = []
            if json_result:
                for item in json_result:
                    Listeaddons.append({
                        "addonid": item.get("addonid"),
                        "label": item["name"],
                        "type": item["type"]
                    })
            self.Data["resultats"] = Listeaddons
            utils.SaveFile(cache_path + "addons", self.Data)
            self.GlobalCache["addons"] = len(Listeaddons)

        GlobalSave = {}
        GlobalSave["resultats"] = self.GlobalCache
        utils.SaveFile(cache_path + "total", GlobalSave)
        self.PurgeCache = None

        if self.dp:
            self.dp.close()
Beispiel #6
0
    def __init__(self):

        utils.logMsg('started loading pluginentry')

        #get params
        action = None
        params = urlparse.parse_qs(sys.argv[2][1:].decode("utf-8"))
        utils.logMsg("Parameter string: %s" % sys.argv[2])

        if params:
            path = params.get("path", None)
            if path: path = path[0]
            limit = params.get("limit", None)
            if limit: limit = int(limit[0])
            else: limit = 25
            action = params.get("action", None)
            if action: action = action[0].upper()

        if action:
            if action == "LAUNCHPVR":
                xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]),
                                          succeeded=False,
                                          listitem=xbmcgui.ListItem())
                xbmc.executeJSONRPC(
                    '{ "jsonrpc": "2.0", "id": 0, "method": "Player.Open", "params": { "item": {"channelid": %d} } }'
                    % int(path))
            if action == "PLAYRECORDING":
                xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]),
                                          succeeded=False,
                                          listitem=xbmcgui.ListItem())
                #retrieve the recording and play as listitem to get resume working
                json_result = utils.getJSON(
                    'PVR.GetRecordingDetails',
                    '{"recordingid": %d, "properties": [ %s ]}' %
                    (int(path), plugincontent.fields_pvrrecordings))
                if json_result:
                    xbmc.executeJSONRPC(
                        '{ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "recordingid": %d } }, "id": 1 }'
                        % int(path))
                    if json_result["resume"].get("position"):
                        for i in range(25):
                            if xbmc.getCondVisibility("Player.HasVideo"):
                                break
                            xbmc.sleep(250)
                        xbmc.Player().seekTime(
                            json_result["resume"].get("position"))
            elif action == "LAUNCH":
                xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]),
                                          succeeded=False,
                                          listitem=xbmcgui.ListItem())
                path = sys.argv[2].split("&path=")[1]
                xbmc.sleep(150)
                xbmc.executebuiltin(path)
            elif action == "PLAYALBUM":
                xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]),
                                          succeeded=False,
                                          listitem=xbmcgui.ListItem())
                xbmc.sleep(150)
                xbmc.executeJSONRPC(
                    '{ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "albumid": %d } }, "id": 1 }'
                    % int(path))
            elif action == "SMARTSHORTCUTS":
                skinshortcuts.getSmartShortcuts(path)
            elif action == "BACKGROUNDS":
                skinshortcuts.getBackgrounds()
            elif action == "WIDGETS":
                skinshortcuts.getWidgets(path)
            elif action == "GETTHUMB":
                plugincontent.getThumb(path)
            elif action == "EXTRAFANART":
                plugincontent.getExtraFanArt(path)
            elif action == "GETCAST":
                movie = params.get("movie", None)
                if movie: movie = movie[0]
                tvshow = params.get("tvshow", None)
                if tvshow: tvshow = tvshow[0]
                movieset = params.get("movieset", None)
                if movieset: movieset = movieset[0]
                episode = params.get("episode", None)
                if episode: episode = episode[0]
                downloadthumbs = params.get("downloadthumbs", False)
                if downloadthumbs: downloadthumbs = downloadthumbs[0] == "true"
                plugincontent.getCast(movie, tvshow, movieset, episode,
                                      downloadthumbs)
            elif action == "ALPHABET":
                allLetters = []
                if xbmc.getInfoLabel("Container.NumItems"):
                    for i in range(int(
                            xbmc.getInfoLabel("Container.NumItems"))):
                        allLetters.append(
                            xbmc.getInfoLabel("Listitem(%s).SortLetter" %
                                              i).upper())

                    startNumber = ""
                    for number in ["2", "3", "4", "5", "6", "7", "8", "9"]:
                        if number in allLetters:
                            startNumber = number
                            break

                    for letter in [
                            startNumber, "A", "B", "C", "D", "E", "F", "G",
                            "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q",
                            "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
                    ]:
                        if letter == startNumber:
                            label = "#"
                        else:
                            label = letter
                        li = xbmcgui.ListItem(label=label)
                        if not letter in allLetters:
                            path = "noop"
                            li.setProperty("NotAvailable", "true")
                        else:
                            path = "plugin://script.skin.helper.service/?action=alphabetletter&letter=%s" % letter
                        xbmcplugin.addDirectoryItem(int(sys.argv[1]), path, li)
                xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
            elif action == "ALPHABETLETTER":
                letter = params.get("letter", None)
                if letter:
                    letter = letter[0]
                    if letter in ["A", "B", "C", "2"]:
                        jumpcmd = "2"
                    elif letter in ["D", "E", "F", "3"]:
                        jumpcmd = "3"
                    elif letter in ["G", "H", "I", "4"]:
                        jumpcmd = "4"
                    elif letter in ["J", "K", "L", "5"]:
                        jumpcmd = "5"
                    elif letter in ["M", "N", "O", "6"]:
                        jumpcmd = "6"
                    elif letter in ["P", "Q", "R", "S", "7"]:
                        jumpcmd = "7"
                    elif letter in ["T", "U", "V", "8"]:
                        jumpcmd = "8"
                    elif letter in ["W", "X", "Y", "Z", "9"]:
                        jumpcmd = "9"
                    else:
                        return

                    xbmc.executebuiltin("SetFocus(50)")
                    for i in range(6):
                        xbmc.executeJSONRPC(
                            '{ "jsonrpc": "2.0", "method": "Input.ExecuteAction", "params": { "action": "jumpsms%s" }, "id": 1 }'
                            % (jumpcmd))
                        xbmc.sleep(50)
                        if xbmc.getInfoLabel(
                                "ListItem.Sortletter").upper() == letter:
                            break

            else:
                #get a widget listing
                refresh = params.get("reload", None)
                if refresh: refresh = refresh[0].upper()
                optionalParam = None
                imdbid = params.get("imdbid", "")
                if imdbid: optionalParam = imdbid[0]
                genre = params.get("genre", "")
                if genre: optionalParam = genre[0]
                browse = params.get("browse", "")
                if browse: optionalParam = browse[0]
                reversed = params.get("reversed", "")
                if reversed: optionalParam = reversed[0]
                type = params.get("type", "")
                if type: optionalParam = type[0]
                name = params.get("name", "")
                if name: optionalParam = name[0]
                randomize = params.get("randomize", "")
                if randomize: randomize = randomize[0]
                randomize = randomize == "true"
                plugincontent.getPluginListing(action, limit, refresh,
                                               optionalParam, randomize)

        else:
            #do plugin main listing...
            plugincontent.doMainListing()
Beispiel #7
0
    def GetTrailer(self):
        #xbmc.executebuiltin( "ActivateWindow(busydialog)" )
        self.windowhome.setProperty('FenetreListeChoix', '1')
        dialog = xbmcgui.Dialog()
        self.TrailerType = ""
        self.ListeTrailer = []
        ContainerID = None
        Saison = None
        TMDBID = ''
        TMDBIDListe = []
        PanneauActeur = None
        TMDBIDListeAllocine = []
        self.TrailerType = ""

        if self.trailerTitre:
            TypeVideo = self.trailerTypeVideo
            PanneauActeur = True
            Titre = self.trailerTitre
            Annee = self.trailerAnnee
            KODIID = self.trailerKODIID
            IMDBID = self.trailerIMDBID
            TMDBID = self.trailerTMDBID
            self.TrailerType = "dialogplus"
            if not TMDBID:
                TMDBID = utils.get_externalID(IMDBID, TypeVideo)
        else:
            TypeVideo = xbmc.getInfoLabel("ListItem.DBType")
            Annee = xbmc.getInfoLabel("ListItem.Year")
            Titre = xbmc.getInfoLabel("ListItem.Label").decode(
                'utf-8', 'ignore')
            Saison = None
            if self.windowhome.getProperty('IconmixShowInfo') == "1":
                ContainerID = 1990
            else:
                if self.windowhome.getProperty('IconmixShowInfo') == "2":
                    if not xbmc.getCondVisibility(
                            "ControlGroup(7003).HasFocus"):
                        ContainerID = 5051
                    else:
                        ContainerID = 1990
                else:
                    ContainerID = None

            if TypeVideo == "episode":
                Saison = str(xbmc.getInfoLabel("ListItem.Season"))

            if TypeVideo == "set":
                self.TrailerType = "videonavsaga"

            if xbmc.getCondVisibility("Control.HasFocus(7779)"):
                PanneauActeur = True
                TypeVideo = xbmc.getInfoLabel(
                    "Container(5051).ListItem.Property(dbtype)")
                Titre = xbmc.getInfoLabel(
                    "Container(5051).ListItem.Label").decode(
                        'utf-8', 'ignore')
                Annee = xbmc.getInfoLabel("Container(5051).ListItem.Year")
                KODIID = xbmc.getInfoLabel("Container(5051).ListItem.DBID")
                self.TrailerType = "Roles"

            if xbmc.getCondVisibility(
                    "Control.HasFocus(2999)"
            ):  #myvideonav elements (saga,acteurs,realisateurs)
                TypeVideo = xbmc.getInfoLabel(
                    "Container(1999).ListItem.DBType")
                Titre = xbmc.getInfoLabel(
                    "Container(1999).ListItem.Label").decode(
                        'utf-8', 'ignore')
                Annee = xbmc.getInfoLabel("Container(1999).ListItem.Year")
                self.TrailerType = "videonav"

            if xbmc.getCondVisibility(
                    "Control.HasFocus(2008)"):  #dialogvideoinfo
                TypeVideo = 'movie'
                Titre = xbmc.getInfoLabel(
                    "Container(5002).ListItem.Label").decode(
                        'utf-8', 'ignore')
                Annee = xbmc.getInfoLabel("Container(5002).ListItem.Year")
                self.TrailerType = "saga"
            if xbmc.getCondVisibility("ControlGroup(442).HasFocus"
                                      ):  #dialogvideoinfo cherche trailer
                logMsg("ContainerID (%s)" % (ContainerID))
                TypeVideo = xbmc.getInfoLabel(
                    "Container(%d).ListItem.DBTYPE" %
                    (ContainerID)) if ContainerID else xbmc.getInfoLabel(
                        "ListItem.DBTYPE")
                Titre = xbmc.getInfoLabel(
                    "Container(%d).ListItem.Label" %
                    (ContainerID)) if ContainerID else xbmc.getInfoLabel(
                        "ListItem.Label")
                Titre = Titre.decode('utf-8', 'ignore')
                Annee = xbmc.getInfoLabel(
                    "Container(%d).ListItem.Year" %
                    (ContainerID)) if ContainerID else xbmc.getInfoLabel(
                        "ListItem.Year")
                self.TrailerType = "videoinfo7003"
            if xbmc.getCondVisibility(
                    "Control.HasFocus(7778)"):  #dialogvideoinfo realisateur
                TypeVideo = xbmc.getInfoLabel(
                    "Container(5052).ListItem.DBTYPE")
                Titre = xbmc.getInfoLabel("Container(5052).ListItem.Label")
                Titre = Titre.decode('utf-8', 'ignore')
                Annee = xbmc.getInfoLabel("Container(5052).ListItem.Year")
                self.TrailerType = "realisateur"

            if self.TrailerType == "Roles":
                #acteurs
                IMDBID = xbmc.getInfoLabel(
                    "Container(5051).ListItem.Property(IMDBNumber)")
                TMDBID = xbmc.getInfoLabel(
                    "Container(5051).ListItem.Property(TMDBNumber)")

                if not TMDBID:
                    TMDBID = utils.get_externalID(IMDBID, TypeVideo)

            if self.TrailerType == "realisateur":
                #realisateur
                IMDBID = xbmc.getInfoLabel(
                    "Container(5052).ListItem.Property(IMDBNumber)")
                TMDBID = xbmc.getInfoLabel(
                    "Container(5052).ListItem.Property(TMDBNumber)")
                KODIID = xbmc.getInfoLabel("Container(5052).ListItem.DBID")
                PanneauActeur = True
                if not TMDBID:
                    TMDBID = utils.get_externalID(IMDBID, TypeVideo)

            if self.TrailerType == "videonav":
                #VideoNav
                IMDBID = xbmc.getInfoLabel(
                    "Container(1999).ListItem.Property(IMDBNumber)")
                TMDBID = xbmc.getInfoLabel(
                    "Container(1999).ListItem.Property(TMDBNumber)")
                KODIID = xbmc.getInfoLabel("Container(1999).ListItem.DBID")
                if not TMDBID and not IMDBID:
                    json_result = utils.getJSON(
                        'VideoLibrary.Get%sDetails' % (TypeVideo),
                        '{ "%sid":%d,"properties":["imdbnumber"] }' %
                        (TypeVideo,
                         int(xbmc.getInfoLabel(
                             "Container(1999).ListItem.DBID"))))
                    IMDBID = json_result.get("imdbnumber")
                if TMDBID == '' and IMDBID:
                    TMDBID = utils.get_externalID(IMDBID, TypeVideo)

            if self.TrailerType == "videonavsaga":
                #VideoNav
                TypeVideo = "movie"

                zz = int(xbmc.getInfoLabel("Container(1999).NumItems"))
                #logMsg("SagaType (%s)(%s)" %(zz,xbmc.getInfoLabel("Container(1999).NumItems")),0)
                compteur = 0

                for compteur in range(0, zz):
                    #SagaItem=ListeSaga.getListItem(cpt)
                    #IMDBID=SagaItem.getProperty(IMDBNumber)
                    #TMDBID=SagaItem.getProperty(TMDBNumber)
                    #DBID=SagaItem.getProperty(DBID)

                    IMDBID = xbmc.getInfoLabel(
                        "Container(1999).ListItemAbsolute(%d).Property(IMDBNumber)"
                        % (compteur))
                    TMDBID = xbmc.getInfoLabel(
                        "Container(1999).ListItemAbsolute(%d).Property(TMDBNumber)"
                        % (compteur))
                    DBID = xbmc.getInfoLabel(
                        "Container(1999).ListItemAbsolute(%d).Property(DBID)" %
                        (compteur))
                    LABEL = xbmc.getInfoLabel(
                        "Container(1999).ListItemAbsolute(%d).Label" %
                        (compteur))
                    YEAR = xbmc.getInfoLabel(
                        "Container(1999).ListItemAbsolute(%d).Year" %
                        (compteur))
                    TMDBIDListeAllocine.append({"Titre": LABEL, "Annee": YEAR})

                    #logMsg("Allocine (%d)(%s)(%s)(%s)(%s)(%s)" %(compteur,LABEL,YEAR,IMDBID,TMDBID,DBID),0)
                    if DBID:
                        if not TMDBID and not IMDBID:
                            json_result = utils.getJSON(
                                'VideoLibrary.GetMovieDetails',
                                '{ "movieid":%d,"properties":["imdbnumber"] }'
                                % (int(DBID)))
                            IMDBID = json_result.get("imdbnumber")
                        if TMDBID or IMDBID:
                            TMDBIDListe.append({
                                "tmdbid": TMDBID,
                                "imdbid": IMDBID
                            })

            if self.TrailerType == "saga":
                #SAGA
                IMDBID = xbmc.getInfoLabel(
                    "Container(5002).ListItem.Property(IMDBNumber)")
                TMDBID = xbmc.getInfoLabel(
                    "Container(5002).ListItem.Property(TMDBNumber)")
                KODIID = xbmc.getInfoLabel("Container(5002).ListItem.DBID")
                if not TMDBID and not IMDBID:
                    json_result = utils.getJSON(
                        'VideoLibrary.GetMovieDetails',
                        '{ "movieid":%d,"properties":["imdbnumber"] }' %
                        (int(xbmc.getInfoLabel(
                            "Container(5002).ListItem.DBID"))))
                    IMDBID = json_result.get("imdbnumber")

                else:
                    if not TMDBID:
                        TMDBID = utils.get_externalID(IMDBID, 'movie')

            if self.TrailerType == "videoinfo7003" or self.TrailerType == "":
                #acteurs videoinfo
                KODIID = xbmc.getInfoLabel(
                    "Container(%d).ListItem.DBID" %
                    (ContainerID)) if ContainerID else xbmc.getInfoLabel(
                        "ListItem.DBID")
                TMDBID = xbmc.getInfoLabel(
                    "Container(%d).ListItem.Property(TMDBNumber)" %
                    (ContainerID)) if ContainerID else xbmc.getInfoLabel(
                        "ListItem.Property(TMDBNumber)")
                if TypeVideo != "episode":
                    IMDBNUMBER = xbmc.getInfoLabel(
                        "Container(%d).ListItem.IMDBNumber" %
                        (ContainerID)) if ContainerID else xbmc.getInfoLabel(
                            "ListItem.IMDBNumber")
                else:
                    IMDBNUMBER = xbmc.getInfoLabel(
                        "Container(%d).ListItem.TVShowTitle" %
                        (ContainerID)) if ContainerID else xbmc.getInfoLabel(
                            "ListItem.TVShowTitle")
                    Titre = IMDBNUMBER
                if not TMDBID:
                    TMDBID = utils.get_externalID(IMDBNUMBER, TypeVideo)
                logMsg("self.TrailerType (%s) : (%s)(%s)(%s)(%s)" %
                       (Titre, IMDBNUMBER, TypeVideo, TMDBID, ContainerID))
        dialog.notification(
            'IconMixTools',
            __language__(32508) + ": [COLOR=Yellow] " + Titre + "[/COLOR]",
            ADDON_ICON, 500)
        if TMDBID != '' or len(TMDBIDListe) > 0:
            xbmc.executebuiltin("ActivateWindow(busydialog)")
            logMsg("self.TrailerType (%s) : (%s)(%s)(%s)(%s)(%s)" %
                   (self.TrailerType, Titre, TypeVideo, TMDBID, ContainerID,
                    KODIID))
            if len(TMDBIDListe) > 0:
                #logMsg("SagaType TMDBIDListe %s" %(TMDBIDListe),0)
                #start_time = time.time()
                if ADDON.getSetting('allocineactif') == "true":
                    self.ListeTrailer = self.ListeTrailer + utils.GetSagaTrailersAllocine(
                        TMDBIDListeAllocine)
                if ADDON.getSetting('youtubeactif') == "true":
                    self.ListeTrailer = self.ListeTrailer + utils.GetSagaTrailers(
                        TMDBIDListe)

            else:

                self.ListeTrailer = utils.getTrailer(TMDBID, TypeVideo, Saison)
                if not self.ListeTrailer:
                    self.ListeTrailer = []
                self.GetAllocineTrailer(Titre, Annee, TypeVideo, PanneauActeur)

            if self.TrailerType == "videonav" and KODIID != "":
                self.ListeTrailer.append({
                    "id":
                    xbmc.getInfoLabel(
                        "Container(1999).ListItem.FilenameAndPath"),
                    "position":
                    "0",
                    "iso_639_1":
                    "",
                    "iso_3166_1":
                    "",
                    "key":
                    "KODI",
                    "name":
                    xbmc.getLocalizedString(208) + "[I]" +
                    "[COLOR=LightGrey] " + xbmc.getInfoLabel(
                        "Container(1999).ListItem.Label").decode("utf8") +
                    " [/I][/COLOR]",
                    "site":
                    "YouTube",
                    "size":
                    xbmc.getInfoLabel(
                        "Container(1999).ListItem.VideoResolution"),
                    "type":
                    "",
                    "landscape":
                    xbmc.getInfoLabel("Container(1999).ListItem.Art(thumb)")
                })
            if self.TrailerType == "saga" and KODIID != "":
                self.ListeTrailer.append({
                    "id":
                    xbmc.getInfoLabel(
                        "Container(5002).ListItem.FilenameAndPath"),
                    "position":
                    "0",
                    "iso_639_1":
                    "",
                    "iso_3166_1":
                    "",
                    "key":
                    "KODI",
                    "name":
                    xbmc.getLocalizedString(208) + "[I]" +
                    "[COLOR=LightGrey] " + xbmc.getInfoLabel(
                        "Container(5002).ListItem.Label").decode("utf8") +
                    " [/I][/COLOR]",
                    "site":
                    "YouTube",
                    "size":
                    xbmc.getInfoLabel(
                        "Container(5002).ListItem.VideoResolution"),
                    "type":
                    "",
                    "landscape":
                    xbmc.getInfoLabel("Container(5002).ListItem.Art(thumb)")
                })
            if self.TrailerType == "videoinfo7003" and ContainerID and KODIID != "":
                self.ListeTrailer.append({
                    "id":
                    xbmc.getInfoLabel(
                        "Container(%d).ListItem.FilenameAndPath" %
                        (ContainerID)),
                    "position":
                    "0",
                    "iso_639_1":
                    "",
                    "iso_3166_1":
                    "",
                    "key":
                    "KODI",
                    "name":
                    xbmc.getLocalizedString(208) + "[I]" +
                    "[COLOR=LightGrey] " +
                    xbmc.getInfoLabel("Container(%d).ListItem.Label" %
                                      (ContainerID)).decode("utf8") +
                    " [/I][/COLOR]",
                    "site":
                    "YouTube",
                    "size":
                    xbmc.getInfoLabel(
                        "Container(%d).ListItem.VideoResolution" %
                        (ContainerID)),
                    "type":
                    "",
                    "landscape":
                    xbmc.getInfoLabel("Container(%d).ListItem.Art(thumb)" %
                                      (ContainerID))
                })
            if self.TrailerType == "videoinfo7003" and not ContainerID and KODIID != "":
                self.ListeTrailer.append({
                    "id":
                    xbmc.getInfoLabel("ListItem.FilenameAndPath"),
                    "position":
                    "0",
                    "iso_639_1":
                    "",
                    "iso_3166_1":
                    "",
                    "key":
                    "KODI",
                    "name":
                    xbmc.getLocalizedString(208) + "[I]" +
                    "[COLOR=LightGrey] " +
                    xbmc.getInfoLabel("ListItem.Label").decode("utf8") +
                    " [/I][/COLOR]",
                    "site":
                    "YouTube",
                    "size":
                    xbmc.getInfoLabel("ListItem.VideoResolution"),
                    "type":
                    "",
                    "landscape":
                    xbmc.getInfoLabel("ListItem.Art(thumb)")
                })
            if self.TrailerType == "Roles" and KODIID != "":
                self.ListeTrailer.append({
                    "id":
                    xbmc.getInfoLabel(
                        "Container(5051).ListItem.FilenameAndPath"),
                    "position":
                    "0",
                    "iso_639_1":
                    "",
                    "iso_3166_1":
                    "",
                    "key":
                    "KODI",
                    "name":
                    xbmc.getLocalizedString(208) + "[I]" +
                    "[COLOR=LightGrey] " + xbmc.getInfoLabel(
                        "Container(5051).ListItem.Label").decode("utf8") +
                    " [/I][/COLOR]",
                    "site":
                    "YouTube",
                    "size":
                    xbmc.getInfoLabel(
                        "Container(5051).ListItem.VideoResolution"),
                    "type":
                    "",
                    "landscape":
                    xbmc.getInfoLabel("Container(5051).ListItem.Art(thumb)")
                })
            if self.TrailerType == "realisateur" and KODIID != "":
                self.ListeTrailer.append({
                    "id":
                    xbmc.getInfoLabel("ListItem.FilenameAndPath"),
                    "position":
                    "0",
                    "iso_639_1":
                    "",
                    "iso_3166_1":
                    "",
                    "key":
                    "KODI",
                    "name":
                    xbmc.getLocalizedString(208) + "[I]" +
                    "[COLOR=LightGrey] " +
                    xbmc.getInfoLabel("ListItem.Label").decode("utf8") +
                    " [/I][/COLOR]",
                    "site":
                    "YouTube",
                    "size":
                    xbmc.getInfoLabel("ListItem.VideoResolution"),
                    "type":
                    "",
                    "landscape":
                    xbmc.getInfoLabel("ListItem.Art(thumb)")
                })

            xbmc.executebuiltin("Dialog.Close(busydialog)")
        if len(self.ListeTrailer) > 0:
            ListeNomTrailer = []
            Image = ""
            for Item in self.ListeTrailer:
                NomTrailer = None

                try:
                    Image = urllib.unquote(
                        Item.get("landscape").replace("image://", ""))
                except:
                    Image = ""
                    logMsg("erreur : %s" % (Item), 0)

                try:
                    NomTrailer = utils.try_decode(
                        Item["name"]) + " [" + utils.try_decode(
                            Item["type"]) + " - " + str(
                                Item["size"]) + "p - " + utils.try_decode(
                                    Item["iso_3166_1"] + "]")
                except:
                    NomTrailer = utils.try_decode(Item["type"]) + ' [' + str(
                        Item.get("size")) + 'p - ' + utils.try_decode(
                            Item["iso_3166_1"]) + ']'

                Elements = xbmcgui.ListItem(label=NomTrailer,
                                            iconImage=str(Image),
                                            label2="selectionnevue")
                Elements.setProperty("Icon", Image)
                Elements.setProperty("Source", Item["key"])
                ListeNomTrailer.append(Elements)

            if len(ListeNomTrailer) > 0:

                self.ui = MainService.dialog_select_UI(
                    'choix.xml',
                    ADDON_PATH,
                    'default',
                    '1080i',
                    listing=ListeNomTrailer,
                    trailers=self.ListeTrailer,
                    ItemId=xbmc.getInfoLabel("ListItem.DBID"))
                self.windowhome.setProperty("IconMixTrailer", "1")
                ret = self.ui.doModal()
                del self.ui
                self.windowhome.clearProperty('IconMixTrailer')

        else:
            #
            dialog = xbmcgui.Dialog()
            dialog.notification('IconMixTools',
                                Titre + ": " + __language__(32506),
                                "acteurs/arfffff.png", 500)
        self.windowhome.setProperty('FenetreListeChoix', '')
        #retour au focus précédent
        retour = {
            "": 2008,
            "videonav": 2999,
            "realisateur": 7778,
            "videoinfo7003": 7003,
            "dialogplus": 7003,
            "videonavsaga": 2008,
            "Roles": 7779
        }
        xbmc.executebuiltin("SetFocus(%d)" % (retour[self.TrailerType]))
Beispiel #8
0
    def __init__(self):
        
        utils.logMsg('started loading pluginentry')
        
        #get params
        action = None
        params = urlparse.parse_qs(sys.argv[2][1:].decode("utf-8"))
        utils.logMsg("Parameter string: %s" % sys.argv[2])
        
        if params:        
            path=params.get("path",None)
            if path: path = path[0]
            limit=params.get("limit",None)
            if limit: limit = int(limit[0])
            else: limit = 25
            action=params.get("action",None)
            if action: action = action[0].upper()
        
        if action:
            if action == "LAUNCHPVR":
                xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem())
                xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "id": 0, "method": "Player.Open", "params": { "item": {"channelid": %d} } }' %int(path))
            if action == "PLAYRECORDING":
                xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem())
                #retrieve the recording and play as listitem to get resume working
                json_result = utils.getJSON('PVR.GetRecordingDetails', '{"recordingid": %d, "properties": [ %s ]}' %(int(path),plugincontent.fields_pvrrecordings))
                if json_result:
                    xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "recordingid": %d } }, "id": 1 }' % int(path))
                    if json_result["resume"].get("position"):
                        for i in range(25):
                            if xbmc.getCondVisibility("Player.HasVideo"):
                                break
                            xbmc.sleep(250)
                        xbmc.Player().seekTime(json_result["resume"].get("position"))
            elif action == "LAUNCH":
                xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem())
                path = sys.argv[2].split("&path=")[1]
                xbmc.executebuiltin(path)
            elif action == "FOCUSANDCLICK":
                #used as workaround to display local media in extendedinfo actorinfo
                xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem())
                control=params.get("control")[0]
                title=params.get("title")[0]
                totalItems = int(xbmc.getInfoLabel("Container(%s).NumItems" %control))
                curItem = 0
                itemFound = False
                xbmc.executebuiltin("Control.SetFocus(%s,0)" %control)
                while totalItems > curItem:
                    curTitle = xbmc.getInfoLabel("Container(%s).ListItemAbsolute(%s).Title" %(control,curItem)).decode("utf-8")
                    if curTitle == title:
                        itemFound = True
                        xbmc.executebuiltin("Control.SetFocus(%s, %s)" %(control,curItem))
                        xbmc.executebuiltin("Action(select)")
                        break
                    else:
                        curItem += 1
                        xbmc.sleep(10)
                        
                #focus castinfo again after closing videoinfo
                if itemFound:
                    while not xbmc.getCondVisibility("Window.IsActive(script-ExtendedInfo Script-DialogVideoInfo.xml)"):
                        xbmc.sleep(500)
                    while xbmc.getCondVisibility("Window.IsActive(script-ExtendedInfo Script-DialogVideoInfo.xml)"):
                        xbmc.sleep(500)
                    xbmc.sleep(300)
                    xbmc.executebuiltin("Control.SetFocus(140)")

            elif action == "PLAYALBUM":
                xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem())
                xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "albumid": %d } }, "id": 1 }' % int(path))
            elif action == "SMARTSHORTCUTS":
                skinshortcuts.getSmartShortcuts(path)
            elif action == "BACKGROUNDS":
                skinshortcuts.getBackgrounds()
            elif action == "WIDGETS":
                skinshortcuts.getWidgets(path)
            elif action == "GETTHUMB":
                plugincontent.getThumb(path)
            elif action == "EXTRAFANART":
                plugincontent.getExtraFanArt(path)
            elif action == "GETCAST":
                movie=params.get("movie",None)
                if movie: movie = movie[0]
                tvshow=params.get("tvshow",None)
                if tvshow: tvshow = tvshow[0]
                movieset=params.get("movieset",None)
                if movieset: movieset = movieset[0]
                episode=params.get("episode",None)
                if episode: episode = episode[0]
                downloadthumbs=params.get("downloadthumbs",False)
                if downloadthumbs: downloadthumbs = downloadthumbs[0]=="true"
                plugincontent.getCast(movie,tvshow,movieset,episode,downloadthumbs)
            else:
                #get a widget listing
                refresh=params.get("reload",None)
                if refresh: refresh = refresh[0].upper()
                optionalParam = None
                imdbid=params.get("imdbid","")
                if imdbid: optionalParam = imdbid[0]
                genre=params.get("genre","")
                if genre: optionalParam = genre[0]
                browse=params.get("browse","")
                if browse: optionalParam = browse[0]
                reversed=params.get("reversed","")
                if reversed: optionalParam = reversed[0]
                type=params.get("type","")
                if type: optionalParam = type[0]
                name=params.get("name","")
                if name: optionalParam = name[0]
                randomize=params.get("randomize","")
                if randomize: randomize = randomize[0]
                randomize = randomize == "true"
                plugincontent.getPluginListing(action,limit,refresh,optionalParam,randomize)

        else:
            #do plugin main listing...
            plugincontent.doMainListing()