Created
May 7, 2021 20:27
-
-
Save RoyTakanen/c1bb458f83fa319cdab8432ec99c521b to your computer and use it in GitHub Desktop.
New wallpaper from apod (simple python script)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.request, json, os, ctypes | |
key = "<your_apod_api_key>" | |
bg_path = "<path_to_your_backgrounds_folder>" | |
with urllib.request.urlopen("https://api.nasa.gov/planetary/apod?api_key=" + key) as url: | |
data = json.loads(url.read().decode()) | |
file = os.path.basename(data["hdurl"]) | |
save_path = bg_path + file | |
urllib.request.urlretrieve(data["hdurl"], save_path) | |
ctypes.windll.user32.SystemParametersInfoW(20, 0, save_path , 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment