1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-30 19:46:25 +00:00
bazarr/libs/ffsubsync/version.py
2020-06-12 15:08:44 -04:00

34 lines
899 B
Python

# -*- coding: utf-8 -*-
from ._version import get_versions
__version__ = get_versions()['version']
del get_versions
def make_version_tuple(vstr=None):
if vstr is None:
vstr = __version__
if vstr[0] == 'v':
vstr = vstr[1:]
components = []
for component in vstr.split('+')[0].split('.'):
try:
components.append(int(component))
except ValueError:
break
return tuple(components)
def update_available():
import requests
from requests.exceptions import Timeout
from .constants import API_RELEASE_URL
try:
resp = requests.get(API_RELEASE_URL, timeout=1)
latest_vstr = resp.json()['tag_name']
except Timeout:
return False
except KeyError:
return False
if not resp.ok:
return False
return make_version_tuple(__version__) < make_version_tuple(latest_vstr)