Skip to content

Instantly share code, notes, and snippets.

@windyinsc
Forked from cmplant3210/bsitowu.py
Created March 24, 2018 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save windyinsc/a1a3606df84777bc0d79c0549b63210a to your computer and use it in GitHub Desktop.
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.
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