Skip to content

Instantly share code, notes, and snippets.

@RoyTakanen
Created May 7, 2021 20:27
Show Gist options
  • Save RoyTakanen/c1bb458f83fa319cdab8432ec99c521b to your computer and use it in GitHub Desktop.
Save RoyTakanen/c1bb458f83fa319cdab8432ec99c521b to your computer and use it in GitHub Desktop.
New wallpaper from apod (simple python script)
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