Initial commit
This commit is contained in:
commit
0334a78ad5
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
cache.json
|
||||
.venv
|
4
README.md
Normal file
4
README.md
Normal file
@ -0,0 +1,4 @@
|
||||
Github notifier
|
||||
===============
|
||||
|
||||
Quick and dirty script to be run in crontask with chronic and send email notifications about new Github releases for tracked software.
|
32
notifier.py
Executable file
32
notifier.py
Executable file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python
|
||||
import json
|
||||
import sys
|
||||
|
||||
import feedparser
|
||||
|
||||
URLs_FILE = './urls.json'
|
||||
CACHE_FILE = './cache.json'
|
||||
exit_code = 0
|
||||
|
||||
with open(URLs_FILE, 'r') as fh:
|
||||
URLs = json.load(fh)
|
||||
|
||||
try:
|
||||
with open(CACHE_FILE, 'r') as fh:
|
||||
releases = json.load(fh)
|
||||
except:
|
||||
releases = {}
|
||||
|
||||
for name, url in URLs.items():
|
||||
url = '/'.join([url, 'releases.atom'])
|
||||
d = feedparser.parse(url)
|
||||
latest_version = d.entries[0].title
|
||||
if latest_version != releases.get(name):
|
||||
print(f'New version for {name} ({url}): {latest_version}')
|
||||
exit_code = 1
|
||||
releases[name] = latest_version
|
||||
|
||||
with open(CACHE_FILE, 'w') as fh:
|
||||
json.dump(releases, fh)
|
||||
|
||||
sys.exit(exit_code)
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
feedparser
|
Loading…
Reference in New Issue
Block a user