python类Dialog()的实例源码

editor.py 文件源码 项目:script.tvguide.fullscreen 作者: primaeval 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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
sdAPI.py 文件源码 项目:script.tvguide.fullscreen 作者: primaeval 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
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
adobepass.py 文件源码 项目:plugin.video.nbcsnliveextra 作者: eracknaphobia 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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
musicartwork.py 文件源码 项目:script.module.metadatautils 作者: marcelveldt 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
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)
utils.py 文件源码 项目:context.elementum 作者: elgatito 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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)
utils.py 文件源码 项目:context.elementum 作者: elgatito 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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
control.py 文件源码 项目:plugin.video.exodus 作者: lastship 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def idle():
    return execute('Dialog.Close(busydialog)')
kodiutils.py 文件源码 项目:screensaver.kaster 作者: enen92 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def notification(header, message, time=5000, icon=ADDON.getAddonInfo('icon'), sound=True):
    xbmcgui.Dialog().notification(header, message, icon, time, sound)
main.py 文件源码 项目:YoutubeTV 作者: dude56987 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
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
default.py 文件源码 项目:cmik.xbmc 作者: cmik 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def confirm(message, line1='', line2='', title=lang(50001)):
    if not message:
        return
    return xbmcgui.Dialog().yesno(title, message, line1, line2)
default.py 文件源码 项目:cmik.xbmc 作者: cmik 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def alert(message, line1='', line2='', title=lang(50001)):
    if not message:
        return
    return xbmcgui.Dialog().ok(title, message, line1, line2)
colorthemes.py 文件源码 项目:script.skin.helper.skinbackup 作者: marcelveldt 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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)
backuprestore.py 文件源码 项目:script.skin.helper.skinbackup 作者: marcelveldt 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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
backuprestore.py 文件源码 项目:script.skin.helper.skinbackup 作者: marcelveldt 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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
backuprestore.py 文件源码 项目:script.skin.helper.skinbackup 作者: marcelveldt 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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_content.py 文件源码 项目:plugin.audio.spotify 作者: marcelveldt 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
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_content.py 文件源码 项目:plugin.audio.spotify 作者: marcelveldt 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
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_content.py 文件源码 项目:plugin.audio.spotify 作者: marcelveldt 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
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])
gPlayer.py 文件源码 项目:Python-GoogleDrive-VideoStream 作者: ddurdle 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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)
common.py 文件源码 项目:plugin.video.auvio 作者: rickybiscus 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def ask(question):
    dialog = xbmcgui.Dialog()
    title = plugin.addon.getAddonInfo('name')
    return dialog.yesno(title, question)


问题


面经


文章

微信
公众号

扫码关注公众号