diff --git a/bazarr/api.py b/bazarr/api.py index 30d7ceee2..bde16e1f0 100644 --- a/bazarr/api.py +++ b/bazarr/api.py @@ -295,12 +295,15 @@ class SystemReleases(Resource): releases = [] try: with io.open(os.path.join(args.config_dir, 'config', 'releases.txt'), 'r', encoding='UTF-8') as f: - releases = ast.literal_eval(f.read()) - for release in releases: - release[1] = release[1].replace('- ', '') - release[1] = release[1].split('\r\n') - release[1].pop(0) - release.append(True if release[0].lstrip('v') == os.environ["BAZARR_VERSION"] else False) + releases = json.loads(f.read()) + releases = releases[:5] + for i, release in enumerate(releases): + body = release['body'].replace('- ', '').split('\r\n')[1:] + releases[i] = {"body": body, + "name": release['name'], + "date": release['date'][:10], + "prerelease": release['prerelease'], + "current": True if release['name'].lstrip('v') == os.environ["BAZARR_VERSION"] else False} except Exception as e: logging.exception( diff --git a/bazarr/check_update.py b/bazarr/check_update.py index 5cc39b765..06c454d22 100644 --- a/bazarr/check_update.py +++ b/bazarr/check_update.py @@ -54,24 +54,22 @@ def check_and_apply_update(): logging.info('BAZARR Updated to latest version. Restart required. ' + result) updated() else: - url = 'https://api.github.com/repos/morpheus65535/bazarr/releases' - releases = request_json(url, timeout=20, whitelist_status_code=404, validator=lambda x: type(x) == list) + url = 'https://api.github.com/repos/morpheus65535/bazarr/releases/latest' + release = request_json(url, timeout=20, whitelist_status_code=404, validator=lambda x: type(x) == list) - if releases is None: + if release is None: logging.warning('BAZARR Could not get releases from GitHub.') return else: - release = releases[0] - latest_release = release['tag_name'] + latest_release = release['tag_name'] if ('v' + os.environ["BAZARR_VERSION"]) != latest_release: - update_from_source() + update_from_source(tar_download_url=release['tarball_url']) else: logging.info('BAZARR is up to date') -def update_from_source(): - tar_download_url = 'https://github.com/morpheus65535/bazarr/tarball/{}'.format(settings.general.branch) +def update_from_source(tar_download_url): update_dir = os.path.join(os.path.dirname(__file__), '..', 'update') logging.info('BAZARR Downloading update from: ' + tar_download_url) @@ -135,7 +133,10 @@ def check_releases(): logging.exception("Error trying to get releases from Github.") else: for release in r.json(): - releases.append([release['name'], release['body']]) + releases.append({'name': release['name'], + 'body': release['body'], + 'date': release['published_at'], + 'prerelease': release['prerelease']}) with open(os.path.join(args.config_dir, 'config', 'releases.txt'), 'w') as f: json.dump(releases, f) diff --git a/bazarr/scheduler.py b/bazarr/scheduler.py index 2bac3f1c6..acbd4dba7 100644 --- a/bazarr/scheduler.py +++ b/bazarr/scheduler.py @@ -215,12 +215,12 @@ class Scheduler: check_and_apply_update, CronTrigger(year='2100'), hour=4, id='update_bazarr', name=task_name, replace_existing=True) self.aps_scheduler.add_job( - check_releases, IntervalTrigger(hours=6), max_instances=1, coalesce=True, misfire_grace_time=15, + check_releases, IntervalTrigger(hours=3), max_instances=1, coalesce=True, misfire_grace_time=15, id='update_release', name='Update Release Info', replace_existing=True) else: self.aps_scheduler.add_job( - check_releases, IntervalTrigger(hours=6), max_instances=1, coalesce=True, misfire_grace_time=15, + check_releases, IntervalTrigger(hours=3), max_instances=1, coalesce=True, misfire_grace_time=15, id='update_release', name='Update Release Info', replace_existing=True) def __search_wanted_subtitles_task(self): diff --git a/views/systemreleases.html b/views/systemreleases.html index 9f2c0c3b7..f7708e010 100644 --- a/views/systemreleases.html +++ b/views/systemreleases.html @@ -2,6 +2,15 @@ {% block title %}Releases - Bazarr{% endblock %} +{% block head %} + +{% endblock head %} + {% block bcleft %} {% endblock bcleft %} @@ -27,8 +36,12 @@ function appendFunc(value) { entries = ''; - value[1].forEach(appendEntry); - releases = releases + '
From newest to oldest:
From newest to oldest: