mirror of https://github.com/morpheus65535/bazarr
Improving releases and update process.
This commit is contained in:
parent
94825422d5
commit
5aea4e0483
|
@ -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(
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -2,6 +2,15 @@
|
|||
|
||||
{% block title %}Releases - Bazarr{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
<style>
|
||||
.badge {
|
||||
vertical-align: text-bottom;
|
||||
margin-left: 10px;
|
||||
}
|
||||
</style>
|
||||
{% endblock head %}
|
||||
|
||||
{% block bcleft %}
|
||||
|
||||
{% endblock bcleft %}
|
||||
|
@ -27,8 +36,12 @@
|
|||
|
||||
function appendFunc(value) {
|
||||
entries = '';
|
||||
value[1].forEach(appendEntry);
|
||||
releases = releases + '<h4>'+value[0]+((value[2]) ? ' <span class="badge badge-success">Current Version</span>' : '')+'</h4><hr/><p><b>From newest to oldest:</b></p><ul>'+entries+'</ul>';
|
||||
value['body'].forEach(appendEntry);
|
||||
releases = releases + '<h3 style="display:inline;">'+value['name']+'</h3>'
|
||||
releases += ' — '+value['date']
|
||||
releases += ((value['prerelease']) ? '<span class="badge badge-danger">Development</span>' : '<span class="badge badge-info">Master</span>')
|
||||
releases += ((value['current']) ? '<span class="badge badge-secondary">Currently Installed</span>' : '')
|
||||
releases += '</h4><hr/><p><b>From newest to oldest:</b></p><ul>'+entries+'</ul>';
|
||||
|
||||
function appendEntry(entry) {
|
||||
entries = entries + '<li>'+entry+'</li>';
|
||||
|
|
Loading…
Reference in New Issue