1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-22 15:54:26 +00:00

Improved releases view to show only relevant releases in relation to chosen branch.

This commit is contained in:
morpheus65535 2021-03-24 13:43:47 -04:00
parent f2ee0546fb
commit e70461a204
2 changed files with 21 additions and 9 deletions

View file

@ -297,19 +297,31 @@ class SystemReleases(Resource):
try:
with io.open(os.path.join(args.config_dir, 'config', 'releases.txt'), 'r', encoding='UTF-8') as f:
releases = json.loads(f.read())
releases = releases[:25]
for i, release in enumerate(releases):
filtered_releases = []
for release in releases:
if settings.general.branch == 'master' and not release['prerelease']:
filtered_releases.append(release)
elif settings.general.branch != 'master' and any(not x['prerelease'] for x in filtered_releases):
continue
elif settings.general.branch != 'master':
filtered_releases.append(release)
if settings.general.branch == 'master':
filtered_releases = filtered_releases[:5]
for i, release in enumerate(filtered_releases):
body = release['body'].replace('- ', '').split('\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}
filtered_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(
'BAZARR cannot parse releases caching file: ' + os.path.join(args.config_dir, 'config', 'releases.txt'))
return jsonify(data=releases)
return jsonify(data=filtered_releases)
class Series(Resource):

View file

@ -13,7 +13,7 @@ from config import settings
def check_releases():
releases = []
url_releases = 'https://api.github.com/repos/morpheus65535/Bazarr/releases'
url_releases = 'https://api.github.com/repos/morpheus65535/Bazarr/releases?per_page=100'
try:
logging.debug('BAZARR getting releases from Github: {}'.format(url_releases))
r = requests.get(url_releases, allow_redirects=True)