From 152c1365cea9e903e68ca1e8dcf19c12c310682a Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Tue, 21 Jan 2025 00:09:06 -0500 Subject: [PATCH] add launchbox metadata examples for testing --- backend/tasks/fixtures/launchbox/files.xml | 8 + backend/tasks/fixtures/launchbox/mame.xml | 41 +++ backend/tasks/fixtures/launchbox/metadata.xml | 260 ++++++++++++++++++ .../tasks/fixtures/launchbox/platforms.xml | 20 ++ backend/tasks/update_launchbox_metadata.py | 10 +- poetry.lock | 2 +- pyproject.toml | 2 +- 7 files changed, 335 insertions(+), 8 deletions(-) create mode 100644 backend/tasks/fixtures/launchbox/files.xml create mode 100644 backend/tasks/fixtures/launchbox/mame.xml create mode 100644 backend/tasks/fixtures/launchbox/metadata.xml create mode 100644 backend/tasks/fixtures/launchbox/platforms.xml diff --git a/backend/tasks/fixtures/launchbox/files.xml b/backend/tasks/fixtures/launchbox/files.xml new file mode 100644 index 000000000..084152dc6 --- /dev/null +++ b/backend/tasks/fixtures/launchbox/files.xml @@ -0,0 +1,8 @@ + + + + 3DO Interactive Multiplayer + 20th Century Video Almanac (USA) + 20th Century Video Almanac (USA) + + diff --git a/backend/tasks/fixtures/launchbox/mame.xml b/backend/tasks/fixtures/launchbox/mame.xml new file mode 100644 index 000000000..896d25c59 --- /dev/null +++ b/backend/tasks/fixtures/launchbox/mame.xml @@ -0,0 +1,41 @@ + + + + wrlok_l3 + Warlok + preliminary + + Williams + 1982 + true + (L-3) + North America + false + false + false + false + false + false + false + false + false + false + false + false + Electromechanical / Pinball + Pinball + English + pinball/s7.cpp + + + Generic Keypad + Keyboard + wrlok_l3 + true + + + wrlok_l3 + Warlok (L-3) + Williams Classics + + diff --git a/backend/tasks/fixtures/launchbox/metadata.xml b/backend/tasks/fixtures/launchbox/metadata.xml new file mode 100644 index 000000000..118f399b4 --- /dev/null +++ b/backend/tasks/fixtures/launchbox/metadata.xml @@ -0,0 +1,260 @@ + + + + Paper Mario + 2000-08-11T00:00:00-07:00 + Mario pals around in an all-new action adventure! Mario's back in his first adventure since Super Mario 64, and this time, Bowser's bent on preventing a storybook ending. When Princess Peach is kidnapped, Mario plots to rescue the seven Star Spirits and rid the Mushroom Kingdom of Koopa's cruel cohorts. As he travels from the tropical jungles of Lavalava Island to the frosty heights of Shiver Mountain, he'll meet up with seven all-new companions... and he'll need help from each one or there'll be no happily ever after. + 1 + Released + false + http://www.youtube.com/watch?v=WoGJd0k_FR8 + 141 + 4.4416873449131513 + https://en.wikipedia.org/wiki/Paper_Mario_(video_game) + Nintendo 64 + E - Everyone + 403 + Role-Playing + Intelligent Systems + Nintendo + + + Mario Story + 141 + Japan + + + 纸片马力欧 + 141 + China + + + 纸片马里奥 + 141 + China + + + 141 + 5e4587a1-8505-4fd2-ace1-87613df5f5d1.png + Advertisement Flyer - Front + China + 2072259539 + + + 141 + 16231fc3-bcb3-4dbc-bbe4-f0bc36b31081.jpg + Advertisement Flyer - Front + North America + 727411021 + + + 141 + dfb30000-001e-432b-8e95-bd8e9fff3983.jpg + Advertisement Flyer - Front + North America + 583876627 + + + 141 + c417920f-1edc-4af1-95a2-2f55fb777194.jpg + Banner + 959239531 + + + 141 + e76b4339-482d-43e1-8ecb-4c6e1b442daa.jpg + Banner + 1545972692 + + + 141 + c205963e-7349-4755-8dc3-d7439a32a5a3.PNG + Box - 3D + Japan + 3690696107 + + + 141 + 1748e1a1-a1aa-4726-b9e8-4c04da848d58.png + Box - 3D + Europe + 2680176444 + + + 141 + c7ae433d-5e91-4da5-bb75-24b84b68e69c.png + Box - 3D + North America + 3778415585 + + + 141 + 0edddd5d-4175-423d-8418-9340c9eae803.jpg + Box - Back + North America + 4144827731 + + + 141 + 11a54e4a-6831-4f99-bff2-dc2e9c5bf779.jpg + Box - Back + Japan + 1527171011 + + + 141 + 10e9028c-3c48-44d1-9272-aac002e26c86.jpg + Box - Back + Europe + 1577175924 + + + 141 + 346c7be3-6533-4418-80a3-55c61f2abc11.jpg + Box - Front + Europe + 2640187913 + + + 141 + 856a0c08-0d44-4142-8315-8d0c72a679c5.jpg + Box - Front + Japan + 386642606 + + + 141 + eb7eb36a-2a90-4100-aa6b-1c9736e38ae6.png + Box - Front + North America + 390632758 + + + 141 + 310332a4-41d3-4606-bdb1-fedd21f0ea79.jpg + Box - Front + Australia + 936530111 + + + 141 + d5755b52-d75c-405d-98e7-20e54526bed3.jpg + Box - Spine + North America + 3913618231 + + + 141 + 8a47e006-a565-4906-8420-02e6de9a33ad.jpg + Box - Spine + Japan + 1761128152 + + + 141 + 90115c9c-48b9-4b79-b8ea-2033519d9923.png + Cart - 3D + North America + 3602298032 + + + 141 + 87d84d99-db78-4cbc-8450-fda0ffc3ce80.png + Cart - Front + North America + 22235904 + + + 141 + 1e0a96eb-a772-4003-9777-290ac0ea8356.png + Clear Logo + World + 2486841913 + + + 141 + 7fa59a62-99a9-4daa-a8b4-cf9681a73b55.png + Clear Logo + China + 1965202817 + + + 141 + bde294fa-b2d8-46dd-83da-4dc72623d922.png + Clear Logo + Japan + 1297661257 + + + 141 + fb6214d1-b0ba-4193-97d6-82128de00930.png + Clear Logo + Japan + 2974004483 + + + 141 + 87f88c4e-689d-4eef-958c-e65f957f4243.jpg + Fanart - Background + 3930859962 + + + 141 + fa81cb25-99d9-4de8-9526-929c1b791f4e.jpg + Fanart - Background + 397167211 + + + 141 + 70b9b270-361c-4134-8590-19760800245f.png + Fanart - Box - Front + 1787674306 + + + 141 + 7cf2a436-9ba6-42a4-9fe7-b805d6da2ccf.png + Screenshot - Game Title + China + 765939706 + + + 141 + af53b508-1585-4522-bb31-de6eb5c7f6e1.png + Screenshot - Game Title + China + 698006263 + + + 141 + 363e6708-2ec8-495a-be53-492e31d3d5f8.png + Screenshot - Game Title + Japan + 4083516316 + + + 141 + 561f42f1-9f37-4787-82b8-dd8156399c29.png + Screenshot - Game Title + North America + 2631830900 + + + 141 + 3f33ae92-6a49-4428-81b6-10ba85f4e027.png + Screenshot - Gameplay + 991180833 + + + 141 + 927204b2-64ee-4379-99a2-2a114c26f64b.png + Screenshot - Gameplay + 3132977303 + + + 141 + 15f6304e-85be-4863-a65d-9a81f25e7707.png + Screenshot - Gameplay + China + 1122730830 + + diff --git a/backend/tasks/fixtures/launchbox/platforms.xml b/backend/tasks/fixtures/launchbox/platforms.xml new file mode 100644 index 000000000..4db7fafa1 --- /dev/null +++ b/backend/tasks/fixtures/launchbox/platforms.xml @@ -0,0 +1,20 @@ + + + + 3DO Interactive Multiplayer + true + 1993-10-04T00:00:00-07:00 + The 3DO Company + Panasonic Corporation, Sanyo Electric Co., Ltd., GoldStar + 32-bit RISC ARM60 @ 12.5 MHz + 2 MB main RAM and 1 MB video RAM + 3DO "CLIO" @ 25 MHz, 3DO "MADAM" @ 25 MHz + 16-bit Stereo, Dolby Surround + 320x240 and 640x480 + CD-ROM + 1 (up to 8 if daisy-chained) + The 3DO Interactive Multiplayer (often called simply 3DO) is a video game console originally produced by Panasonic in 1993. Further renditions of the hardware were released in 1994 by Sanyo and Goldstar. The consoles were manufactured according to specifications created by The 3DO Company, and were originally designed by Dave Needle and RJ Mical of New Technology Group. The system was conceived by entrepreneur and Electronic Arts founder Trip Hawkins. + Consoles + false + + diff --git a/backend/tasks/update_launchbox_metadata.py b/backend/tasks/update_launchbox_metadata.py index 1781ae18d..eea076c96 100644 --- a/backend/tasks/update_launchbox_metadata.py +++ b/backend/tasks/update_launchbox_metadata.py @@ -1,17 +1,14 @@ import json import zipfile +from io import BytesIO from itertools import batched from typing import Final -try: - from defusedxml import ElementTree as ET -except ImportError: - from xml.etree import ElementTree as ET - from config import ( ENABLE_SCHEDULED_UPDATE_LAUNCHBOX_METADATA, SCHEDULED_UPDATE_LAUNCHBOX_METADATA_CRON, ) +from defusedxml import ElementTree as ET from handler.redis_handler import async_cache from logger.logger import log from tasks.tasks import RemoteFilePullTask @@ -41,7 +38,8 @@ class UpdateLaunchboxMetadataTask(RemoteFilePullTask): return try: - with zipfile.ZipFile(content) as z: + zip_file_bytes = BytesIO(content) + with zipfile.ZipFile(zip_file_bytes) as z: for file in z.namelist(): if file == "Platforms.xml": platform_dict = {} diff --git a/poetry.lock b/poetry.lock index 04f461f76..8e6d4e431 100644 --- a/poetry.lock +++ b/poetry.lock @@ -4071,4 +4071,4 @@ test = ["fakeredis", "pytest", "pytest-asyncio", "pytest-env", "pytest-mock", "p [metadata] lock-version = "2.1" python-versions = "^3.12" -content-hash = "0d1b8d7c24206129490663a62ab4c14f0c677b36c8baf58febdeff7a059e93c1" +content-hash = "93eb44e863ea892a88ff63c4ab4639686bd3652014265698b50c365fed221064" diff --git a/pyproject.toml b/pyproject.toml index bd6d105b4..2f801f1ee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,7 +51,7 @@ dependencies = [ "websockets == 12.0", "yarl ~= 1.14", "zipfile-deflate64 ~= 0.2", - "defusedxml (>=0.7.1,<0.8.0)", + "defusedxml ~= 0.7.1", ] [project.optional-dependencies]