Last active
March 22, 2019 19:40
-
-
Save mtellin/75cf794c9d40648063ef3d3554e1a0f1 to your computer and use it in GitHub Desktop.
Post to my home Slack channel when a new version of rclone is released. Uses kvdb.io as the key/value store for current version.
This file contains 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 requests | |
import os | |
from bs4 import BeautifulSoup | |
# Set environment variables for the following items | |
slackToken = os.environ['SLACK_TOKEN'] | |
kvdbId = os.environ['KVDB_ID'] | |
rcloneLogo = os.environ['RCLONE_LOGO'] | |
# Pull the rClone page and use BeautifulSoup to parse | |
page = requests.get('http://rclone.org/downloads') | |
soup = BeautifulSoup(page.text, 'html.parser') | |
version_tag = soup.find(id='rclone-download-hahahugoshortcode-0xc4203b8f00-1-hbhb') | |
versionString = version_tag.text | |
webVersion = float(versionString.split('v')[1]) | |
session = requests.get('https://kvdb.io/{}/version'.format(kvdbId)) | |
currentVersion = session.json() | |
if webVersion > currentVersion: | |
slackData = { | |
'channel': '#backups', | |
'text': 'Woohoo, there is a new rclone version: ' + str(webVersion), | |
'username': 'rclone', | |
'icon_url': rcloneLogo, | |
'token': slackToken | |
} | |
response = requests.post('https://slack.com/api/chat.postMessage', slackData) | |
# Update KVDB with the new rclone version | |
kvdbData = str(webVersion) | |
response = requests.post('https://kvdb.io/{}/version'.format(kvdbId), kvdbData) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment