Skip to content

Commit

Permalink
feat(render): Update requirements and add target player ID support
Browse files Browse the repository at this point in the history
- Updated the `requirements.txt` file to use an in-house repository for the minimap renderer.
- Added support for specifying a target player ID in the `render_replay` function.
  • Loading branch information
SakuraIsayeki committed Jul 20, 2023
1 parent 170c135 commit fb5e850
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion wowskarma_api_minimap/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ passlib[bcrypt]
python-multipart
psycopg2-binary

git+https://github.com/WoWs-Builder-Team/minimap_renderer.git
git+https://github.com/SakuraIsayeki/wowskarma_minimap_renderer.git
16 changes: 13 additions & 3 deletions wowskarma_api_minimap/src/routes/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@


@router.post("/render", dependencies=[AuthenticatedUser])
async def render_replay(file: UploadFile, replay_id: str | None = None):
async def render_replay(
file: UploadFile,
replay_id: str | None = None,
target_player_id: int | None = None
):
# First check if the file is a replay file (extension .wowsreplay)
if not file.filename.endswith(".wowsreplay"):
raise HTTPException(
Expand All @@ -29,7 +33,7 @@ async def render_replay(file: UploadFile, replay_id: str | None = None):
if file.size > settings.replay.max_file_size:
raise HTTPException(
status_code=status.HTTP_413_REQUEST_ENTITY_TOO_LARGE,
detail="File is too large",
detail="File is too large"
)

# We're gonna write the replay data to a temporary file, in the following folder:
Expand All @@ -43,6 +47,12 @@ async def render_replay(file: UploadFile, replay_id: str | None = None):
replay_data: ReplayData = replay_info["hidden"]["replay_data"]

filepath = f"/tmp/wows-karma/minimap/{binascii.b2a_hex(os.urandom(7))}.mp4"
Renderer(replay_data, enable_chat=True, team_tracers=True).start(filepath)
renderer = Renderer(
replay_data,
enable_chat=True,
team_tracers=True,
target_player_id=target_player_id
)
renderer.start(filepath)

return FileResponse(filepath, media_type="video/mp4", filename=f"{replay_id or 'replay'}.mp4")

0 comments on commit fb5e850

Please sign in to comment.