Merge pull request #709 from anime-dl/version-checker

Checks for new versions
master
Arjix 2021-08-18 21:10:47 +03:00 committed by GitHub
commit cced96f3ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 1 deletions

View File

@ -1 +1 @@
__version__ = '5.0.12'
__version__ = '5.0.13'

View File

@ -11,6 +11,29 @@ from anime_downloader import util
echo = click.echo
def check_for_update():
from pkg_resources import parse_version
import requests
import re
version_file = "https://raw.githubusercontent.com/anime-dl/anime-downloader/master/anime_downloader/__version__.py"
regex = r"__version__\s*=\s*[\"'](\d+\.\d+\.\d+)[\"']"
r = requests.get(version_file)
if not r.ok:
return
current_ver = parse_version(__version__)
remote_ver = parse_version(re.match(regex, r.text).group(1))
if remote_ver > current_ver:
print(
"New version (on GitHub) is available: {} -> {}\n".format(
current_ver, remote_ver
)
)
class CLIClass(click.MultiCommand):
def list_commands(self, ctx):
@ -49,6 +72,11 @@ def cli(log_level):
def main():
try:
check_for_update()
except Exception:
pass
try:
cli()
except Exception as e: