Python xbmc 模块,executebuiltin() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用xbmc.executebuiltin()

项目:YoutubeTV    作者:dude56987    | 项目源码 | 文件源码
def restore(self):
        # clear out caches prior to restore
        # this prevents hanging cache data
        self.playlistCache.reset()
        self.cache.reset()
        self.timer.reset()
        # restore the channels saved from the last backup
        tempTable=tables.table(_datadir+'backup/')
        channels=tempTable.loadValue('backup')
        # refresh all channel data for channels
        for channel in channels:
            # grab each channels metadata and store it
            self.grabChannelMetadata(channel)
            # save all channels into the cache
            self.cache.saveValue(channel,list())
        # refresh the view and load the popup
        xbmc.executebuiltin('container.Update('+_url+',replace)')
        popup('YoutubeTV','Restore of backup Complete!')
################################################################################
项目:nuodtayo.tv    作者:benaranguren    | 项目源码 | 文件源码
def login():
    cookie_jar.clear()
    login_page = callServiceApi("/user/login")
    form_login = common.parseDOM(login_page, "form", attrs = {'id' : 'form1'})
    request_verification_token = common.parseDOM(
        form_login[0], "input",
        attrs = {'name': '__RequestVerificationToken'}, ret='value'
    )
    emailAddress = this.getSetting('emailAddress')
    password = this.getSetting('password')
    formdata = {"EMail": emailAddress,
                "Password": password,
                '__RequestVerificationToken': request_verification_token[0]
               }
    headers = [('Referer', 'http://tfc.tv/User/Login')]
    response = callServiceApi("/user/login", formdata, headers=headers,
                              base_url='https://tfc.tv', timeout=120)
    common.log('LOGIN_STATUS')
    if 'logout' in response:
        common.log('LOGGED IN')
    else:
        xbmc.executebuiltin('Sign In Error')
项目:script.skin.helper.skinbackup    作者:marcelveldt    | 项目源码 | 文件源码
def set_day_night_theme(self, dayornight, themename, themefile):
        ''' Sets a new daynight theme'''
        currenttimevalue = xbmc.getInfoLabel("Skin.String(SkinHelper.ColorTheme.%s.time)" % dayornight)
        if not currenttimevalue:
            currenttimevalue = "20:00" if dayornight == "night" else "07:00"
        timevalue = xbmcgui.Dialog().input(self.addon.getLocalizedString(32017),
                                           currenttimevalue).decode("utf-8")
        try:
            # check if the time is valid
            check_date = datetime(*(time.strptime(timevalue, "%H:%M")[0:6]))
            del check_date
            base_setting = "SkinHelper.ColorTheme.%s" % dayornight
            xbmc.executebuiltin("Skin.SetString(%s.theme,%s)" % (base_setting, themename.encode("utf-8")))
            xbmc.executebuiltin("Skin.SetString(%s.time,%s)" % (base_setting, timevalue))
            label = "%s  (%s %s)" % (themename.encode("utf-8"), self.addon.getLocalizedString(32019), timevalue)
            xbmc.executebuiltin("Skin.SetString(%s.label,%s)" % (base_setting, label))
            xbmc.executebuiltin("Skin.SetString(%s.file,%s)" % (base_setting, themefile.encode("utf-8")))
        except Exception as exc:
            log_exception(__name__, exc)
            xbmcgui.Dialog().ok(xbmc.getLocalizedString(329), self.addon.getLocalizedString(32018))
项目:script.skin.helper.skinbackup    作者:marcelveldt    | 项目源码 | 文件源码
def backup_theme(self, themename):
        '''backup a colortheme to a zipfile'''
        import zipfile
        backup_path = xbmcgui.Dialog().browse(3, self.addon.getLocalizedString(32029), "files").decode("utf-8")
        if backup_path:
            xbmc.executebuiltin("ActivateWindow(busydialog)")
            backup_name = u"%s ColorTheme - %s" % (get_skin_name().capitalize(), themename)
            backupfile = os.path.join(backup_path, backup_name + u".zip")
            zip_temp = u'special://temp/%s.zip' % backup_name
            xbmcvfs.delete(zip_temp)
            xbmcvfs.delete(backupfile)
            zip_temp = xbmc.translatePath(zip_temp).decode("utf-8")
            zip_file = zipfile.ZipFile(zip_temp, "w", zipfile.ZIP_DEFLATED)
            abs_src = os.path.abspath(xbmc.translatePath(self.userthemes_path).decode("utf-8"))
            for filename in xbmcvfs.listdir(self.userthemes_path)[1]:
                if (filename.startswith("%s_" % themename) or
                        filename.replace(".theme", "").replace(".jpg", "") == themename):
                    filename = filename.decode("utf-8")
                    filepath = xbmc.translatePath(self.userthemes_path + filename).decode("utf-8")
                    absname = os.path.abspath(filepath)
                    arcname = absname[len(abs_src) + 1:]
                    zip_file.write(absname, arcname)
            zip_file.close()
            xbmcvfs.copy(zip_temp, backupfile)
            xbmc.executebuiltin("Dialog.Close(busydialog)")
项目:script.skin.helper.skinbackup    作者:marcelveldt    | 项目源码 | 文件源码
def reset(self, filters=None, silent=False):
        '''reset skin settings'''
        log_msg("filters: %s" % filters)
        if silent or (not silent and
                      xbmcgui.Dialog().yesno(heading=self.addon.getLocalizedString(32010),
                                             line1=self.addon.getLocalizedString(32011))):
            if filters:
                # only restore specific settings
                skinsettings = self.get_skinsettings(filters)
                for setting in skinsettings:
                    xbmc.executebuiltin("Skin.Reset(%s)" % setting[1].encode("utf-8"))
            else:
                # restore all skin settings
                xbmc.executebuiltin("RunScript(script.skinshortcuts,type=resetall&warning=false)")
                xbmc.sleep(250)
                xbmc.executebuiltin("Skin.ResetSettings")
                xbmc.sleep(250)
                xbmc.executebuiltin("ReloadSkin")
            # fix default settings and labels
            xbmc.sleep(1500)
            xbmc.executebuiltin("RunScript(script.skin.helper.service,action=checkskinsettings)")
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def set_playback_device(self):
        '''set the active playback device'''
        deviceid = self.params["deviceid"][0]
        if deviceid == "local":
            self.addon.setSetting("playback_device", "local")
        elif deviceid == "remote":
            headertxt = self.addon.getLocalizedString(11039)
            bodytxt = self.addon.getLocalizedString(11061)
            dialog = xbmcgui.Dialog()
            dialog.textviewer(headertxt, bodytxt)
            result = dialog.input(self.addon.getLocalizedString(11062))
            if result:
                self.addon.setSetting("playback_device", "remote")
                self.addon.setSetting("connect_id", result)
            del dialog
        elif deviceid == "squeezebox":
            self.addon.setSetting("playback_device", "squeezebox")
        else:
            self.sp.transfer_playback(deviceid, False)
            self.addon.setSetting("playback_device", "connect")
            self.addon.setSetting("connect_id", deviceid)
        xbmc.executebuiltin("Container.Refresh")
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def browse_topartists(self):
        xbmcplugin.setContent(self.addon_handle, "artists")
        result = self.sp.current_user_top_artists(limit=20, offset=0)
        cachestr = "spotify.topartists.%s" % self.userid
        checksum = self.cache_checksum(result["total"])
        items = self.cache.get(cachestr, checksum=checksum)
        if not items:
            count = len(result["items"])
            while result["total"] > count:
                result["items"] += self.sp.current_user_top_artists(limit=20, offset=count)["items"]
                count += 50
            items = self.prepare_artist_listitems(result["items"])
            self.cache.set(cachestr, items, checksum=checksum)
        self.add_artist_listitems(items)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
        xbmcplugin.endOfDirectory(handle=self.addon_handle)
        if self.defaultview_artists:
            xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_artists)
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def browse_toptracks(self):
        xbmcplugin.setContent(self.addon_handle, "songs")
        results = self.sp.current_user_top_tracks(limit=20, offset=0)
        cachestr = "spotify.toptracks.%s" % self.userid
        checksum = self.cache_checksum(results["total"])
        items = self.cache.get(cachestr, checksum=checksum)
        if not items:
            items = results["items"]
            while results["next"]:
                results = self.sp.next(results)
                items.extend(results["items"])
            items = self.prepare_track_listitems(tracks=items)
            self.cache.set(cachestr, items, checksum=checksum)
        self.add_track_listitems(items, True)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
        xbmcplugin.endOfDirectory(handle=self.addon_handle)
        if self.defaultview_songs:
            xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_songs)
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def browse_album(self):
        xbmcplugin.setContent(self.addon_handle, "songs")
        album = self.sp.album(self.albumid, market=self.usercountry)
        xbmcplugin.setProperty(self.addon_handle, 'FolderName', album["name"])
        tracks = self.get_album_tracks(album)
        if album.get("album_type") == "compilation":
            self.add_track_listitems(tracks, True)
        else:
            self.add_track_listitems(tracks)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_TRACKNUM)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_TITLE)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_VIDEO_YEAR)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_SONG_RATING)
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_ARTIST)
        xbmcplugin.endOfDirectory(handle=self.addon_handle)
        if self.defaultview_songs:
            xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_songs)
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def search_tracks(self):
        xbmcplugin.setContent(self.addon_handle, "songs")
        xbmcplugin.setProperty(self.addon_handle, 'FolderName', xbmc.getLocalizedString(134))
        result = self.sp.search(
            q="track:%s" %
            self.trackid,
            type='track',
            limit=self.limit,
            offset=self.offset,
            market=self.usercountry)
        tracks = self.prepare_track_listitems(tracks=result["tracks"]["items"])
        self.add_track_listitems(tracks, True)
        self.add_next_button(result['tracks']['total'])
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
        xbmcplugin.endOfDirectory(handle=self.addon_handle)
        if self.defaultview_songs:
            xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_songs)
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def search_albums(self):
        xbmcplugin.setContent(self.addon_handle, "albums")
        xbmcplugin.setProperty(self.addon_handle, 'FolderName', xbmc.getLocalizedString(132))
        result = self.sp.search(
            q="album:%s" %
            self.albumid,
            type='album',
            limit=self.limit,
            offset=self.offset,
            market=self.usercountry)
        albumids = []
        for album in result['albums']['items']:
            albumids.append(album["id"])
        albums = self.prepare_album_listitems(albumids)
        self.add_album_listitems(albums, True)
        self.add_next_button(result['albums']['total'])
        xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED)
        xbmcplugin.endOfDirectory(handle=self.addon_handle)
        if self.defaultview_albums:
            xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_albums)
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def search_playlists(self):
        xbmcplugin.setContent(self.addon_handle, "files")
        result = self.sp.search(
            q=self.playlistid,
            type='playlist',
            limit=self.limit,
            offset=self.offset,
            market=self.usercountry)
        log_msg(result)
        xbmcplugin.setProperty(self.addon_handle, 'FolderName', xbmc.getLocalizedString(136))
        playlists = self.prepare_playlist_listitems(result['playlists']['items'])
        self.add_playlist_listitems(playlists)
        self.add_next_button(result['playlists']['total'])
        xbmcplugin.endOfDirectory(handle=self.addon_handle)
        if self.defaultview_playlists:
            xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_playlists)
项目:script.matchcenter    作者:enen92    | 项目源码 | 文件源码
def onInit(self):
        xbmc.log(msg="[Match Center] Script started", level=xbmc.LOGDEBUG)
        if os.path.exists(ignored_league_list_file):
            self.ignored_leagues = [league.lower() for league in eval(FileIO.fileread(ignored_league_list_file)) if league] 
        else:
            self.ignored_leagues = []
        xbmc.executebuiltin("ClearProperty(no-games,Home)")
        self.getControl(32540).setImage(os.path.join(addon_path,"resources","img","goal.png"))
        xbmc.executebuiltin("SetProperty(loading-script-matchcenter-livescores,1,home)")
        self.livescoresThread()
        xbmc.executebuiltin("ClearProperty(loading-script-matchcenter-livescores,Home)")
        i = 0
        while self.isRunning:
            if (float(i*200)/(livescores_update_time*60*1000)).is_integer() and ((i*200)/(3*60*1000)) != 0:
                self.livescoresThread()
            xbmc.sleep(200)
            i += 1
        xbmc.log(msg="[Match Center] Script stopped", level=xbmc.LOGDEBUG)
项目:script.matchcenter    作者:enen92    | 项目源码 | 文件源码
def onInit(self):
        self.getControl(32540).setImage(os.path.join(addon_path,"resources","img","goal.png"))
        xbmc.executebuiltin("SetProperty(loading-script-matchcenter-leagueselection,1,home)")
        leagues = api.Search().Leagues(sport="Soccer")
        leagues_to_be_shown = ssutils.get_league_tables_ids()
        items = []
        if leagues:
            for league in leagues:
                if str(league.idLeague) in str(leagues_to_be_shown):
                    item = xbmcgui.ListItem(league.strLeague)
                    item.setProperty("thumb",str(league.strBadge))
                    item.setProperty("identifier",str(league.idLeague))
                    items.append(item)
        xbmc.executebuiltin("ClearProperty(loading-script-matchcenter-leagueselection,Home)")
        self.getControl(32500).addItems(items)
        if len(items) <= 9:
            self.getControl(32541).setWidth(962)
            self.getControl(32542).setWidth(962)
项目:script.matchcenter    作者:enen92    | 项目源码 | 文件源码
def run():
    try:
        xbmc.executebuiltin("ActivateWindow(10147)")
        window = xbmcgui.Window(10147)
        xbmc.sleep(100)
        window.getControl(1).setLabel(translate(32000))
        window.getControl(5).setText(translate(32065))
        while xbmc.getCondVisibility("Window.IsActive(10147)"):
            xbmc.sleep(100)
        ret = xbmcgui.Dialog().yesno(translate(32000), translate(32067))
        if ret:
            xbmc.executebuiltin("RunAddon(script.keymap)")

    except:
        traceback.print_stack()
        xbmc.executebuiltin("XBMC.Notification('"+translate(32000)+"','"+translate(32066)+"','2000','')")
项目:tvalacarta    作者:tvalacarta    | 项目源码 | 文件源码
def channeltypes(params,url,category):
    logger.info("channelselector.channeltypes")

    lista = getchanneltypes()
    for item in lista:
        addfolder(item.title,item.channel,item.action,category=item.category,thumbnailname=item.thumbnail)

    if config.get_platform()=="kodi-krypton":
        import plugintools
        plugintools.set_view( plugintools.TV_SHOWS )

    # Label (top-right)...
    import xbmcplugin
    xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category="" )
    xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
    xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )

    if config.get_setting("forceview")=="true":
        # Confluence - Thumbnail
        import xbmc
        xbmc.executebuiltin("Container.SetViewMode(500)")
项目:tvalacarta    作者:tvalacarta    | 项目源码 | 文件源码
def listchannels(params,url,category):
    logger.info("channelselector.listchannels")

    lista = filterchannels(category)
    for channel in lista:
        if config.is_xbmc() and (channel.type=="xbmc" or channel.type=="generic"):
            addfolder(channel.title , channel.channel , "mainlist" , channel.channel)

        elif config.get_platform()=="boxee" and channel.extra!="rtmp":
            addfolder(channel.title , channel.channel , "mainlist" , channel.channel)

    if config.get_platform()=="kodi-krypton":
        import plugintools
        plugintools.set_view( plugintools.TV_SHOWS )

    # Label (top-right)...
    import xbmcplugin
    xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=category )
    xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
    xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )

    if config.get_setting("forceview")=="true":
        # Confluence - Thumbnail
        import xbmc
        xbmc.executebuiltin("Container.SetViewMode(500)")
项目:forthelulz    作者:munchycool    | 项目源码 | 文件源码
def resolve_url(url):
    duration=7500   
    try:
        stream_url = urlresolver.HostedMediaFile(url=url).resolve()
        # If urlresolver returns false then the video url was not resolved.
        if not stream_url or not isinstance(stream_url, basestring):
            try: msg = stream_url.msg
            except: msg = url
            xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%('URL Resolver',msg, duration, _icon))
            return False
    except Exception as e:
        try: msg = str(e)
        except: msg = url
        xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%('URL Resolver',msg, duration, _icon))
        return False

    return stream_url
项目:forthelulz    作者:munchycool    | 项目源码 | 文件源码
def resolve_url(url):
    duration=7500   
    try:
        stream_url = urlresolver.HostedMediaFile(url=url).resolve()
        # If urlresolver returns false then the video url was not resolved.
        if not stream_url or not isinstance(stream_url, basestring):
            try: msg = stream_url.msg
            except: msg = url
            xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%('URL Resolver',msg, duration, addon_icon))
            return False
    except Exception as e:
        try: msg = str(e)
        except: msg = url
        xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%('URL Resolver',msg, duration, addon_icon))
        return False

    return stream_url
项目:catchup4kodi    作者:catchup4kodi    | 项目源码 | 文件源码
def RESTORE():

    import time
    dialog = xbmcgui.Dialog()
    if zip == '' and ADDON.getSetting('email')=='':
        dialog.ok('USB BACKUP/RESTORE','You have not set your ZIP Folder.\nPlease update the addon settings and try again.','','')
        ADDON.openSettings(sys.argv[0])

    lib=xbmc.translatePath(os.path.join(zip,'backup.zip'))
    READ_ZIP(lib)
    dp.create("USB BACKUP/RESTORE","Checking ",'', 'Please Wait')
    HOME = xbmc.translatePath(os.path.join('special://','home'))

    dp.update(0,"", "Extracting Zip Please Wait")
    extract.all(lib,HOME,dp)
    time.sleep(1)
    XfinityInstaller()
    xbmc.executebuiltin('UpdateLocalAddons ')    
    xbmc.executebuiltin("UpdateAddonRepos")
    time.sleep(1)
    xbmc.executebuiltin('UnloadSkin()') 
    xbmc.executebuiltin('ReloadSkin()')
    Kodi17()
    dialog.ok("USB BACKUP/RESTORE", "PLEASE REBOOT YOUR BOX IF HOMESCREEN HAS NOT CHANGED", "","")
    xbmc.executebuiltin("LoadProfile(Master user)")
项目:catchup4kodi    作者:catchup4kodi    | 项目源码 | 文件源码
def showText(heading, text):
    id = 10147

    xbmc.executebuiltin('ActivateWindow(%d)' % id)
    xbmc.sleep(100)

    win = xbmcgui.Window(id)

    retry = 50
    while (retry > 0):
        try:
            xbmc.sleep(10)
            retry -= 1
            win.getControl(1).setLabel(heading)
            win.getControl(5).setText(text)
            return
        except:
            pass
项目:catchup4kodi    作者:catchup4kodi    | 项目源码 | 文件源码
def showText(heading, text):
    id = 10147

    xbmc.executebuiltin('ActivateWindow(%d)' % id)
    xbmc.sleep(100)

    win = xbmcgui.Window(id)

    retry = 50
    while (retry > 0):
        try:
            xbmc.sleep(10)
            retry -= 1
            win.getControl(1).setLabel(heading)
            win.getControl(5).setText(text)
            return
        except:
            pass
项目:plugin.video.netflix    作者:asciidisco    | 项目源码 | 文件源码
def set_custom_view(self, content):
        """Set the view mode

        Parameters
        ----------
        content : :obj:`str`

            Type of content in container
            (folder, movie, show, season, episode, login)

        """
        custom_view = self.get_addon().getSetting('customview')
        if custom_view == 'true':
            view = int(self.get_addon().getSetting('viewmode' + content))
            if view != -1:
                xbmc.executebuiltin('Container.SetViewMode(%s)' % view)
项目:plugin.video.netflix    作者:asciidisco    | 项目源码 | 文件源码
def set_location(self, url, replace=False):
        """Set URL location

        Parameters
        ----------
        url : :obj:`str`
            Window URL

        ret : bool
            Return to location prior to activation

        Returns
        -------
        bool
            Window was activated
        """
        cmd = 'Container.Update({},{})'.format(url, str(replace))
        return xbmc.executebuiltin(cmd)
项目:plugin.audio.tidal2    作者:arnesongit    | 项目源码 | 文件源码
def add_list_items(self, items, content=None, end=True, withNextPage=False):
        TidalSession.add_list_items(self, items, content=content, end=end, withNextPage=withNextPage)
        if end:
            try:
                self.save_album_cache()
                kodiVersion = xbmc.getInfoLabel('System.BuildVersion').split()[0]
                kodiVersion = kodiVersion.split('.')[0]
                skinTheme = xbmc.getSkinDir().lower()
                if 'onfluence' in skinTheme:
                    if kodiVersion <= '16':
                        xbmc.executebuiltin('Container.SetViewMode(506)')
                    elif content == 'musicvideos':
                        xbmc.executebuiltin('Container.SetViewMode(511)')
                    elif content == 'artists':
                        xbmc.executebuiltin('Container.SetViewMode(512)')
                    else:
                        xbmc.executebuiltin('Container.SetViewMode(506)')
                elif 'estuary' in skinTheme:
                    xbmc.executebuiltin('Container.SetViewMode(55)')
            except:
                pass
项目:plugin.audio.tidal2    作者:arnesongit    | 项目源码 | 文件源码
def selectPlaylistDialog(self, headline=None, allowNew=False):
        if not self._session.is_logged_in:
            return None
        xbmc.executebuiltin("ActivateWindow(busydialog)")
        try:
            if not headline:
                headline = _T(30238)
            items = self.playlists()
            dialog = xbmcgui.Dialog()
            item_list = [item.title for item in items]
            if allowNew:
                item_list.append(_T(30237))
        except Exception, e:
            log(str(e), level=xbmc.LOGERROR)
            xbmc.executebuiltin("Dialog.Close(busydialog)")
            return None
        xbmc.executebuiltin("Dialog.Close(busydialog)")
        selected = dialog.select(headline, item_list)
        if selected >= len(items):
            item = self.newPlaylistDialog()
            return item
        elif selected >= 0:
            return items[selected]
        return None
项目:plugin.audio.tidal2    作者:arnesongit    | 项目源码 | 文件源码
def user_playlist_remove_album(playlist_id, item_id, dialog=True):
    playlist = session.get_playlist(playlist_id)
    ok = True
    if dialog:
        ok = xbmcgui.Dialog().yesno(_T(30247) % playlist.title, _T(30246))
    if ok:
        xbmc.executebuiltin('ActivateWindow(busydialog)')
        try:
            items = session.get_playlist_tracks(playlist)
            for item in items:
                if '%s' % item.album.id == '%s' % item_id:
                    session.user.remove_playlist_entry(playlist, entry_no=item._playlist_pos)
                    break # Remove only one Item
        except Exception, e:
            log(str(e), level=xbmc.LOGERROR)
            traceback.print_exc()
        xbmc.executebuiltin('Dialog.Close(busydialog)')
        xbmc.executebuiltin('Container.Refresh()')
项目:script.tvguide.fullscreen    作者:primaeval    | 项目源码 | 文件源码
def _scheduleAutoplay(self, channelId, programTitle, startTime, endTime):
        t = startTime - datetime.datetime.now()
        timeToAutoplay = ((t.days * 86400) + t.seconds) / 60
        if timeToAutoplay < 0:
            return
        #timeToAutoplay = 1
        name = self.createAlarmClockName(programTitle, startTime)
        xbmc.executebuiltin('AlarmClock(%s-start,RunScript(special://home/addons/script.tvguide.fullscreen/play.py,%s,%s),%d,True)' %
        (name.encode('utf-8', 'replace'), channelId.encode('utf-8'), startTime, timeToAutoplay - int(ADDON.getSetting('autoplays.before'))))

        t = endTime - datetime.datetime.now()
        timeToAutoplay = ((t.days * 86400) + t.seconds) / 60
        #timeToAutoplay = 0
        if ADDON.getSetting('autoplays.stop') == 'true':
            xbmc.executebuiltin('AlarmClock(%s-stop,RunScript(special://home/addons/script.tvguide.fullscreen/stop.py,%s,%s),%d,True)' %
            (name.encode('utf-8', 'replace'), channelId.encode('utf-8'), startTime, timeToAutoplay + int(ADDON.getSetting('autoplays.after'))))
项目:script.tvguide.fullscreen    作者:primaeval    | 项目源码 | 文件源码
def _scheduleAutoplaywith(self, channelId, programTitle, startTime, endTime):
        t = startTime - datetime.datetime.now()
        timeToAutoplaywith = ((t.days * 86400) + t.seconds) / 60
        if timeToAutoplaywith < 0:
            return
        #timeToAutoplaywith = 1
        name = self.createAlarmClockName(programTitle, startTime)
        timestamp = time.mktime(startTime.timetuple())
        xbmc.executebuiltin('AlarmClock(%s-start,RunScript(special://home/addons/script.tvguide.fullscreen/playwith.py,%s,%s),%d,True)' %
        (name.encode('utf-8', 'replace'), channelId.encode('utf-8'), timestamp, timeToAutoplaywith - int(ADDON.getSetting('autoplaywiths.before'))))

        t = endTime - datetime.datetime.now()
        timeToAutoplaywith = ((t.days * 86400) + t.seconds) / 60
        #timeToAutoplaywith = 0
        if ADDON.getSetting('autoplaywiths.stop') == 'true':
            xbmc.executebuiltin('AlarmClock(%s-stop,RunScript(special://home/addons/script.tvguide.fullscreen/stopwith.py,%s,%s),%d,True)' %
            (name.encode('utf-8', 'replace'), channelId.encode('utf-8'), timestamp, timeToAutoplaywith + int(ADDON.getSetting('autoplaywiths.after'))))
项目:script.tvguide.fullscreen    作者:primaeval    | 项目源码 | 文件源码
def clear_catchup(self):
        if not self.playing_catchup_channel:
            return
        self.playing_catchup_channel = False
        filename = 'special://profile/addon_data/script.tvguide.fullscreen/catchup_channel.list'
        f = xbmcvfs.File(filename,'rb')
        alarms = f.read().splitlines()
        f.close()
        if not alarms:
            return
        xbmcvfs.delete(filename)
        for name in alarms:
            xbmc.executebuiltin('CancelAlarm(%s,True)' % name.encode('utf-8', 'replace'))
        programList = []
        catchup = ADDON.getSetting('catchup.text')
        channel = utils.Channel("catchup", catchup, '', "special://home/addons/plugin.video.%s/icon.png" % catchup.lower(), "catchup", True)
        self.database.updateProgramList(None,programList,channel)
        self.onRedrawEPG(self.channelIdx, self.viewStartDate)
项目:pelisalacarta-ce    作者:pelisalacarta-ce    | 项目源码 | 文件源码
def onAction(self, action):
             if action == ACTION_SELECT_ITEM or action == ACTION_GESTURE_SWIPE_LEFT:
                import os
                import xbmc
                APPCOMMANDDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "customapp.xml")
                NOBACKDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "noback.xml")
                REMOTENOBACKDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "remotenoback.xml")
                APPNOBACKDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "appnoback.xml")
                TESTPYDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "test.py")
                try:
                    os.remove(NOBACKDESTFILE)
                    os.remove(REMOTENOBACKDESTFILE)
                    os.remove(APPNOBACKDESTFILE)
                    if os.path.exists ( TESTPYDESTFILE ):
                        urllib.urlretrieve ("https://raw.githubusercontent.com/neno1978/script.palc.forcerefresh/master/Bityouth/customapp.xml", APPCOMMANDDESTFILE )
                    xbmc.executebuiltin('Action(reloadkeymaps)')
                except:
                    xbmc.executebuiltin('Action(reloadkeymaps)')
                self.close()
项目:pelisalacarta-ce    作者:pelisalacarta-ce    | 项目源码 | 文件源码
def onAction(self, action):
            if action == ACTION_SELECT_ITEM or action == ACTION_GESTURE_SWIPE_LEFT:
               import os
               import xbmc
               APPCOMMANDDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "customapp.xml")
               NOBACKDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "noback.xml")
               REMOTENOBACKDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "remotenoback.xml")
               APPNOBACKDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "appnoback.xml")
               TESTPYDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "test.py")
               try:
                  os.remove(NOBACKDESTFILE)
                  os.remove(REMOTENOBACKDESTFILE)
                  os.remove(APPNOBACKDESTFILE)
                  if os.path.exists ( TESTPYDESTFILE ):
                     urllib.urlretrieve ("https://raw.githubusercontent.com/neno1978/script.palc.forcerefresh/master/Bityouth/customapp.xml", APPCOMMANDDESTFILE )
                  xbmc.executebuiltin('Action(reloadkeymaps)')
               except:
                  xbmc.executebuiltin('Action(reloadkeymaps)')
               self.close()
项目:pelisalacarta-ce    作者:pelisalacarta-ce    | 项目源码 | 文件源码
def callback_voto(item, values):
    item.voto = item.valores["voto"][values["voto"]]
    item.action = "acciones_fa"
    movieid = item.url.rsplit("=", 1)[1]
    post = "id=%s&rating=%s&itk=%s&action=rate" % (movieid, item.voto, item.itk)
    data = jsontools.load_json(httptools.downloadpage("http://filmaffinity.com/%s/ratingajax.php" % langf, post).data)

    if not item.folder:
        import xbmc
        return xbmc.executebuiltin("Container.Refresh")
    else:
        if data["result"] == 0:
            title = "Voto contabilizado con éxito"
        else:
            title = "Error, algo ha fallado durante el proceso"
        itemlist.append(item.clone(action="", title=title))
        return itemlist
项目:pelisalacarta-ce    作者:pelisalacarta-ce    | 项目源码 | 文件源码
def addlist_mal(item):
    data = httptools.downloadpage(item.url).data

    anime_id = scrapertools.find_single_match(data, 'id="myinfo_anime_id" value="([^"]+)"')
    if item.value == "2":
        vistos = scrapertools.find_single_match(data, 'id="myinfo_watchedeps".*?<span id="curEps">(\d+)')
    else:
        vistos = scrapertools.find_single_match(data, 'id="myinfo_watchedeps".*?value="(\d+)"')
    if not item.score:
        item.score = scrapertools.find_single_match(data, 'id="myinfo_score".*?selected" value="(\d+)"')
    token = scrapertools.find_single_match(data, "name='csrf_token' content='([^']+)'")

    post = {'anime_id': int(anime_id), 'status': int(item.value), 'score': int(item.score), 'num_watched_episodes': int(vistos), 'csrf_token': token}
    headers_mal = {'User-Agent': 'Mozilla/5.0', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'Referer': item.url, 'X-Requested-With': 'XMLHttpRequest'}
    url = "https://myanimelist.net/ownlist/anime/add.json"
    if item.lista:
        url = "https://myanimelist.net/ownlist/anime/edit.json"
    data = httptools.downloadpage(url, post=jsontools.dump_json(post), headers=headers_mal, replace_headers=True).data
    item.title = "En tu lista"
    if config.is_xbmc():
        import xbmc
        xbmc.executebuiltin("Container.Refresh")
项目:pelisalacarta-ce    作者:pelisalacarta-ce    | 项目源码 | 文件源码
def onAction(self, action):
            if action == ACTION_SELECT_ITEM or action == ACTION_GESTURE_SWIPE_LEFT:
               ###Se vuelven a cargar Customkey al salir de info
               import os, sys
               import xbmc
               APPCOMMANDDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "customapp.xml")
               NOBACKDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "noback.xml")
               REMOTENOBACKDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "remotenoback.xml")
               APPNOBACKDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "appnoback.xml")
               TESTPYDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "test.py")
               try:
                   os.remove(NOBACKDESTFILE)
                   os.remove(REMOTENOBACKDESTFILE)
                   os.remove(APPNOBACKDESTFILE)
                   if os.path.exists ( TESTPYDESTFILE ):
                      urllib.urlretrieve ("https://raw.githubusercontent.com/neno1978/script.palc.forcerefresh/master/Bricocine/customapp.xml", APPCOMMANDDESTFILE )
                   xbmc.executebuiltin('Action(reloadkeymaps)')
               except:
                  pass
               self.close()
项目:pelisalacarta-ce    作者:pelisalacarta-ce    | 项目源码 | 文件源码
def onAction(self, action):
            if action == ACTION_SELECT_ITEM or action == ACTION_GESTURE_SWIPE_LEFT:
               import os, sys
               import xbmc
               APPCOMMANDDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "customapp.xml")
               NOBACKDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "noback.xml")
               REMOTENOBACKDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "remotenoback.xml")
               APPNOBACKDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "appnoback.xml")
               TESTPYDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "test.py")
               try:
                   os.remove(NOBACKDESTFILE)
                   os.remove(REMOTENOBACKDESTFILE)
                   os.remove(APPNOBACKDESTFILE)
                   xbmc.executebuiltin('Action(reloadkeymaps)')
                   if os.path.exists ( TESTPYDESTFILE ):
                      urllib.urlretrieve ("https://raw.githubusercontent.com/neno1978/script.palc.forcerefresh/master/Bricocine/customapp.xml", APPCOMMANDDESTFILE )
                   xbmc.executebuiltin('Action(reloadkeymaps)')
               except:
                   xbmc.executebuiltin('Action(reloadkeymaps)')
               self.close()
项目:pelisalacarta-ce    作者:pelisalacarta-ce    | 项目源码 | 文件源码
def sync_trakt_kodi(silent=True):

    # Para que la sincronizacion no sea silenciosa vale con silent=False
    if xbmc.getCondVisibility('System.HasAddon("script.trakt")'):
        notificacion = True
        if (not config.get_setting("sync_trakt_notification", "biblioteca") and
                platformtools.is_playing()):
            notificacion = False

        xbmc.executebuiltin('RunScript(script.trakt,action=sync,silent=%s)' % silent)
        logger.info("Sincronizacion con Trakt iniciada")

        if notificacion:
            platformtools.dialog_notification("pelisalacarta",
                                              "Sincronizacion con Trakt iniciada",
                                              icon=0,
                                              time=2000)
项目:script.module.metadatautils    作者:marcelveldt    | 项目源码 | 文件源码
def music_artwork_options(self, artist, album, track, disc):
        '''show options for music artwork'''
        options = []
        options.append(self._mutils.addon.getLocalizedString(32028))  # Refresh item (auto lookup)
        options.append(self._mutils.addon.getLocalizedString(32036))  # Choose art
        options.append(self._mutils.addon.getLocalizedString(32034))  # Open addon settings
        header = self._mutils.addon.getLocalizedString(32015)
        dialog = xbmcgui.Dialog()
        ret = dialog.select(header, options)
        del dialog
        if ret == 0:
            # Refresh item (auto lookup)
            self.get_music_artwork(artist, album, track, disc, ignore_cache=True)
        elif ret == 1:
            # Choose art
            self.get_music_artwork(artist, album, track, disc, ignore_cache=True, manual=True)
        elif ret == 2:
            # Open addon settings
            xbmc.executebuiltin("Addon.OpenSettings(%s)" % ADDON_ID)
项目:plugin.video.exodus    作者:lastship    | 项目源码 | 文件源码
def get(version):
    try:
        import xbmc,xbmcgui,xbmcaddon,xbmcvfs

        f = xbmcvfs.File(xbmcaddon.Addon().getAddonInfo('changelog'))
        text = f.read() ; f.close()

        label = '%s - %s' % (xbmc.getLocalizedString(24054), xbmcaddon.Addon().getAddonInfo('name'))

        id = 10147

        xbmc.executebuiltin('ActivateWindow(%d)' % id)
        xbmc.sleep(100)

        win = xbmcgui.Window(id)

        retry = 50
        while (retry > 0):
            try:
                xbmc.sleep(10)
                win.getControl(1).setLabel(label)
                win.getControl(5).setText(text)
                retry = 0
            except:
                retry -= 1

        return '1'
    except:
        return '1'
项目:YoutubeTV    作者:dude56987    | 项目源码 | 文件源码
def removeChannel(self,channelUsername):
        '''
        Remove channel with username channelUsername.

        :return None
        '''
        # check if channel exists in channels
        if channelUsername in self.cache.names:
            # remove the channel from the cache
            self.cache.deleteValue(channelUsername)
            # if channel has playlists in cache
            if channelUsername in self.playlistCache.names:
                # delete the playlists for the channel
                self.playlistCache.deleteValue(channelUsername)
            # delte the channel timer
            #del self.timer[channelUsername]
            self.timer.deleteValue(channelUsername)
            # delete the channel playlist timers
            #for timer in self.timer.keys():
            killArray=[]
            for timer in self.timer.names:
                if channelUsername+':' in timer:
                    killArray.append(timer)
                    #del self.timer[timer]
            for item in killArray:
                self.timer.deleteValue(item)
        # save the changes to the data
        xbmc.executebuiltin('container.Update('+_url+',replace)')
        popup('YoutubeTV','Channel '+channelUsername+' removed')
项目:nuodtayo.tv    作者:benaranguren    | 项目源码 | 文件源码
def play_video(episode_url, thumbnail):

    episodeDetails = {}

    for i in range(int(this.getSetting('loginRetries')) + 1):
        episodeDetails = get_media_info(episode_url)
        if episodeDetails and episodeDetails.get('StatusCode', 0) == 1:
            break
        else:
            login()

    if episodeDetails and episodeDetails.get('StatusCode', 0) == 1:
        media_url = episodeDetails['MediaReturnObj']['uri']
        common.log(episodeDetails['MediaReturnObj']['live'] == False)
        if not episodeDetails['MediaReturnObj']['live']:
            # re-enable bw limiting in v0.1.12. Streams has very variable rate
            # and without this limits, the stream will drop.
            media_url = media_url.replace('&b=100-1000', '&b=100-6000')
            server_override_enable = this.getSetting('server_override_enable')
            server_override_url = this.getSetting('server_override_url')
            common.log('#'*30)
            common.log(server_override_url)
            common.log(server_override_enable)
            if server_override_enable.lower() == 'true' and server_override_url:
                media_url = media_url.replace('http://o2-i.',
                                              server_override_url)

        liz = xbmcgui.ListItem(name, iconImage="DefaultVideo.png",
                               thumbnailImage=thumbnail, path=media_url)
        liz.setInfo(type="Video", infoLabels={"Title": name})
        liz.setProperty('IsPlayable', 'true')

        return xbmcplugin.setResolvedUrl(thisPlugin, True, liz)
    else:
        default_msg = 'Subscription is already expired \
                       or the item is not part of your \
                       subscription.'
        status_msg = episodeDetails.get('StatusMessage', default_msg)
        xbmc.executebuiltin('Notification(%s, %s)' % \
                            ('Media Error', status_msg))
项目:nuodtayo.tv    作者:benaranguren    | 项目源码 | 文件源码
def show_message(message, title=xbmcaddon.Addon().getLocalizedString(50107)):
    if not message:
        return
    xbmc.executebuiltin("ActivateWindow(%d)" % (10147, ))
    win = xbmcgui.Window(10147)
    xbmc.sleep(100)
    win.getControl(1).setLabel(title)
    win.getControl(5).setText(message)
项目:cmik.xbmc    作者:cmik    | 项目源码 | 文件源码
def showMessage(message, title = lang(50001)):
    if not message:
        return
    xbmc.executebuiltin("ActivateWindow(%d)" % 10147)
    win = xbmcgui.Window(10147)
    xbmc.sleep(100)
    win.getControl(1).setLabel(title)
    win.getControl(5).setText(message)
项目:cmik.xbmc    作者:cmik    | 项目源码 | 文件源码
def showNotification(message, title=lang(50001)):
    xbmc.executebuiltin('Notification(%s, %s)' % (title, message))
项目:script.skin.helper.skinbackup    作者:marcelveldt    | 项目源码 | 文件源码
def restore_guisettings(self, filename, progressdialog):
        '''restore guisettings'''
        kodifile = xbmcvfs.File(filename, 'r')
        data = kodifile.read()
        importstring = eval(data)
        kodifile.close()
        xbmc.sleep(200)
        for count, skinsetting in enumerate(importstring):

            if progressdialog and progressdialog.iscanceled():
                return

            setting = skinsetting[1]
            settingvalue = skinsetting[2]

            if progressdialog:
                progressdialog.update((count * 100) / len(importstring),
                                      '%s %s' % (self.addon.getLocalizedString(32033), setting))

            if skinsetting[0] == "string":
                if settingvalue:
                    xbmc.executebuiltin("Skin.SetString(%s,%s)" % (setting, settingvalue))
                else:
                    xbmc.executebuiltin("Skin.Reset(%s)" % setting)
            elif skinsetting[0] == "bool":
                if settingvalue == "true":
                    xbmc.executebuiltin("Skin.SetBool(%s)" % setting)
                else:
                    xbmc.executebuiltin("Skin.Reset(%s)" % setting)
            xbmc.sleep(30)
项目:plugin.video.bdyun    作者:caasiu    | 项目源码 | 文件源码
def showNotification(title,message, time=4000):
    """Show Notification

    Args: 
        title: has to be unicode
        message: has to be unicode
        time: Time that the message is beeing displayed
    """
    __addoniconpath__ = os.path.join(addon_dir(),"icon.png")
    log(u'Notification. %s: %s' % (title, message) )
    xbmc.executebuiltin(encode('Notification("' + title + '","' + message + '",'+(str(time)).decode('utf-8')+',"' + __addoniconpath__ + '")'))
项目:plugin.video.bdyun    作者:caasiu    | 项目源码 | 文件源码
def clear_cache():
    info = plugin.get_storage('info')
    homemenu = plugin.get_storage('homemenu')
    pcs_info = plugin.get_storage('pcs_info')
    info.clear()
    homemenu.clear()
    pcs_info.clear()
    dialog.notification('', u'????', xbmcgui.NOTIFICATION_INFO, 3000)
    xbmc.executebuiltin('Container.Refresh')
    return
项目:plugin.video.bdyun    作者:caasiu    | 项目源码 | 文件源码
def refresh():
    homemenu = plugin.get_storage('homemenu')
    homemenu.clear()
    xbmc.executebuiltin('Container.Refresh')
项目:konsodi    作者:kharts    | 项目源码 | 文件源码
def notify(message):
    """
    Opens notification window with message
    :param: message: str - message
    :return: None
    """
    icon = ""  # os.path.join(addonFolder, "icon.png")
    xbmc.executebuiltin(unicode('XBMC.Notification(' + message + ',3000,' + icon + ')').encode("utf-8"))
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def get_auth_token(self):
        '''check for valid credentials and grab token'''
        auth_token = None
        username = self.addon.getSetting("username").decode("utf-8")
        password = self.addon.getSetting("password").decode("utf-8")
        if username and password:
            self.spotty.username = username
            self.spotty.password = password
            auth_token = get_token(self.spotty)
        if auth_token:
            log_msg("Retrieved auth token")
            # store authtoken as window prop for easy access by plugin entry
            xbmc.executebuiltin("SetProperty(spotify-token, %s, Home)" % auth_token['access_token'])
        return auth_token