feat: by default check for updates when any command is ran

This commit is contained in:
benex
2024-11-16 22:47:04 +03:00
parent 0b3615c9f5
commit c65a1a2815
3 changed files with 20 additions and 1 deletions

View File

@@ -226,6 +226,17 @@ def run_cli(
from .config import Config
ctx.obj = Config()
if ctx.obj.check_for_updates:
from .app_updater import check_for_updates
import time
is_latest = check_for_updates()
if not is_latest:
print(
"You are running an older version of fastanime please update to get the latest features"
)
time.sleep(10)
ctx.obj.manga = manga
if log:
import logging

View File

@@ -45,8 +45,9 @@ def check_for_updates():
return (is_latest, release_json)
else:
print("Failed to check for updates")
print(request.text)
return (False, {})
return (True, {})
def is_git_repo(author, repository):

View File

@@ -33,6 +33,7 @@ class Config(object):
"auto_next": "False",
"auto_select": "True",
"cache_requests": "true",
"check_for_updates": "True",
"continue_from_history": "True",
"default_media_list_tracking": "None",
"downloads_dir": USER_VIDEOS_DIR,
@@ -88,6 +89,7 @@ class Config(object):
self.auto_next = self.get_auto_next()
self.auto_select = self.get_auto_select()
self.cache_requests = self.get_cache_requests()
self.check_for_updates = self.configparser.get("general", "check_for_updates")
self.continue_from_history = self.get_continue_from_history()
self.default_media_list_tracking = self.get_default_media_list_tracking()
self.disable_mpv_popen = self.configparser.getboolean(
@@ -346,6 +348,11 @@ icons = {self.icons}
# this also applies to episode titles
normalize_titles = {self.normalize_titles}
# whether to check for updates every time you run the script [True/False]
# this is useful for keeping your script up to date
# cause there are always new features being added 😄
check_for_updates = {self.check_for_updates}
# can be [allanime, animepahe, hianime]
# allanime is the most realible
# animepahe provides different links to streams of different quality so a quality can be selected reliably with --quality option