Last active
July 21, 2021 01:53
-
-
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.
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() | |
exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment