commit 0334a78ad50ede46277140139223b64bd15fc69c Author: Phyks (Lucas Verney) Date: Mon Nov 18 20:09:06 2024 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0beff40 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +cache.json +.venv diff --git a/README.md b/README.md new file mode 100644 index 0000000..6067c4f --- /dev/null +++ b/README.md @@ -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. diff --git a/notifier.py b/notifier.py new file mode 100755 index 0000000..b894264 --- /dev/null +++ b/notifier.py @@ -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) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..1b25361 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +feedparser diff --git a/urls.json b/urls.json new file mode 100644 index 0000000..c7ea853 --- /dev/null +++ b/urls.json @@ -0,0 +1,5 @@ +{ + "Gitea": "https://github.com/go-gitea/gitea/", + "Roundcube": "https://github.com/roundcube/roundcubemail/", + "Navidrome": "https://github.com/navidrome/navidrome/" +}