Compare commits

..

No commits in common. "3ee2fc0684ff53e3eaf5510d2b9579bc9866bf3e" and "4aac49f603589e3b94a9811aab5358dcdffe5c51" have entirely different histories.

3 changed files with 10 additions and 47 deletions

View File

@ -1,22 +1,6 @@
import cv2 import cv2
import base64 import base64
global gamelist
gamelist = []
# Set the gamelist
def set_gamelist(gamelist_dict):
global gamelist
gamelist = gamelist_dict
return True
# Get the gamelist
def get_gamelist():
global gamelist
return gamelist
# Reducing the size of an artwork/image (PNG to JPEG) and base64-encode it. # Reducing the size of an artwork/image (PNG to JPEG) and base64-encode it.
# imagepath = full file image path # imagepath = full file image path

View File

@ -1,36 +1,25 @@
from __main__ import app from __main__ import app
from flask import jsonify, make_response from flask import jsonify, request
import modules.db_connect import modules.db_connect
from modules.functions import get_gamelist, set_gamelist
import modules.game import modules.game
import glob import glob
import json
import base64
contentpath = modules.db_connect.contentpath() contentpath = modules.db_connect.contentpath()
# Fetch all _index.nfo-files present in given path and corresponding data
# Collects all _index.nfo-files present and crunches them into a list of
# games.
@app.route('/gamelist', methods=['GET']) @app.route('/gamelist', methods=['GET'])
def show_gamelist(): def gamelist():
if get_gamelist():
return jsonify(get_gamelist())
update_gamelist()
return jsonify(get_gamelist())
nfolist = list(dict.fromkeys(glob.glob(str(contentpath)+'/**/**/*_index.nfo',recursive=True)))
# Updates the gamelist by searching for new nfo's gamelist = []
@app.route('/gamelist/update', methods=['GET'])
def update_gamelist():
nfolist = list(dict.fromkeys(glob.glob(
str(contentpath)+'/**/**/*_index.nfo', recursive=True)))
glist = []
for nfo in nfolist: for nfo in nfolist:
try: try:
game = modules.game.game(nfo, True, True) game = modules.game.game(nfo, True, True)
glist.append(game) gamelist.append(game)
except Exception as e: except Exception as e:
print(e) print(e)
set_gamelist(glist) return jsonify(gamelist)
return make_response("<h1>Success</h1>", 200)

View File

@ -1,7 +1,7 @@
from __main__ import app from __main__ import app
import json import json
import requests import requests
from flask import render_template, redirect, url_for from flask import render_template
import modules.init import modules.init
host_endpoint = modules.init.host_endpoint() host_endpoint = modules.init.host_endpoint()
@ -26,13 +26,3 @@ def gamelist(lang_code):
return render_template('gamelist.html', gamelist=glist, return render_template('gamelist.html', gamelist=glist,
**languages[lang_code], lang_code=lang_code) **languages[lang_code], lang_code=lang_code)
# Update/Refresh the gamelist by re-scanning the game archive (slow)
@app.route("/<lang_code>/gamelist/update")
def gamelist_update(lang_code):
lang_code = lang(lang_code)
response = requests.get(
host_endpoint + '/gamelist/update')
if response.status_code == 200:
return redirect(url_for('gamelist', lang_code=lang_code))