bcns-gameDistributionSystem/api/modules/gamelist.py

26 lines
650 B
Python

from __main__ import app
from flask import jsonify, request
import modules.db_connect
import modules.game
import glob
import json
import base64
contentpath = modules.db_connect.contentpath()
# Fetch all _index.nfo-files present in given path and corresponding data
@app.route('/gamelist', methods=['GET'])
def gamelist():
nfolist = list(dict.fromkeys(glob.glob(str(contentpath)+'/**/**/*_index.nfo',recursive=True)))
gamelist = []
for nfo in nfolist:
try:
game = modules.game.game(nfo, True, True)
gamelist.append(game)
except Exception as e:
print(e)
return jsonify(gamelist)