kodihelper.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:kodi-viaplay 作者: emilsvennesson 项目源码 文件源码
def device_registration(self):
        """Presents a dialog with information on how to activate the device.
        Attempts to authorize the device using the interval returned by the activation data."""
        activation_data = self.vp.get_activation_data()
        message = self.language(30039).format(activation_data['verificationUrl'], activation_data['userCode'])
        dialog = xbmcgui.DialogProgress()
        xbmc.sleep(200)  # small delay to prevent DialogProgress from hanging
        dialog.create(self.language(30040), message)
        secs = 0
        expires = activation_data['expires']

        while secs < expires:
            try:
                self.vp.authorize_device(activation_data)
                dialog.close()
                return True
            except self.vp.ViaplayError as error:
                # raise all non-pending authorization errors
                if not error.value == 'DeviceAuthorizationPendingError':
                    raise
            secs += activation_data['interval']
            percent = int(100 * float(secs) / float(expires))
            dialog.update(percent, message)
            xbmc.sleep(activation_data['interval'] * 1000)
            if dialog.iscanceled():
                dialog.close()
                return False

        dialog.close()
        return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号