Esempio n. 1
0
    def e_id(self, tok):

        bt = baidu_tts()
        setting = setting.setting()
        url = setting['smarthome']['url']
        port = setting['smarthome']['port']
        passwd = setting['smarthome']['passwd']
        service = '/api/states'
        headers = {'x-ha-access': passwd, 'content-type': 'application/json'}

        r = requests.get(url + ':' + port + service, headers=headers)

        r_json = r.json()
        e_id = {}
        try:
            for r_jsons in r_json:
                entity_id = r_jsons['entity_id']
                friendly_name = r_jsons['attributes']['friendly_name']
                domain = entity_id.split(".")[0]
                e_id[friendly_name] = entity_id
        except TypeError:
            bt.tts('homeassistant设备实体码获取失败', tok)
            speaker.speak()
        else:
            return e_id
Esempio n. 2
0
 def make_headers(self):
     chrome_version = str(random.randint(59, 63)) + '.0.' + str(
         random.randint(1000, 3200)) + '.94'
     headers = {
         # "Host":"yangkeduo.com",
         # "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
         # "Accept-Language":"zh-CN,zh;q=0.9,en;q=0.8",
         # "Accept-Encoding":"gzip, deflate",
         # "Host":"yangkeduo.com",
         # "Referer":"http://mobile.yangkeduo.com/",
         # "Connection":"keep-alive",
         # 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/'+chrome_version+' Safari/537.36',
         # "Host":"mobile.yangkeduo.com",
         # "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
         # "Accept-Language":"zh-CN,zh;q=0.9,en;q=0.8",
         # "Accept-Encoding":"gzip, deflate",
         # "Host":"mobile.yangkeduo.com",
         "Referer": "Android",
         # "Connection":"keep-alive",
         "Cookie": 'api_uid=',
         "AccessToken": "",
         'Content-Type': 'application/json',
         'ETag': self.get_ETag(),
         'X-PDD-QUERIES':
         'width=720&height=1356&net=1&brand=4G&model=4G&osv=6.0&appv=4.49.2&pl=2',
         'User-Agent': setting.setting().get_android_user_agent(),
     }
     return headers
Esempio n. 3
0
    def make_headers(self):
        chrome_version = str(random.randint(59, 63)) + '.0.' + str(
            random.randint(1000, 3200)) + '.94'
        # headers = {
        # 	"Host":"mobile.yangkeduo.com",
        # 	"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        # 	"Accept-Language":"zh-CN,zh;q=0.9,en;q=0.8",
        # 	"Accept-Encoding":"gzip, deflate",
        # 	"Host":"yangkeduo.com",
        # 	"Referer":"http://yangkeduo.com/goods.html?goods_id=442573047&from_subject_id=935&is_spike=0&refer_page_name=subject&refer_page_id=subject_1515726808272_1M143fWqjQ&refer_page_sn=10026",
        # 	"Connection":"keep-alive",
        # 	'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/'+chrome_version+' Safari/537.36',
        # }
        #
        headers = {
            # "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
            # "Accept-Language":"zh-CN,zh;q=0.9,en;q=0.8",
            # "Accept-Encoding":"gzip, deflate",
            "Referer": "Android",
            # "Connection":"keep-alive",
            'User-Agent': setting.setting().get_default_user_agent(),
            #'User-Agent':'Mozilla/5.0 (iPhone; CPU iPhone OS 11_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15F79 ===  iOS/11.4 Model/iPhone9,1 BundleID/com.xunmeng.pinduoduo AppVersion/4.15.0 AppBuild/1807251632 cURL/7.47.0',
            #'AccessToken':'TCEQ2DM4MRHLIDZVEB6MFP3JOENREVWSO2IH77PI3MUV4Q6GGF3A1017c59',
            "AccessToken": "",
            "Cookie": "api_uid="
        }

        # ip = str(random.randint(100, 200))+'.'+str(random.randint(1, 255))+'.'+str(random.randint(1, 255))+'.'+str(random.randint(1, 255))
        # headers['CLIENT-IP'] 	=	ip
        # headers['X-FORWARDED-FOR']=	ip
        return headers
Esempio n. 4
0
    def make_headers(self):
        chrome_version = str(random.randint(59, 63)) + '.0.' + str(
            random.randint(1000, 3200)) + '.94'
        headers = {
            # "Host":"mobile.yangkeduo.com",
            # "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
            # "Accept-Language":"zh-CN,zh;q=0.9,en;q=0.8",
            # "Accept-Encoding":"gzip, deflate",
            # "Referer":"http://yangkeduo.com/goods.html?goods_id=442573047&from_subject_id=935&is_spike=0&refer_page_name=subject&refer_page_id=subject_1515726808272_1M143fWqjQ&refer_page_sn=10026",
            # "Connection":"keep-alive",
            # 'User-Agent':'phh_android_version/Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/'+chrome_version+' Safari/537.36',
            #"Host":"mobile.yangkeduo.com",
            #"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
            #"Accept-Language":"zh-CN,zh;q=0.9,en;q=0.8",
            #"Accept-Encoding":"gzip, deflate",
            #"Host":"yangkeduo.com",
            "Referer": "Android",
            "Cookie": 'api_uid=',
            "AccessToken": "",
            #"Connection":"keep-alive",
            'User-Agent': setting.setting().get_default_user_agent(),
        }

        # ip = str(random.randint(100, 200))+'.'+str(random.randint(1, 255))+'.'+str(random.randint(1, 255))+'.'+str(random.randint(1, 255))
        # headers['CLIENT-IP'] 	=	ip
        # headers['X-FORWARDED-FOR']=	ip
        return headers
Esempio n. 5
0
    def make_headers(self):
        chrome_version = str(random.randint(59, 63)) + '.0.' + str(
            random.randint(1000, 3200)) + '.94'
        headers = {
            # "Host":"yangkeduo.com",
            # "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
            # "Accept-Language":"zh-CN,zh;q=0.9,en;q=0.8",
            # "Accept-Encoding":"gzip, deflate",
            # "Host":"yangkeduo.com",
            # "Referer":"http://mobile.yangkeduo.com/",
            # "Connection":"keep-alive",
            # 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/'+chrome_version+' Safari/537.36',
            # "Host":"mobile.yangkeduo.com",
            # "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
            # "Accept-Language":"zh-CN,zh;q=0.9,en;q=0.8",
            # "Accept-Encoding":"gzip, deflate",
            # "Host":"mobile.yangkeduo.com",
            "Referer": "Android",
            # "Connection":"keep-alive",
            "Cookie": 'api_uid=',
            "AccessToken": "",
            'User-Agent': setting.setting().get_android_user_agent(),
        }

        # ip = str(random.randint(100, 200))+'.'+str(random.randint(1, 255))+'.'+str(random.randint(1, 255))+'.'+str(random.randint(1, 255))
        # headers['CLIENT-IP'] 	=	ip
        # headers['X-FORWARDED-FOR']=	ip
        return headers
Esempio n. 6
0
    def tts(self, saytext, lang):

        y = youdao_tts()
        selfset = setting.setting()
        appSecret = selfset['main_setting']['YOUDAO_TTS_SET']['appkey']
        appKey = selfset['main_setting']['YOUDAO_TTS_SET']['appid']
        data = {}
        salt = random.randint(1, 65536)

        sign = appKey + q + str(salt) + appSecret
        m1 = md5.new()
        m1.update(sign)
        sign = m1.hexdigest()

        data['appKey'] = appKey
        data['q'] = q
        data['salt'] = salt
        data['sign'] = sign
        data['langType'] = lang
        response = requests.post('http://openapi.youdao.com/ttsapi', data=data)

        contentType = response.headers['content-type']

        if contentType == "audio/mp3":
            filePath = "/home/pi/xiaolan/musiclib/" + 'say' + ".mp3"
            fo = open(filePath, 'wb')
            fo.write(response.content)
            fo.close()
        else:
            y.tts('对不起,我的语言中枢出错了,我不能跟你说话了', 'zh-CHS')
            speaker.speak()
Esempio n. 7
0
    def make_headers(self):
        chrome_version = str(random.randint(59, 63)) + '.0.' + str(
            random.randint(1000, 3200)) + '.94'
        headers = {
            # "Host":"yangkeduo.com",
            # "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
            # "Accept-Language":"zh-CN,zh;q=0.9,en;q=0.8",
            # "Accept-Encoding":"gzip, deflate",
            # "Host":"yangkeduo.com",
            # "Referer":"http://yangkeduo.com",
            # "Connection":"keep-alive",
            # 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/'+chrome_version+' Safari/537.36',
            # "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
            # "Accept-Language":"zh-CN,zh;q=0.9,en;q=0.8",
            # "Accept-Encoding":"gzip, deflate",
            # "Host":"yangkeduo.com",
            "Referer": "Android",
            # "Connection":"keep-alive",
            "Cookie": 'api_uid=',
            'User-Agent': setting.setting().get_default_user_agent(),
            #'User-Agent':'Mozilla/5.0 (iPhone; CPU iPhone OS 11_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15F79 ===  iOS/11.4 Model/iPhone9,1 BundleID/com.xunmeng.pinduoduo AppVersion/4.15.0 AppBuild/1807251632 cURL/7.47.0',
            'AccessToken': '',
        }

        # ip = str(random.randint(100, 200))+'.'+str(random.randint(1, 255))+'.'+str(random.randint(1, 255))+'.'+str(random.randint(1, 255))
        # headers['CLIENT-IP'] 	=	ip
        # headers['X-FORWARDED-FOR']=	ip
        return headers
Esempio n. 8
0
def run_game():
    pygame.init()
    ai_setting = setting()
    scree = pygame.display.set_mode(
        (ai_setting.screen_width, ai_setting.screen_hight))
    aliens = Group()
    ship = Ship(scree, ai_setting)
    alien = Alien(ai_setting, scree)
    gf.create_fleet(ai_setting, scree, ship, aliens)
    bullets = Group()
    pygame.display.set_caption('New game')
    stats = GameStats(ai_setting)
    sb = Scoreboard(ai_setting, scree, stats)
    play_button = Button(ai_setting, scree, "Play")

    while True:
        gf.check_events(ship, ai_setting, scree, bullets, stats, play_button,
                        aliens)
        if stats.game_active:
            ship.update()
            gf.update_aliens(ai_setting, aliens, ship, stats, bullets, scree)
            gf.update_bullet(ai_setting, scree, ship, aliens, bullets, sb,
                             stats)
        gf.update_screen(ai_setting, scree, ship, bullets, aliens, play_button,
                         stats, sb)
Esempio n. 9
0
def main(text, tok):

    setting = setting.setting()
    ak = setting['tuling']['key']
    ui = setting['tuling']['user_id']
    url = 'http://openapi.tuling123.com/openapi/api/v2'
    dataf = {
        "reqType": 0,
        "perception": {
            "inputText": {
                "text": text
            },
        },
        "userInfo": {
            "apiKey": ak,
            "userId": ui
        }
    }
    data = json.dumps(dataf)
    talkback = requests.post(url, data=data)
    talkback_data = talkback.json()
    text = talkback_data["results"][-1]["values"]["text"]
    saytext = text.encode('utf-8', 'strict')
    bt = baidu_tts()
    bt.tts(saytext, tok)
    speaker.speak()
 def make_headers(self):
     headers = {
         "User-Agent": setting.setting().get_default_user_agent(),
         "AccessToken": "",
         "Referer": "Android",
         "Cookie": "api_uid="
     }
     return headers
Esempio n. 11
0
def get_intent(text):

    urlf = 'http://api.xfyun.cn/v1/aiui/v1/text_semantic?text='
    appid = setting.setting()['main_setting']['NLP']['appid']
    apikey = setting.setting()['main_setting']['NLP']['key']
    lastmdl = 'eyJ1c2VyaWQiOiIxMyIsInNjZW5lIjoibWFpbiJ9'
    curtimeo = int(time.time())
    curtimef = str(curtimeo)

    try:
        textl = base64.b64encode(text)
    except TypeError:
        intent = 'no'
        return intent

    textv = 'text=' + textl

    csumc = apikey + curtimef + 'eyJ1c2VyaWQiOiIxMyIsInNjZW5lIjoibWFpbiJ9' + textv

    c = hashlib.md5()
    c.update(csumc)
    checksuml = c.hexdigest()

    headers = {
        'X-Appid': appid,
        'Content-type': 'application/x-www-form-urlencoded; charset=utf-8',
        'X-CurTime': curtimef,
        'X-Param': 'eyJ1c2VyaWQiOiIxMyIsInNjZW5lIjoibWFpbiJ9',
        'X-CheckSum': checksuml
    }
    url = urlf + textl

    r = requests.post(url, headers=headers)
    json = r.json()
    try:
        intent = json['data']['service']
    except KeyError:
        intent = 'reintent'
        return intent
    except TypeError:
        intent = 'reintent'
        return intent
    if intent != None:
        return intent
    else:
        do_intent(text)
	def make_headers(self, keyword):
		headers = {
			"User-Agent": setting.setting().get_web_user_agent(),
			"AccessToken": "",
			"Referer": 'http://mobile.yangkeduo.com/search_result.html?search_key='+urllib.parse.quote(keyword),
			"Cookie": "api_uid=",
			'VerifyAuthToken': 'Bh5TE-gu-kYMnm75UOIGmA'
		}
		return headers
Esempio n. 13
0
 def add_new_url(self, url):
     # print("-----"+url)
     if url is None:
         print("UrlManager url is None")
         return
     sett = setting()
     # print(sett.WhiteList(url))
     # if url not in self.new_urls and url not in self.old_urls:
     if sett.WhiteList(
             url) and url not in self.new_urls and url not in self.old_urls:
         self.new_urls.add(url)
Esempio n. 14
0
	def get_ssdb_proxy_ip(self):
		ips = self.ssdb.hkeys('proxy_ip_hash', '', '', 1000)
		machine_type = setting.setting().machine_type()
		res = []
		for index in range(len(ips)):
			if index % 2 != machine_type:
				continue
			res.append(ips[index])
		if res:
			return res
		else:
			return []
Esempio n. 15
0
 def __init__(self):
     """ initialization """
     pygame.init()
     """ draw main screen """
     self.setting = setting()
     self.mainScreen = pygame.display.set_mode(
         size=(self.setting.screenWidth, self.setting.screenHeight))
     pygame.display.set_caption(self.setting.caption)
     """ load vehicle """
     self.spaceShip = Spaceship(self)
     self.bullets = pygame.sprite.Group()
     self.aliens = pygame.sprite.Group()
     self._create_fleet()
Esempio n. 16
0
def main(tok):

    url = 'http://api.avatardata.cn/Joke/QueryJokeByTime?key='
    selfset = setting.setting()
    key = selfset['joke']['key']
    bt = baidu_tts()

    r = requests.post(url + key + '&sort=asc&time=1418745237')

    json = r.json()

    bt.tts(json['result'][random.randint(0, 9)]['content'], tok)
    speaker.speak()
Esempio n. 17
0
    def __init__(self):

        self.awaken = Xiaolan.awaken()
        self.selfset = setting.setting()
        self.r = recorder()
        self.bt = baidu_tts()
        self.yt = youdao_tts()
        self.bs = baidu_stt(1, 2, 3, 4)
        self.sk = Skills()
        self.sm = hass()
        self.mu = xlMusic()
        self.ma = maps()
        self.xlnlu = Nlu()
        self.tok = bt.get_token()
Esempio n. 18
0
def main(tok):

    bt = baidu_tts()
    bs = baidu_stt(1, 'a', 2, '{')
    r = recorder()
    selfset = setting.setting()
    host = 'https://api.seniverse.com/v3/weather/now.json?key='
    key = selfset['weather']['key']

    r = requests.get(host + key + '&location=ip&language=zh-Hans&unit=c')

    json = r.json()
    bt.tts(
        ',今天的天气是,' + json['results'][0]['now']['text'] + ',温度是,' +
        json['results'][0]['now']['temperature'] + ',摄氏度,', tok)
    speaker.speak()
Esempio n. 19
0
def main(tok):
    
    bt = baidu_tts()
    yt = youdao_tts()
    bs = baidu_stt(1, 2, 3, 4)
    r = recorder()
    
    selfset = setting.setting()
    hash = hashlib.md5()
    
    bt.tts('您好,请说出您的快递单号和快递公司', tok)
    speaker.speak()
    speaker.ding()
    r.exrecord()
    speaker.dong()
    idss = bs.stt('./voice.wav', tok)
    ids = number_choose(ids, tok)
    
    requestData = {
                   'OrderCode': ids,
                   'ShipperCode': service,
                   'LogisticCode':'12345678'
        }
    
        data = {
                'EBusinessID': '1349773',
                'RequestType': '1002',
                'RequestData': parse.quote(str(requestData)),
                'DataType': '2',
        }
        strings = str(requestData) + '1f0c5c35-67a8-495f-b3ab-a7fc534a826f'
        string = strings.encode(encoding='UTF-8',errors='strict')
        hashs.update(string)
        s = hashs.hexdigest().encode('utf-8')
        y = base64.b64encode(s)
        z = str(y, 'utf-8')
        data['DataSign'] = parse.quote(z, 'utf-8')
        r = requests.post('http://api.kdniao.cc/Ebusiness/EbusinessOrderHandle.aspx',
                          data=data)
        json = r.json()
        try:
            bt.tts(json['Traces'][-1]['AcceptStation'], tok)
            speaker.speak()
        except KeyError:
            bt.tts('对不起,包裹信息查询失败', tok)
            speaker.speak()
Esempio n. 20
0
def main(tok):

    bt = baidu_tts()
    bs = baidu_stt(1, 'a', 2, '{')
    r = recorder()
    selfset = setting.setting()
    host = 'https://api.seniverse.com/v3/weather/now.json?key='
    key = selfset['weather']['key']

    data = {'key': key, 'location': 'ip', 'language': 'zh-Hans', 'unit': 'c'}
    r = requests.get(host, data=data)

    json = r.json()
    bt.tts(
        ',今天的天气是,' + json['results'][0]['now']['text'] + ',温度是,' +
        json['results'][0]['now']['temperature'] + ',摄氏度,', tok)
    speaker.speak()
Esempio n. 21
0
def welcome(tok):

    print('''

    ###################################
    #     小蓝-中文智能家居对话机器人      #
    #   (c)蓝之酱[email protected]    #
    # www.github.com/xiaoland/xiaolan #
    #         欢迎使用!!!  :)          #
    ###################################

    ''')
    bt = baidu_tts()
    selfset = setting.setting()
    bt.tts(selfset['main_setting']['your_name'] + ',你好啊,我是你的小蓝', tok)
    speaker.speak()
    os.system('pulseaudio --start')
    awaken()
Esempio n. 22
0
	def make_headers(self):
		chrome_version   = str(random.randint(59,63))+'.0.'+str(random.randint(1000,3200))+'.94'
		headers = {
			# "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
			# "Accept-Language":"zh-CN,zh;q=0.9,en;q=0.8",
			# "Accept-Encoding":"gzip, deflate",
			"Referer":"Android",
			# "Connection":"keep-alive",
			'User-Agent':setting.setting().get_default_user_agent(),
			#'User-Agent':'Mozilla/5.0 (iPhone; CPU iPhone OS 11_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15F79 ===  iOS/11.4 Model/iPhone9,1 BundleID/com.xunmeng.pinduoduo AppVersion/4.15.0 AppBuild/1807251632 cURL/7.47.0',
			#'AccessToken':'TCEQ2DM4MRHLIDZVEB6MFP3JOENREVWSO2IH77PI3MUV4Q6GGF3A1017c59',
			"AccessToken": "",
			"Cookie": "api_uid="
		}
		
		# ip = str(random.randint(100, 200))+'.'+str(random.randint(1, 255))+'.'+str(random.randint(1, 255))+'.'+str(random.randint(1, 255))
		# headers['CLIENT-IP'] 	=	ip
		# headers['X-FORWARDED-FOR']=	ip
		return headers
Esempio n. 23
0
def main(tok):

    bt = baidu_tts()
    bs = baidu_stt(1, 'a', 2, '{')
    r = recorder()
    host = 'https://api.seniverse.com/v3/weather/now.json?key='
    key = setting.setting()['weather']['key']
    APIURL = key + '&location=ip&language=zh-Hans&unit=c'
    
    url = host + APIURL

    r = requests.get(url)
    
    json = r.json()
    print json
    weather = json['results'][0]['now']['text']
    temperature = json['results'][0]['now']['temperature']
    
    tweatherstates = ',今天,' + weather + ',温度是,'  + temperature + ',摄氏度,'
    bt.tts(saytext, tok)
    speaker.speak()
Esempio n. 24
0
    def get_token(self):

        selfset = setting.setting()
        AK = selfset['main_setting']['BAIDU_TTS_SET']['AK']
        SK = selfset['main_setting']['BAIDU_TTS_SET']['SK']
        URL = 'http://openapi.baidu.com/oauth/2.0/token'

        params = urllib.urlencode({
            'grant_type': 'client_credentials',
            'client_id': AK,
            'client_secret': SK
        })
        r = requests.get(URL, params=params)
        try:
            r.raise_for_status()
            token = r.json()['access_token']
            return token
        except requests.exceptions.HTTPError:
            self._logger.critical('Token request failed with response: %r',
                                  r.text,
                                  exc_info=True)
Esempio n. 25
0
def main(tok):

    bt = baidu_tts()
    yt = youdao_tts()
    bs = baidu_stt(1, 2, 3, 4)
    r = recorder()

    selfset = setting.setting()
    hash = hashlib.md5()

    bt.tts('您好,请说出您要查询的快递单号', tok)
    speaker.speak()
    speaker.ding()
    r.exrecord()
    speaker.dong()

    requestData = {
        'OrderCode': '',
        'ShipperCode': 'YTO',
        'LogisticCode': number_choose(bs.stt('./voice.wav', tok), tok)
    }

    data = {
        'EBusinessID': selfset['express']['EBusinessID'],
        'RequestType': '1002',
        'RequestData': urllib.urlencode(str(requestData)),
        'DataType': '2',
    }
    hash.update(str(requestData) + selfset['express']['key'], encoding='utf-8')
    data['DataSign'] = urllib.urlencode(base64.b64encode(hash.hexdigest()))
    json = requests.post(
        'http://api.kdniao.cc/Ebusiness/EbusinessOrderHandle.aspx',
        data=data,
        headers='application/x-www-form-urlencoded;charset=utf-8')
    try:
        bt.tts(json['Traces'][-1]['AcceptStation'], tok)
        speaker.speak()
    except KeyError:
        bt.tts('对不起,包裹信息查询失败', tok)
        speaker.speak()
Esempio n. 26
0
    def sensor(self, getstatemode, getstatethings, tok):

        bt = baidu_tts()
        bs = baidu_stt(1, 2, 3, 4)
        r = recorder()
        h = hass()

        setting = setting.setting()
        url = setting['smarthome']['url']
        port = setting['smarthome']['port']
        passwd = setting['smarthome']['passwd']
        service = '/api/states'
        headers = {'x-ha-access': passwd, 'content-type': 'application/json'}

        if passwd != None or passwd != '':
            e_id = h.e_id(tok)
            service = '/api/states' + e_id[getstatethings]
            r = requests.get(url + ':' + port + service, headers=headers)
            if cortolback.status_code == 200 or cortolback.status_code == 201:
                json = r.json()
                if json['state'] == 'turn_on' and getstatemode == 'switch':
                    bt.tts(getstatethins + '为开启状态', tok)
                    speaker.speak()
                elif json['state'] == 'turn_on' and getstatemode == 'switch':
                    bt.tts(getstatethings + '为关闭状态', tok)
                    speaker.speak()
                elif json['state'] == 'turn_on' and getstatemode == 'sensor':
                    bt.tts(getstatethings + '为关闭状态', tok)
                    speaker.speak()
                elif json['state'].isdigit() == True:
                    bt.tts(getstatethings + '的数据是' + json['state'], tok)
                    speaker.speak()
                else:
                    bt.tts('对不起,暂时不支持读取改设备的状态', tok)
                    speaker.speak()
            else:
                bt.tts('执行错误', tok)
                speaker.speak()
        else:
            pass
Esempio n. 27
0
def main(tok):

    url = 'http://api.avatardata.cn/Joke/QueryJokeByTime?key='
    setting = setting.setting()
    key = setting['joke']['key']
    bt = baidu_tts()
    bs = baidu_stt(1, 'a', 2, '{')
    chose = random.randint(0, 9)

    r = requests.post(url + key + '&sort=asc&time=1418745237')

    json = r.json()

    if chose == 0:
        saytext = json['result'][0]['content']
    elif chose == 1:
        saytext = json['result'][1]['content']
    elif chose == 2:
        saytext = json['result'][2]['content']
    elif chose == 3:
        saytext = json['result'][3]['content']
    elif chose == 4:
        saytext = json['result'][4]['content']
    elif chose == 5:
        saytext = json['result'][5]['content']
    elif chose == 6:
        saytext = json['result'][6]['content']
    elif chose == 7:
        saytext = json['result'][7]['content']
    elif chose == 8:
        saytext = json['result'][8]['content']
    elif chose == 9:
        saytext = json['result'][9]['content']
    else:
        saytext = json['result'][0]['content']

    saytext = jokefj + '第二个笑话' + jokesj
    bt.tts(saytext, tok)
    speaker.speak()
Esempio n. 28
0
 def make_headers(self, goods_id):
     headers = {
         "Accept":
         "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
         "Accept-Encoding":
         "gzip, deflate",
         "Accept-Language":
         "zh-CN,zh;q=0.9",
         "Connection":
         "keep-alive",
         "Referer":
         'http://mobile.yangkeduo.com/goods.html?goods_id=' + str(goods_id),
         "Host":
         "mobile.yangkeduo.com",
         "Upgrade-Insecure-Requests":
         "1",
         "Cookie":
         '_nano_fp=XpdYX0gJlpgon0dxl9_Vfj_vkXR1TNT9PuWUpMqq; api_uid=' +
         str(self.ssdb.get('pdd_api_uid')),
         'User-Agent':
         setting.setting().get_web_user_agent(),
     }
     return headers
Esempio n. 29
0
'''
Created on 2019/11/17

@author: Takagi
'''

if __name__ == '__main__':
    print("start")
    import os
    from setting import setting
    set = setting()
    set.input_folder = os.path.join(os.path.dirname(__file__), "inputdata")
    set.output_folder = os.path.join(os.path.dirname(__file__), "outputdata")

    from networkmodel import networksimulation
    networksimulation(set)

    print("End all process")
Esempio n. 30
0
File: ui.py Progetto: p0poff/git2ftp
 def __init__(self):
     self.setting = setting.setting()
     self.curFiles = []
     self.curDir = ftp.curdir()