-
-
Save windyinsc/a1a3606df84777bc0d79c0549b63210a to your computer and use it in GitHub Desktop.
BloomSky image uploader for Wunderground. Set cron job to upload as often as you'd like.
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
import urllib.request | |
import json | |
import ftplib | |
url = 'http://api.bloomsky.com/api/skydata/' | |
api = '<insert your api from dashboard.bloomsky.com>' | |
req = urllib.request.Request(url,headers={'Authorization':api}) | |
response = urllib.request.urlopen(req) | |
jsondata = json.loads(response.read().decode('utf-8')) | |
j = (jsondata[0]['Data']) | |
imageurl = j['ImageURL'] | |
urllib.request.urlretrieve(imageurl, '/home/pi/image.jpg') | |
server = 'webcam.wunderground.com' | |
username = '<your cam ID from Wunderground>' | |
password = '<your wunderground password>' | |
ftp_connection = ftplib.FTP(server,username,password) | |
remote_path = '/' | |
ftp_connection.cwd(remote_path) | |
fh = open("/home/pi/image.jpg",'rb') | |
ftp_connection.storbinary('STOR image.jpg', fh) | |
fh.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment