diff --git a/app.py b/app.py index 1d2a14c..d2512f7 100644 --- a/app.py +++ b/app.py @@ -11,6 +11,7 @@ from ffmpy import FFmpeg app = Flask(__name__) DATABASE = 'taiko.db' +DEFAULT_URL = 'https://github.com/bui/taiko-web/' def get_db(): @@ -119,9 +120,17 @@ def get_tja_preview(tja): def get_version(): - version = None + version = {'commit': None, 'commit_short': '', 'version': None, 'url': DEFAULT_URL} if os.path.isfile('version.json'): - version = json.load(open('version.json', 'r')) + try: + ver = json.load(open('version.json', 'r')) + except ValueError: + print('Invalid version.json file') + return version + + for key in version.keys(): + if ver.get(key): + version[key] = ver.get(key) return version @@ -213,10 +222,10 @@ def make_preview(song_id, song_type): if os.path.isfile(song_path) and not os.path.isfile(prev_path): preview = get_preview(song_id, song_type) / 1000 if not preview or preview <= 0.1: - print 'Skipping #%s due to no preview' % song_id + print('Skipping #%s due to no preview' % song_id) return False - print 'Making preview.mp3 for song #%s' % song_id + print('Making preview.mp3 for song #%s' % song_id) ff = FFmpeg(inputs={song_path: '-ss %s' % preview}, outputs={prev_path: '-codec:a libmp3lame -ar 32000 -b:a 92k -y -loglevel panic'}) ff.run() diff --git a/public/src/js/about.js b/public/src/js/about.js index 8c9f2e2..235a8de 100644 --- a/public/src/js/about.js +++ b/public/src/js/about.js @@ -29,10 +29,7 @@ this.endButton.innerText = strings.tutorial.ok this.endButton.setAttribute("alt", strings.tutorial.ok) - var versionUrl = "https://github.com/bui/taiko-web/" - if(gameConfig._version){ - versionUrl = gameConfig._version.url - } + var versionUrl = gameConfig._version.url this.getLink(this.linkIssues).href = versionUrl + "issues" pageEvents.add(this.linkIssues, ["click", "touchend"], this.linkButton.bind(this)) diff --git a/public/src/js/loader.js b/public/src/js/loader.js index 6e7a81c..6149fdf 100644 --- a/public/src/js/loader.js +++ b/public/src/js/loader.js @@ -23,7 +23,7 @@ class Loader{ this.loaderPercentage = document.querySelector("#loader .percentage") this.loaderProgress = document.querySelector("#loader .progress") - var queryString = gameConfig._version ? "?" + gameConfig._version.commit_short : "" + var queryString = gameConfig._version.commit_short ? "?" + gameConfig._version.commit_short : "" assets.js.forEach(name => { var script = document.createElement("script") diff --git a/templates/index.html b/templates/index.html index d88252b..2f2a329 100644 --- a/templates/index.html +++ b/templates/index.html @@ -19,10 +19,10 @@