Compare commits
No commits in common. "4e76be200aae9d468a21eab982cf45792f01301e" and "8cad5a53acfae45d9bc76ba3ccb7135f122398d6" have entirely different histories.
4e76be200a
...
8cad5a53ac
@ -1,8 +1,5 @@
|
|||||||
import cv2
|
import cv2
|
||||||
import base64
|
import base64
|
||||||
from io import BytesIO
|
|
||||||
import zipfile
|
|
||||||
import pathlib
|
|
||||||
|
|
||||||
global gamelist
|
global gamelist
|
||||||
gamelist = []
|
gamelist = []
|
||||||
@ -64,14 +61,3 @@ def image_resize(image, width=None, height=None, inter=cv2.INTER_AREA):
|
|||||||
|
|
||||||
# return the resized image
|
# return the resized image
|
||||||
return resized
|
return resized
|
||||||
|
|
||||||
|
|
||||||
# Create a ZIP-file on the fly for downloading games quicker
|
|
||||||
def make_archive(dirname, path):
|
|
||||||
base_path = pathlib.Path(path)
|
|
||||||
b = BytesIO()
|
|
||||||
with zipfile.ZipFile(b, mode="w", compression=zipfile.ZIP_DEFLATED) as z:
|
|
||||||
for f_name in base_path.iterdir():
|
|
||||||
z.write(f_name, arcname=f_name.name)
|
|
||||||
b.seek(0)
|
|
||||||
return b
|
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
from __main__ import app
|
from __main__ import app
|
||||||
from flask import jsonify, request, send_from_directory, send_file
|
from flask import jsonify, request, send_from_directory
|
||||||
import base64
|
import base64
|
||||||
import json
|
import json
|
||||||
import modules.db_connect
|
import modules.db_connect
|
||||||
from modules.functions import reduceartcv2, make_archive
|
from modules.functions import reduceartcv2
|
||||||
import os
|
import os
|
||||||
|
|
||||||
contentpath = modules.db_connect.contentpath()
|
contentpath = modules.db_connect.contentpath()
|
||||||
@ -86,18 +86,3 @@ def getmanual():
|
|||||||
manualname = nfo['game']['manual']
|
manualname = nfo['game']['manual']
|
||||||
manualpath = os.path.dirname(nfopath)+'/'
|
manualpath = os.path.dirname(nfopath)+'/'
|
||||||
return send_from_directory(manualpath, manualname, as_attachment=True)
|
return send_from_directory(manualpath, manualname, as_attachment=True)
|
||||||
|
|
||||||
|
|
||||||
# Game folder as ZIP-file (kinda slow)
|
|
||||||
@app.route('/getzipfile', methods=["GET"])
|
|
||||||
def getzipfile():
|
|
||||||
nfopath = base64.b64decode(request.json).decode()
|
|
||||||
nfo = json.load(open(nfopath, 'r'))
|
|
||||||
nfo['path'] = base64.b64encode(nfopath.encode('utf-8')).decode()
|
|
||||||
path = os.path.dirname(nfopath)
|
|
||||||
dirname = os.path.basename(nfopath)
|
|
||||||
return send_file(
|
|
||||||
make_archive(dirname, path),
|
|
||||||
mimetype='application/zip',
|
|
||||||
as_attachment=True,
|
|
||||||
download_name=str(dirname) + '.zip')
|
|
||||||
|
|||||||
@ -17,8 +17,7 @@
|
|||||||
"lang_game_manual_not_found": "Manual not available",
|
"lang_game_manual_not_found": "Manual not available",
|
||||||
"lang_game_download_header": "Download game",
|
"lang_game_download_header": "Download game",
|
||||||
"lang_game_download_ingress": "Here you can download the game using either torrent file or a magnet-link!",
|
"lang_game_download_ingress": "Here you can download the game using either torrent file or a magnet-link!",
|
||||||
"lang_game_download_zip_button": "Download Zip",
|
"lang_game_download_torrent_button": "Download",
|
||||||
"lang_game_download_torrent_button": "Download Torrent",
|
|
||||||
"lang_game_download_magnet_link": "Magnet link",
|
"lang_game_download_magnet_link": "Magnet link",
|
||||||
"lang_game_artwork": "Artwork",
|
"lang_game_artwork": "Artwork",
|
||||||
"lang_game_year": "Release date",
|
"lang_game_year": "Release date",
|
||||||
|
|||||||
@ -4,6 +4,5 @@
|
|||||||
"lang_home_change_language": "Byt språk",
|
"lang_home_change_language": "Byt språk",
|
||||||
"lang_home_change_language_button": "Byt",
|
"lang_home_change_language_button": "Byt",
|
||||||
"lang_navigation_home": "Hem",
|
"lang_navigation_home": "Hem",
|
||||||
"lang_navigation_gamelist": "Spellista",
|
"lang_navigation_gamelist": "Spellista"
|
||||||
"lang_game_download_zip_button": "Ladda ned Zip"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,19 +46,6 @@ def artwork(lang_code):
|
|||||||
# Download a game
|
# Download a game
|
||||||
@app.route("/<lang_code>/game/download")
|
@app.route("/<lang_code>/game/download")
|
||||||
def download(lang_code):
|
def download(lang_code):
|
||||||
gamepath = request.args.get("gamepath")
|
|
||||||
gametitle = request.args.get("gametitle")
|
|
||||||
targettype = request.args.get("targettype")
|
|
||||||
if "zip" in targettype:
|
|
||||||
gamezip = requests.get(host_endpoint + '/getzipfile', json=gamepath)
|
|
||||||
return Response(gamezip, mimetype="application/zip",
|
|
||||||
headers={
|
|
||||||
"Content-Disposition":
|
|
||||||
"attachment;filename=" + str(gametitle)})
|
|
||||||
elif "torrent" in targettype:
|
|
||||||
pass
|
|
||||||
|
|
||||||
else:
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -22,8 +22,7 @@
|
|||||||
{% endif%}
|
{% endif%}
|
||||||
<h3>{{lang_game_download_header}}</h3>
|
<h3>{{lang_game_download_header}}</h3>
|
||||||
<p>{{lang_game_download_ingress}}</p>
|
<p>{{lang_game_download_ingress}}</p>
|
||||||
<a href="{{ url_for('download', targettype="torrent", gametitle=game.game.title, gamepath=game.path, lang_code=lang_code)}}"><button type="button">{{lang_game_download_torrent_button}}</button></a>
|
<a href="{{ url_for('download', gamepath=game.path, lang_code=lang_code)}}"><button type="button">{{lang_game_download_torrent_button}}</button></a>
|
||||||
<a href="{{ url_for('download', targettype="zip", gamepath=game.path, gametitle=game.game.title, lang_code=lang_code)}}"><button type="button">{{lang_game_download_zip_button}}</button></a>
|
|
||||||
<p><a href="">{{lang_game_download_magnet_link}}</a></p>
|
<p><a href="">{{lang_game_download_magnet_link}}</a></p>
|
||||||
<table class="game">
|
<table class="game">
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user