当前位置: 首页>>代码示例>>Python>>正文


Python FavouritesManager.addToFavourites方法代码示例

本文整理汇总了Python中favouritesManager.FavouritesManager.addToFavourites方法的典型用法代码示例。如果您正苦于以下问题:Python FavouritesManager.addToFavourites方法的具体用法?Python FavouritesManager.addToFavourites怎么用?Python FavouritesManager.addToFavourites使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在favouritesManager.FavouritesManager的用法示例。


在下文中一共展示了FavouritesManager.addToFavourites方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from favouritesManager import FavouritesManager [as 别名]
# 或者: from favouritesManager.FavouritesManager import addToFavourites [as 别名]

#.........这里部分代码省略.........
                    return
                xbmc.executebuiltin(enc.unescape(url))


    def _parseParameters(self, params):
        # ugly workaround for OpenELEC (sorts query parameters alphabetically)
        myparameters = params.split('&')
        mode = filter(lambda x: x.startswith('mode='), myparameters)
        codedItem = filter(lambda x: x.startswith('url='), myparameters)
        myparameters.remove(mode[0])
        myparameters.remove(codedItem[0])        
        myparameters.append(codedItem[0][4:])
        
        mode = int(mode[0].split('=')[1])
        item = ListItem.fromUrl('&'.join(myparameters))        
        return [mode, item]


    def run(self, paramstring):
        common.log('SportsDevil running')
        try:
            # Main Menu
            if len(paramstring) <= 2:
                
                mainMenu = ListItem.fromUrl(self.MAIN_MENU_FILE)
                tmpList = self.parseView(mainMenu)
                if tmpList:
                    self.currentlist = tmpList
                
                # if addon is started
                currFolder = xbmcUtils.getCurrentFolderPath()
                if not currFolder.startswith(self.base):
                    xbmcplugin.setPluginFanart(self.handle, common.Paths.pluginFanart)
                    self.clearCache()                    
                     
                    if common.getSetting('autoupdate') == 'true':    
                        self.update()

            else:
                params = paramstring[1:]
                [mode, item] = self._parseParameters(params)

                # switch(mode)
                if mode == Mode.VIEW:
                    tmpList = self.parseView(item)
                    if tmpList:
                        self.currentlist = tmpList
                        count = len(self.currentlist.items)
                        if count == 1:
                            # Autoplay single video
                            autoplayEnabled = common.getSetting('autoplay') == 'true'
                            if autoplayEnabled:
                                videos = self.currentlist.getVideos()
                                if len(videos) == 1:
                                    self.playVideo(videos[0], True)


                elif mode == Mode.ADDITEM:
                    if self.favouritesManager.addItem():
                        xbmc.executebuiltin('Container.Refresh()')

                elif mode in [Mode.ADDTOFAVOURITES, Mode.REMOVEFROMFAVOURITES, Mode.EDITITEM]:

                    if mode == Mode.ADDTOFAVOURITES:
                        self.favouritesManager.addToFavourites(item)
                    elif mode == Mode.REMOVEFROMFAVOURITES:
                        self.favouritesManager.removeItem(item)
                        xbmc.executebuiltin('Container.Refresh()')
                    elif mode == Mode.EDITITEM:
                        if self.favouritesManager.editItem(item):
                            xbmc.executebuiltin('Container.Refresh()')

                elif mode == Mode.EXECUTE:
                    self.executeItem(item)

                elif mode == Mode.PLAY:
                    self.playVideo(item)

                elif mode == Mode.QUEUE:
                    self.queueAllVideos(item)

                elif mode == Mode.DOWNLOAD:
                    url = urllib.unquote(item['url'])
                    title = item['title']
                    self.downloadVideo(url, title)
                
                elif mode == Mode.REMOVEFROMCUSTOMMODULES:
                    self.removeCustomModule(item)
                
                elif mode == Mode.UPDATE:
                    self.update()
                    
                elif mode == Mode.DOWNLOADCUSTOMMODULE:
                    self.downloadCustomModule()
                            

        except Exception, e:
            if common.enable_debug:
                traceback.print_exc(file = sys.stdout)
            common.showError('Error running SportsDevil.\n\nReason:\n' + str(e))
开发者ID:gtfamily,项目名称:gtfamily,代码行数:104,代码来源:main.py

示例2: __init__

# 需要导入模块: from favouritesManager import FavouritesManager [as 别名]
# 或者: from favouritesManager.FavouritesManager import addToFavourites [as 别名]

#.........这里部分代码省略.........
                tmpList = self.parseView(self.MAIN_MENU_FILE)
                if tmpList:
                    self.currentlist = tmpList
                    self.curr_file = tmpList.cfg

            else:
                params = paramstring
                mode, codedItem = params.split('&',1)
                mode = int(mode.split('=')[1])

                codedItem = codedItem[4:]
                item = decodeUrl(codedItem)

                # switch(mode)
                if mode == Mode.VIEW:
                    tmpList = self.parseView(codedItem)
                    if tmpList:
                        self.currentlist = tmpList
                        self.curr_file = tmpList.cfg
                        count = len(self.currentlist.items)
                        if count == 0:
                            common.showInfo('No stream available')
                        elif count == 1:
                            # Autoplay single video
                            autoplayEnabled = common.getSetting('autoplay') == 'true'
                            if autoplayEnabled:
                                videos = self.currentlist.getVideos()
                                if len(videos) == 1:
                                    self.playVideo(videos[0], True)


                elif mode == Mode.ADDITEM:
                    if self.favouritesManager.addItem():
                        xbmc.executebuiltin('Container.Refresh()')

                elif mode in [Mode.ADDTOFAVOURITES, Mode.REMOVEFROMFAVOURITES, Mode.EDITITEM]:

                    if mode == Mode.ADDTOFAVOURITES:
                        self.favouritesManager.addToFavourites(item)
                    elif mode == Mode.REMOVEFROMFAVOURITES:
                        self.favouritesManager.removeItem(item)
                        xbmc.executebuiltin('Container.Refresh()')
                    elif mode == Mode.EDITITEM:
                        if self.favouritesManager.editItem(item):
                            xbmc.executebuiltin('Container.Refresh()')

                elif mode == Mode.EXECUTE:
                    url = item['url']
                    if url.find('(') > -1:
                        xbmcCommand = parseText(url,'([^\(]*).*')
                        if xbmcCommand.lower() in ['activatewindow', 'runscript', 'runplugin', 'playmedia']:
                            if xbmcCommand.lower() == 'activatewindow':
                                params = parseText(url, '.*\(\s*(.+?)\s*\).*').split(',')
                                for i in range(len(params)-1,-1,-1):
                                    p = params[i]
                                    if p == 'return':
                                        params.remove(p)
                                path = enc.unescape(params[len(params)-1])
                                xbmc.executebuiltin('Container.Update(' + path + ')')
                                return
                            xbmc.executebuiltin(enc.unescape(url))

                elif mode == Mode.PLAY:
                    self.playVideo(item)

                elif mode == Mode.QUEUE:
                    dia = DialogProgress()
                    dia.create('SportsDevil', 'Get videos...' + item['title'])
                    dia.update(0)

                    items = self.getVideos(item, dia)
                    if items:
                        for it in items:
                            item = self.createXBMCListItem(it)
                            uc = sys.argv[0] + '?mode=' + str(Mode.PLAY) + '&url=' + codeUrl(it)
                            item.setProperty('IsPlayable', 'true')
                            item.setProperty('IsFolder','false')
                            xbmc.PlayList(1).add(uc, item)
                        resultLen = len(items)
                        msg = 'Queued ' + str(resultLen) + ' video'
                        if resultLen > 1:
                            msg += 's'
                        dia.update(100, msg)
                        xbmc.sleep(500)
                        dia.update(100, msg,' ',' ')
                    else:
                        dia.update(0, 'No items found',' ')

                    xbmc.sleep(700)
                    dia.close()

                elif mode == Mode.DOWNLOAD:
                    url = urllib.unquote(item['url'])
                    title = item['title']
                    self.downloadVideo(url, title)

        except Exception, e:
            if common.enable_debug:
                traceback.print_exc(file = sys.stdout)
            common.showError('Error running SportsDevil.\n\nReason:\n' + str(e))
开发者ID:rollysalvana,项目名称:pampereo-xbmc-plugins,代码行数:104,代码来源:main.py


注:本文中的favouritesManager.FavouritesManager.addToFavourites方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。