bcns-gameDistributionSystem/api/modules/gamelist.py
2022-10-26 09:17:21 +02:00

25 lines
699 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:
# f = open(nfo, encoding="UTF-8")
game = modules.game.game(nfo, True, True)
# game['game']['path'] = base64.b64encode(nfo.encode('utf-8')).decode()
gamelist.append(game)
return jsonify(gamelist)