| 12345678910111213141516171819202122232425 | #!/usr/bin/env python3import osimport subprocessfrom datetime import datetimeimport requeststoday = datetime.today().strftime("%Y-%m-%d")home = os.path.expanduser("~")target_path = f"{home}/var/media/backgrounds/bing/{today}.jpg"# If the file for today already exists, just exitif os.path.isfile(target_path):    print(f"Bing image for {today} already exists, skipping download")    exit()iotd_uri = "https://www.bing.com/HPImageArchive.aspx?format=js&idx=1&n=1"r = requests.get(iotd_uri)image_info_uri = r.json()["images"][0]["url"]img = requests.get(f"https://www.bing.com{image_info_uri}", stream=True)handle = open(target_path, "wb")for chunk in img.iter_content(chunk_size=512):    if chunk:  # filter out keep-alive new chunks        handle.write(chunk)
 |