/vemenidubi
Created 2 years, 10 months ago...
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 |
import requests
import ctypes
import datetime
import time
from datetime import date
SPI_SETDESKWALLPAPER = 20
path_to_folder = r"C:\Users\Simon\Documents\Folders\Photos\Backgrounds\Python"
api_address='http://api.openweathermap.org/data/2.5/weather?appid=0c42f7f6b53b244c78a418f4f181282a&q='
city = "WHERE YOU LIVE"
url = api_address + city
def main():
timestamp = datetime.datetime.now().time()
start_night = datetime.time(18, 1)
end_night = datetime.time(6, 0)
start_day = datetime.time(6, 1)
end_day = datetime.time(18, 0)
json_data = requests.get(url).json()
format_data = json_data["weather"][0]["main"]
print("Looped")
if date.today().weekday() == 6:
ctypes.windll.user32.SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, path_to_folder + "\Tokyo.jpg", 3)
time.sleep(120)
print("Sunday")
main()
if format_data == "Rain":
ctypes.windll.user32.SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, path_to_folder + "\Waterfall.jpg", 3)
time.sleep(120)
print("Rain")
main()
elif format_data == "Thunderstorm":
ctypes.windll.user32.SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, path_to_folder + "\Cloud.jpg", 3)
time.sleep(120)
print("Storm")
main()
elif format_data == "Drizzle":
ctypes.windll.user32.SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, path_to_folder + "\Rooftop1.png", 3)
time.sleep(120)
print("Drizzle")
main()
# Night & Day
elif format_data == "Clear" and start_night <= timestamp or timestamp <= end_night:
ctypes.windll.user32.SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, path_to_folder + "\Moon.png", 3)
time.sleep(120)
print("Night")
main()
elif format_data == "Clear" and start_day <= timestamp <= end_day:
ctypes.windll.user32.SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, path_to_folder + "\KatanaMorning.png", 3)
time.sleep(120)
print("Day")
main()
elif format_data == "Clouds":
ctypes.windll.user32.SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, path_to_folder + "\Shibuya.png", 3)
time.sleep(120)
print("Clouds")
main()
else:
ctypes.windll.user32.SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, path_to_folder + "\Firewatch.jpg", 3)
time.sleep(120)
print("Other")
main()
main()