summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--LICENSE25
-rw-r--r--requirements.txt5
-rw-r--r--vivaldi-update-checker.py41
4 files changed, 73 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..9af7a0d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+venv/
+.idea \ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..3d4446b
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,25 @@
+BSD 2-Clause License
+
+Copyright (c) 2021, Evgeny Zinoviev
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..8b5c400
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,5 @@
+requests~=2.25.1
+packaging~=20.9
+ch1p~=0.0.5
+bs4
+beautifulsoup4~=4.9.3 \ No newline at end of file
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
+