『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
楼主: syjjx

[插件集成] 小爱同学TTS服务(2019年5月29日更新可用版本)

  [复制链接]

0

主题

18

帖子

80

积分

注册会员

Rank: 2

积分
80
金钱
62
HASS币
0
发表于 2018-5-6 20:52:44 | 显示全部楼层
強大: 全部的LOG在底下 可否指點一下,感謝。

--- Logging error ---
Traceback (most recent call last):
  File "hello_miai.py", line 231, in _get_logon_info
    with open(self._login_info_dir+'/config.json','r',encoding='utf-8') as json_         file:
FileNotFoundError: [Errno 2] No such file or directory: '../.xiaoai/config.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "hello_miai.py", line 93, in _get_sign
    self._cookies['pass_ua']=self._request.cookies.get_dict()['pass_ua']
KeyError: 'pass_ua'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/logging/__init__.py", line 981, in emit
    msg = self.format(record)
  File "/usr/lib/python3.5/logging/__init__.py", line 831, in format
    return fmt.format(record)
  File "/usr/lib/python3.5/logging/__init__.py", line 568, in format
    record.message = record.getMessage()
  File "/usr/lib/python3.5/logging/__init__.py", line 331, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "hello_miai.py", line 255, in <module>
    xiaomi_tts(miid,password,login_info_dir='../.xiaoai',can_input_capt=True).sp         eech("Token已生成",int(num))
  File "hello_miai.py", line 81, in __init__
    self._get_logon_info()
  File "hello_miai.py", line 237, in _get_logon_info
    self._serviceToken()
  File "hello_miai.py", line 157, in _serviceToken
    _serviceLoginAuth2_json=self._serviceLoginAuth2()
  File "hello_miai.py", line 108, in _serviceLoginAuth2
    self._sign=self._get_sign()  #获取sign
  File "hello_miai.py", line 98, in _get_sign
    _LOGGER.error('_get_sign',e)
Message: '_get_sign'
Arguments: (KeyError('pass_ua',),)
Traceback (most recent call last):
  File "hello_miai.py", line 231, in _get_logon_info
    with open(self._login_info_dir+'/config.json','r',encoding='utf-8') as json_         file:
FileNotFoundError: [Errno 2] No such file or directory: '../.xiaoai/config.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "hello_miai.py", line 255, in <module>
    xiaomi_tts(miid,password,login_info_dir='../.xiaoai',can_input_capt=True).sp         eech("Token已生成",int(num))
  File "hello_miai.py", line 81, in __init__
    self._get_logon_info()
  File "hello_miai.py", line 237, in _get_logon_info
    self._serviceToken()
  File "hello_miai.py", line 157, in _serviceToken
    _serviceLoginAuth2_json=self._serviceLoginAuth2()
  File "hello_miai.py", line 109, in _serviceLoginAuth2
    self._headers['Cookie']='pass_ua={}; deviceId={}; pass_trace={}; uLocale={};          JSESSIONID={}'.format(self._cookies['pass_ua'],self._cookies['deviceId'],self._         cookies['pass_trace'],self._cookies['uLocale'],self._cookies['JSESSIONID'])              
KeyError: 'pass_ua'
回复

使用道具 举报

7

主题

125

帖子

852

积分

高级会员

Rank: 4

积分
852
金钱
727
HASS币
0
发表于 2018-5-6 21:08:07 | 显示全部楼层
syjjx 发表于 2018-5-6 20:07
[code]    - service: hello_miai.send
      data_template:
        message ...

谢谢。搞定
我把 data_template:  写成了 data: 这差别太大了啊
回复

使用道具 举报

15

主题

192

帖子

2057

积分

论坛技术达人

积分
2057
金钱
1845
HASS币
0

卓越贡献

 楼主| 发表于 2018-5-6 21:10:40 | 显示全部楼层
jozhi 发表于 2018-5-6 20:51
我的錯誤如下

During handling of the above exception, another exception occurred:
            r = self._request.get(url,headers=self._headers,timeout=3)
            _LOGGER.error(self._request.cookies.get_dict())
            _LOGGER.error(r.text)

在89行,r = self._request.get(url,headers=self._headers,timeout=3)
新增下面两行,然后再运行一次,看看日志中的这两行记录的详细数据
回复

使用道具 举报

0

主题

18

帖子

80

积分

注册会员

Rank: 2

积分
80
金钱
62
HASS币
0
发表于 2018-5-6 21:10:59 | 显示全部楼层
本帖最后由 flame0205 于 2018-5-6 21:14 编辑

請教一下:

Arguments: (KeyError('pass_ua',),)
获取_sign出错!

大概是什麼意思感謝。

以下是整句的LOG,請參考,謝謝。

--- Logging error ---
Traceback (most recent call last):
  File "hello_miai.py", line 230, in _get_logon_info
    with open(self._login_info_dir+'/config.json','r',encoding='utf-8') as json_file:
FileNotFoundError: [Errno 2] No such file or directory: '../.xiaoai/config.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "hello_miai.py", line 93, in _get_sign
    self._cookies['pass_ua']=self._request.cookies.get_dict()['pass_ua']
KeyError: 'pass_ua'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/logging/__init__.py", line 981, in emit
    msg = self.format(record)
  File "/usr/lib/python3.5/logging/__init__.py", line 831, in format
    return fmt.format(record)
  File "/usr/lib/python3.5/logging/__init__.py", line 568, in format
    record.message = record.getMessage()
  File "/usr/lib/python3.5/logging/__init__.py", line 331, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "hello_miai.py", line 254, in <module>
    xiaomi_tts(miid,password,login_info_dir='../.xiaoai',can_input_capt=True).speech("Token已生成",int(num))
  File "hello_miai.py", line 81, in __init__
    self._get_logon_info()
  File "hello_miai.py", line 236, in _get_logon_info
    self._serviceToken()
  File "hello_miai.py", line 156, in _serviceToken
    _serviceLoginAuth2_json=self._serviceLoginAuth2()
  File "hello_miai.py", line 108, in _serviceLoginAuth2
    self._sign=self._get_sign()  #获取sign
  File "hello_miai.py", line 98, in _get_sign
    _LOGGER.error('_get_sign',e)
Message: '_get_sign'
Arguments: (KeyError('pass_ua',),)
获取_sign出错!
Traceback (most recent call last):
  File "hello_miai.py", line 230, in _get_logon_info
    with open(self._login_info_dir+'/config.json','r',encoding='utf-8') as json_file:
FileNotFoundError: [Errno 2] No such file or directory: '../.xiaoai/config.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "hello_miai.py", line 254, in <module>
    xiaomi_tts(miid,password,login_info_dir='../.xiaoai',can_input_capt=True).speech("Token已生成",int(num))
  File "hello_miai.py", line 81, in __init__
    self._get_logon_info()
  File "hello_miai.py", line 236, in _get_logon_info
    self._serviceToken()
  File "hello_miai.py", line 157, in _serviceToken
    if _serviceLoginAuth2_json['code']==0:
TypeError: 'NoneType' object is not subscriptable


回复

使用道具 举报

15

主题

192

帖子

2057

积分

论坛技术达人

积分
2057
金钱
1845
HASS币
0

卓越贡献

 楼主| 发表于 2018-5-6 21:17:34 | 显示全部楼层
本帖最后由 syjjx 于 2018-5-6 21:19 编辑
flame0205 发表于 2018-5-6 21:10
請教一下:

Arguments: (KeyError('pass_ua',),)

看63楼,自己修改下代码,在运行下,我看看你们获取的cookie和html文本
或者你直接用浏览器访问下https://account.xiaomi.com/pass/serviceLogin?sid=micoapi看看你在浏览器中获取到的cookie是什么
回复

使用道具 举报

9

主题

358

帖子

3123

积分

论坛元老

Rank: 8Rank: 8

积分
3123
金钱
2765
HASS币
0
发表于 2018-5-6 21:19:33 | 显示全部楼层
syjjx 发表于 2018-5-6 21:10
[code]            r = self._request.get(url,headers=self._headers,timeout=3)
   ...

我加這兩行上去以後....
开发者工具的service下找不到hello_miai.send这个服务了@@
回复

使用道具 举报

15

主题

192

帖子

2057

积分

论坛技术达人

积分
2057
金钱
1845
HASS币
0

卓越贡献

 楼主| 发表于 2018-5-6 21:24:00 | 显示全部楼层
jozhi 发表于 2018-5-6 21:19
我加這兩行上去以後....
开发者工具的service下找不到hello_miai.send这个服务了@@ ...

日志中有报错信息的,应该是tab缩进和空格缩进的问题
回复

使用道具 举报

0

主题

7

帖子

78

积分

注册会员

Rank: 2

积分
78
金钱
71
HASS币
0
发表于 2018-5-6 21:25:52 | 显示全部楼层
看看看看!
回复

使用道具 举报

0

主题

18

帖子

80

积分

注册会员

Rank: 2

积分
80
金钱
62
HASS币
0
发表于 2018-5-6 21:26:35 | 显示全部楼层
syjjx 发表于 2018-5-6 21:17
看63楼,自己修改下代码,在运行下,我看看你们获取的cookie和html文本
或者你直接用浏览器访问下https:// ...

強大 修改代碼後顯示如下: 請參考

{'deviceId': 'wb_26283e42-bd17-435d-9fd6-d0db365675f2', 'pass_trace': 'ga8bp4BxxtQhPgnOA5ocVUUrAuDVwaBoYiczOf3oc6emP2KzlLpxYW5/xNe2OjD3JYvRn3jmrBxS40Rxkb14bwj7UB2+TuZ2HJlWWH4Ch2Kgkuxv9KtEDTgYVgX8ZK1A', 'uLocale': 'zh_CN', 'JSESSIONID': 'aaa7ILExYaZ_a7nEFPLmw'}


<!doctype html>
<meta name="description" content="小米帐号能使用小米手机,MIUI,小米云,多看阅读,米聊,小米社区等小米服务。" />
<meta name="keywords" content="小米帐号,小米账号,小米注册,注册,Mi Account,Sign in,小米,帐号,账号,小米帐户,登录,登陆,安全令牌,动态口令,小米注册,找回密码" />

<script>
var _d_={};
var _t_={
  statURL:'https://data.mistat.xiaomi.com/mistats',
  appId:"2882303761517246742",
  appKey:"5621724658742",
  jspcompletenew Date()).getTime(),
  supportLocalstorage:!!window.localStorage,
  samplingBase:100,
  samplingRate:5
};
if(window.performance){
  var timing=performance.timing;
  if(!timing.responseEnd){
    timing.responseEnd=timing.responseStart;
  }
  _d_.startTS=timing.fetchStart
  _d_.endTS=timing.responseEnd;
}else{
  _d_.startTS=_d_.endTS=(new Date()).getTime();
}
var JSP_VAR={
  deviceType:'PC',
  dataCenter:'sgp',
  dataCenterZone:'Singapore',
  locale:"zh_CN",
  region:"TW",
  callback:"https://api.mina.mi.com/sts",
  sid:"micoapi",
  qs:"%3Fsid%3Dmicoapi",
  hidden:"",
  "_sign":"7r4bjQjlOIJHfZD0jfrFpfe2xLs=",
  serviceParam :'{"checkSafePhone":false}',
  privacyLink:'http://www.miui.com/res/doc/privacy/cn.html',
  agreeLink:'http://www.miui.com/res/doc/eula/cn.html'
};
var PAGE_VAR={
  form_cache:false,
  cache_keyJSP_VAR.deviceType!=="mobile" ? "/static/res/25fadc9/account-static/html/login/dist/v2/sgp/login-cn.html" : "/static/res/25fadc9/account-static/html/login/dist/v2/sgp/login-wap-cn.html")
};
if(location.search.indexOf("_debugMode")>-1){
  window.localStorage && window.localStorage.removeItem(PAGE_VAR.cache_key);
}
(function(){
  function getLocal(url){
    if(window.localStorage){
      var data=localStorage.getItem(url);
      return data;
    }
    return null;
  }
  function setLocal(url,data){
    if(window.localStorage && data){
      try{
        localStorage.setItem(url,data);
      }catch(e){}
    }
  }
  function getContent(url){
    var xhr= new (window.XMLHttpRequest || window.ActiveXObject)("Microsoft.XMLHTTP");
    xhr.onreadystatechange = function() {
      if (xhr.readyState == 4 && xhr.status == 200) {
          setLocal(url,xhr.responseText);
          _t_.htmlGetEnd=(new Date()).getTime();
          document.write(xhr.responseText);
          document.close();
      }
    };
    xhr.open("GET",url,false);
    xhr.send();
  }
  var cache_key=PAGE_VAR.cache_key;
      _t_.version=cache_key;
  var html=getLocal(cache_key);
  if(html){
    _t_.htmlCache=true;
    PAGE_VAR.form_cache=true;
    document.write(html);
    document.close();
  }else{
    _t_.htmlCache=false;
    _t_.htmlGetStart=(new Date()).getTime();
    getContent(cache_key);
  }
})();
</script>

--- Logging error ---
Traceback (most recent call last):
  File "hello_miai.py", line 232, in _get_logon_info
    with open(self._login_info_dir+'/config.json','r',encoding='utf-8') as json_file:
FileNotFoundError: [Errno 2] No such file or directory: '../.xiaoai/config.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "hello_miai.py", line 95, in _get_sign
    self._cookies['pass_ua']=self._request.cookies.get_dict()['pass_ua']
KeyError: 'pass_ua'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/logging/__init__.py", line 981, in emit
    msg = self.format(record)
  File "/usr/lib/python3.5/logging/__init__.py", line 831, in format
    return fmt.format(record)
  File "/usr/lib/python3.5/logging/__init__.py", line 568, in format
    record.message = record.getMessage()
  File "/usr/lib/python3.5/logging/__init__.py", line 331, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "hello_miai.py", line 256, in <module>
    xiaomi_tts(miid,password,login_info_dir='../.xiaoai',can_input_capt=True).speech("Token已生成",int(num))
  File "hello_miai.py", line 81, in __init__
    self._get_logon_info()
  File "hello_miai.py", line 238, in _get_logon_info
    self._serviceToken()
  File "hello_miai.py", line 158, in _serviceToken
    _serviceLoginAuth2_json=self._serviceLoginAuth2()
  File "hello_miai.py", line 110, in _serviceLoginAuth2
    self._sign=self._get_sign()  #获取sign
  File "hello_miai.py", line 100, in _get_sign
    _LOGGER.error('_get_sign',e)
Message: '_get_sign'
Arguments: (KeyError('pass_ua',),)
获取_sign出错!
Traceback (most recent call last):
  File "hello_miai.py", line 232, in _get_logon_info
    with open(self._login_info_dir+'/config.json','r',encoding='utf-8') as json_file:
FileNotFoundError: [Errno 2] No such file or directory: '../.xiaoai/config.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "hello_miai.py", line 256, in <module>
    xiaomi_tts(miid,password,login_info_dir='../.xiaoai',can_input_capt=True).speech("Token已生成",int(num))
  File "hello_miai.py", line 81, in __init__
    self._get_logon_info()
  File "hello_miai.py", line 238, in _get_logon_info
    self._serviceToken()
  File "hello_miai.py", line 159, in _serviceToken
    if _serviceLoginAuth2_json['code']==0:
TypeError: 'NoneType' object is not subscriptable

回复

使用道具 举报

9

主题

358

帖子

3123

积分

论坛元老

Rank: 8Rank: 8

积分
3123
金钱
2765
HASS币
0
发表于 2018-5-6 21:27:52 | 显示全部楼层
syjjx 发表于 2018-5-6 21:24
日志中有报错信息的,应该是tab缩进和空格缩进的问题

搞不好是網頁的關係
我直接連到https://account.xiaomi.com/pass/serviceLogin?sid=micoapi
輸入帳號密碼以後 他直接報錯誤401無法開啟網頁
ScreenHunter_032.jpg
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-12-23 21:58 , Processed in 0.074870 second(s), 33 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表