Last active
June 30, 2018 20:40
-
-
Save YtvwlD/4a12bb90cfaeea2195790d1a0a44f408 to your computer and use it in GitHub Desktop.
download NASA's Astronomy Picture of the Day
This file contains hidden or 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
#!/usr/bin/env python3 | |
from os import environ, rename | |
from os.path import expanduser | |
from urllib.request import urlretrieve | |
from bowshock.apod import apod | |
# you might want to change these values | |
DEST_FILE = expanduser("~/.cache/kscreenlocker_greet/plasma_engine_potd/apod") | |
NASA_API_KEY = "DEMO_KEY" | |
print("Moving old image...") | |
rename(DEST_FILE, DEST_FILE + ".bak") | |
environ["NASA_API_KEY"] = NASA_API_KEY | |
metadata = apod().json() | |
print("Downloading image...") | |
urlretrieve(metadata["url"], filename=DEST_FILE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment