diff --git a/Jarvis.py b/Jarvis.py index 926c273f4e510dc266d086416f891b2a9e015863..79cdc7f5c2c1b27177057645ba7e6029f956105b 100755 --- a/Jarvis.py +++ b/Jarvis.py @@ -409,12 +409,10 @@ def tests(entre): parle(useless.chuck(), False) if "donne une info" in entre: - parle(usefull.sudpresse(), False) + parle(usefull.francetv().replace("\n", ". "), False) if "donne les info" in entre: - res = "" - for i in range(5): - res += usefull.sudpresse() + "\n" + res = usefull.francetv(False).replace("\n", ". ") parle(res, False) if "horoscope" in entre: diff --git a/__pycache__/myimports.cpython-37.pyc b/__pycache__/myimports.cpython-37.pyc index d7c1cf0f35ff62f0c1d788a9066218a22f1b0702..831983528055afa657233070dac9282fd30012c9 100644 Binary files a/__pycache__/myimports.cpython-37.pyc and b/__pycache__/myimports.cpython-37.pyc differ diff --git a/saved_voice/58.mp3 b/saved_voice/58.mp3 index fb0b1f2a2f39c90d018c3f4aada9c73b6e949d2e..44ab23a193a03ca104c10b22f17979db3914ee05 100644 Binary files a/saved_voice/58.mp3 and b/saved_voice/58.mp3 differ diff --git a/usefull/__pycache__/sudinfo.cpython-37.pyc b/usefull/__pycache__/sudinfo.cpython-37.pyc index 06d74c3f2023be7eef70c36e4fd19c116137a3f3..af5a8781de2ec237c2bef490a7761c832f40be31 100644 Binary files a/usefull/__pycache__/sudinfo.cpython-37.pyc and b/usefull/__pycache__/sudinfo.cpython-37.pyc differ diff --git a/usefull/sudinfo.py b/usefull/sudinfo.py index dad44db26a85b3f8b34cb5a3a70423c6479c57f9..6209ba3861fe6e1be3989e5247955bc08f4ce204 100644 --- a/usefull/sudinfo.py +++ b/usefull/sudinfo.py @@ -19,15 +19,26 @@ def sudpresse(): except: return 'Houston on a un problème' -def francetv(): + +def francetv(one=True): try: - req = requests.get("https://www.francetvinfo.fr/titres/") + req = requests.get("https://www.francetvinfo.fr/titres.atom") html = req.content bs = BeautifulSoup(html, "html.parser") - res = bs.find_all('aside') - print(res[0].find_all("a")) + res = [e.text.replace(" ", " ") for e in bs.find_all(['title', 'summary'])] + res_dict_list = [] + for i in range(1, len(res)): + if i % 2 == 1: + res_dict_list.append({}) + res_dict_list[-1]["title"] = res[i] + res_dict_list[-1]["summary"] = res[i + 1] + if one: + result = random.choice(res_dict_list) + return "\n".join(result.values()) + return "\n".join(res[:21]) except: return 'Houston on a un problème' + if __name__ == '__main__': print(francetv())