summaryrefslogtreecommitdiff
path: root/vivaldi-update-checker.py
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2021-04-25 23:59:51 +0300
committerEvgeny Zinoviev <me@ch1p.io>2021-04-25 23:59:51 +0300
commit1d003cf394231918cdd165cc256da17b1d1dcef0 (patch)
treeed52996fa639669bdd5e67036bd725b2df31ff5e /vivaldi-update-checker.py
initial
Diffstat (limited to 'vivaldi-update-checker.py')
-rw-r--r--vivaldi-update-checker.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/vivaldi-update-checker.py b/vivaldi-update-checker.py
new file mode 100644
index 0000000..b0053ee
--- /dev/null
+++ b/vivaldi-update-checker.py
@@ -0,0 +1,41 @@
+import requests, re
+
+from packaging import version
+from ch1p import State, telegram_notify
+from bs4 import BeautifulSoup
+from html import escape
+
+
+class VersionNotFoundError(RuntimeError): pass
+
+
+class VivaldiUpdateChecker:
+ def __init__(self):
+ pass
+
+ def get(self):
+ r = requests.get('https://vivaldi.com/blog/')
+ soup = BeautifulSoup(r.text, 'html.parser')
+ links = soup.select('.download-vivaldi-sidebar a')
+ for link in links:
+ if link['href'] == 'https://vivaldi.com/download/':
+ return re.search(r'\((.*?)\)', link.get_text().strip()).group(1)
+ raise VersionNotFoundError("version not found")
+
+
+if __name__ == '__main__':
+ state = State(default={'prev_version': '0.0'})
+
+ try:
+ checker = VivaldiUpdateChecker()
+ cur_version = checker.get()
+
+ if version.parse(state['prev_version']) < version.parse(cur_version):
+ message = 'New Vivaldi version: <b>%s</b>. Download here: https://vivaldi.com/download/' % (cur_version)
+ state['prev_version'] = cur_version
+ telegram_notify(text=message, parse_mode='HTML')
+
+ except VersionNotFoundError:
+ print('version not found')
+ pass
+