Skip to content

Commit

Permalink
Merge pull request #709 from anime-dl/version-checker
Browse files Browse the repository at this point in the history
Checks for new versions
  • Loading branch information
ArjixWasTaken committed Aug 18, 2021
2 parents be769cf + fd683a4 commit cced96f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion anime_downloader/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '5.0.12'
__version__ = '5.0.13'
28 changes: 28 additions & 0 deletions anime_downloader/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,29 @@
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):
Expand Down Expand Up @@ -49,6 +72,11 @@ def cli(log_level):


def main():
try:
check_for_update()
except Exception:
pass

try:
cli()
except Exception as e:
Expand Down

0 comments on commit cced96f

Please sign in to comment.