summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2021-09-08 22:51:23 +0300
committerEvgeny Zinoviev <me@ch1p.io>2021-09-08 22:51:23 +0300
commit651b4c0ccb17dee1fbee44e891d9afa63132147c (patch)
tree02e05a1b0e6373f79c1feb2aadb31fd72b7b6685
parent411a2cfeed588bd98b7e4efde442b1ca3ca5d162 (diff)
use archlinux website to get vivaldi version because vivaldi website's cursed by cloudflare
-rw-r--r--vivaldi-update-checker.py26
1 files changed, 17 insertions, 9 deletions
diff --git a/vivaldi-update-checker.py b/vivaldi-update-checker.py
index 7568bc9..f85a391 100644
--- a/vivaldi-update-checker.py
+++ b/vivaldi-update-checker.py
@@ -1,5 +1,6 @@
import requests, re
+from argparse import ArgumentParser
from packaging import version
from ch1p import State, telegram_notify
from bs4 import BeautifulSoup
@@ -13,26 +14,33 @@ class VivaldiUpdateChecker:
pass
def get(self):
- r = requests.get('https://vivaldi.com/blog/')
+ r = requests.get('https://archlinux.org/packages/community/x86_64/vivaldi/')
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)
+ meta = soup.select('meta[itemprop=version]')
+ if meta:
+ return meta[0]['content']
raise VersionNotFoundError("version not found")
if __name__ == '__main__':
+ parser = ArgumentParser()
+ parser.add_argument('--print', action='store_true',
+ help='Print version and exit')
+ args = parser.parse_args()
+
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')
+ if args.print:
+ print(cur_version)
+ else:
+ 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')