-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnasa.py
118 lines (98 loc) · 3.74 KB
/
nasa.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import requests
import os
from PIL import Image
import pyttsx3
from TeronUi import takecommand
# from jarvis import takecommand
Api_Key = "v7wIjE8msJog8Hgw99aoEoDNVSzUc0ZSFcPinl0j"
Assistant = pyttsx3.init('sapi5')
voices = Assistant.getProperty('voices')
# print(voices)
Assistant.setProperty('voices', voices[0].id)
Assistant.setProperty('rate', 170)
def speak(audio):
print(" ")
Assistant.say(audio)
print(f": {audio}")
print(" ")
Assistant.runAndWait()
def NasaNews(Date):
speak("Extracting Data From Nasa For Your Search...")
Url = "https://api.nasa.gov/planetary/apod?api_key="+str(Api_Key)
Params = {'date':str(Date)}
r = requests.get(Url,params = Params)
Data = r.json()
print(Data)
Info = Data['explanation']
title = Data['title']
Image_Url = Data['url']
Image_r = requests.get(Image_Url)
print(Info)
print(title)
FileName = str(Date) + '.jpg'
print(FileName)
with open(FileName, 'wb') as f:
f.write(Image_r.content)
Path_1 = "C:\\Users\\zeyan\\OneDrive\\Desktop\\Teron 2.0\\" + str(FileName)
Path_2 = "C:\\Users\\zeyan\\OneDrive\\Desktop\\Teron 2.0\\Nasa Images\\" + str(FileName)
os.rename(Path_1, Path_2)
img = Image.open(Path_2)
img.show()
speak(f"Title: {title}")
speak(f"According To Nasa: {Info}")
def Mars():
name = 'curiosity'
date = '2020-12-3'
Api = str(Api_Key)
url = f"https://api.nasa.gov/mars-photos/api/v1/rovers/{name}/photos?earth_date={date}&api_key={Api_Key}"
r = requests.get(url)
Data = r.json()
Photos = Data['photos'][:10]
try:
for index , photo in enumerate(Photos):
camera = photo['camera']
rover = photo['rover']
rover_name = rover['name']
camera_name = camera['name']
full_camera_name = camera['full_name']
data_of_photo = photo['earth_date']
img_url = photo['img_src']
p = requests.get(img_url)
img = f'{index} .jpg'
with open(img, 'wb') as file:
file.write(p.content)
Path_1 = "C:\\Users\\zeyan\\OneDrive\\Desktop\\Jarvis\\" +str(img)
# Path_2 = "C:\\Users\\zeyan\\OneDrive\\Desktop\\Jarvis\\Mars Images\\"+ str(img)
# os.rename(Path_1, Path_2)
os.startfile(Path_1)
speak(f"This Image Was Captured With : {full_camera_name}")
speak(f"This Image Was Captured On {data_of_photo}")
except:
speak("There Was An Error!")
def DateConverter(Query):
Date = takecommand()
Date = Date.replace(" and ", "-")
Date = Date.replace(" and ", "-")
Date = Date.replace(" and ", "-")
Date = Date.replace(" ", "")
return str(Date)
def SolarBodies(Body):
url = "https://api.le-systeme-solaire.net/rest/bodies/"
r = requests.get(url)
Data = r.json()
bodies = Data['bodies']
Number = len(bodies)
url2 = f"https://api.le-systeme-solaire.net/rest/bodies/ {Body}"
rrr = requests.get(url2)
data2 = rrr.json()
print(data2)
mass = data2['mass']['massValue']
volume = data2['vol']['volValue']
density = data2['density']
gravity = data2['gravity']
escape = data2['escape']
speak(f"Number Of Bodies In Solar System: {Number}")
speak(f"Volume Of {Body} Is {volume} cubic meter ")
speak(f"Density Of {Body} Is {density} kilogram per cubic meter")
speak(f"Gravity Of {Body} Is {gravity} metres per second")
speak(f"Escape Velocity Of {Body} Is {escape} km/s")