Skip to content

Commit

Permalink
Webhost: add file downloads to the room api endpoint (ArchipelagoMW#2780
Browse files Browse the repository at this point in the history
)
  • Loading branch information
alwaysintreble authored and qwint committed Jun 24, 2024
1 parent 0c8cb55 commit 1574a42
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
23 changes: 21 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,30 @@ 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):
slot_download = {
"slot": slot.player_id,
"download": url_for("download_slot_file", room_id=room.id, player_id=slot.player_id)
}
downloads.append(slot_download)
elif slot.data:
slot_download = {
"slot": slot.player_id,
"download": url_for("download_patch", patch_id=slot.id, room_id=room.id)
}
downloads.append(slot_download)
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

0 comments on commit 1574a42

Please sign in to comment.