Like to help out with hosting costs for WXForum.net? Use the donate page. Thanks!
0 Members and 1 Guest are viewing this topic.
#!/usr/bin/python'''Python script to save a static image from a Nest Cam video stream.Useful because Weather Underground requires a static image.To use, figure out your Nest Cam's uuid. See here for details:https://ithoughthecamewithyou.com/post/capture-dropcam-frames-to-google-driveThen set it to run in crontab every minute. Each time the script is run it saves the images once a second for a minute.'''import os, urllib, time, shutil# uuid of your camerauuid = "d62aa97fdae445af8ebea9328d5fcb06"# width of the imageimage_width = 1000# filename (path) to save the imagesaved_image_path = os.path.expanduser("~") + "/sinkingsensation.com/cam/saved.jpg"# create the target directory if it doesn't existtry: os.makedirs( os.path.dirname(saved_image_path) )except: passurl = "https://nexusapi.dropcam.com/get_image?uuid=%s&width=%s" % (uuid, image_width)# since the max frequency for crontab is to run a job once a minute,# download the image once a second for a minute.for i in range(60): # download the image to a temp file so people aren't trying to load an incomplete image urllib.urlretrieve(url, "temp.jpg") # copy it to our final path after downloaded shutil.copyfile("temp.jpg", saved_image_path) time.sleep(1)