Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webhost: add file downloads to the room api endpoint #2780

Merged
merged 5 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions WebHostLib/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
from typing import List, Tuple
from uuid import UUID

from flask import Blueprint, abort
from flask import Blueprint, abort, url_for

import worlds.Files
from .. import cache
from ..models import Room, Seed

Expand All @@ -21,12 +22,22 @@ def room_info(room: UUID):
room = Room.get(id=room)
if room is None:
return abort(404)

def supports_apdeltapatch(game: str):
return game in worlds.Files.AutoPatchRegister.patch_types
downloads = {}
for slot in sorted(room.seed.slots):
if slot.data and not supports_apdeltapatch(slot.game):
downloads[slot.player_id] = url_for("download_slot_file", room_id=room.id, player_id=slot.player_id)
alwaysintreble marked this conversation as resolved.
Show resolved Hide resolved
elif slot.data:
downloads[slot.player_id] = url_for("download_patch", patch_id=slot.id, room_id=room.id)
return {
"tracker": room.tracker,
"players": get_players(room.seed),
"last_port": room.last_port,
"last_activity": room.last_activity,
"timeout": room.timeout
"timeout": room.timeout,
"downloads": downloads,
}


Expand Down
3 changes: 0 additions & 3 deletions WebHostLib/templates/macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@
{% elif patch.game | supports_apdeltapatch %}
<a href="{{ url_for("download_patch", patch_id=patch.id, room_id=room.id) }}" download>
Download Patch File...</a>
{% elif patch.game == "Dark Souls III" %}
<a href="{{ url_for("download_slot_file", room_id=room.id, player_id=patch.player_id) }}" download>
Download JSON File...</a>
{% elif patch.game == "Final Fantasy Mystic Quest" %}
<a href="{{ url_for("download_slot_file", room_id=room.id, player_id=patch.player_id) }}" download>
Download APMQ File...</a>
Expand Down
Loading