Skip to content

Instantly share code, notes, and snippets.

@cmplant3210
Last active July 21, 2021 01:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cmplant3210/cee94c6ecc9a3b28a82a29164cf1f3fd to your computer and use it in GitHub Desktop.
Save cmplant3210/cee94c6ecc9a3b28a82a29164cf1f3fd to your computer and use it in GitHub Desktop.
BloomSky image uploader for Wunderground using Raspberry Pi. 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()
exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment