mirror of
https://github.com/rommapp/romm.git
synced 2026-11-30 18:42:34 +01:00
Merge branch 'master' into calc-file-hashes-roms
This commit is contained in:
@@ -12,7 +12,7 @@ touch romm_mock/library/roms/switch/metroid.xci
|
||||
mkdir -p romm_mock/resources
|
||||
mkdir -p romm_mock/assets
|
||||
mkdir -p romm_mock/config
|
||||
touch romm_mock/config.yml
|
||||
touch romm_mock/config/config.yml
|
||||
```
|
||||
|
||||
### Setting up the backend
|
||||
|
||||
@@ -63,9 +63,14 @@ def upgrade() -> None:
|
||||
|
||||
# Add "roms/" prefix to each path in path_screenshots
|
||||
if path_screenshots:
|
||||
path_screenshots_list = json.loads(path_screenshots)
|
||||
path_screenshots_list = [f"roms/{path}" for path in path_screenshots_list]
|
||||
path_screenshots = json.dumps(path_screenshots_list)
|
||||
try:
|
||||
path_screenshots_list = json.loads(path_screenshots)
|
||||
path_screenshots_list = [
|
||||
f"roms/{path}" for path in path_screenshots_list
|
||||
]
|
||||
path_screenshots = json.dumps(path_screenshots_list)
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
|
||||
# Update the database with the new paths
|
||||
connection.execute(
|
||||
|
||||
@@ -58,7 +58,7 @@ async def add_collection(
|
||||
path_cover_l,
|
||||
path_cover_s,
|
||||
artwork_path,
|
||||
) = fs_resource_handler.build_artwork_path(_added_collection, file_ext)
|
||||
) = await fs_resource_handler.build_artwork_path(_added_collection, file_ext)
|
||||
|
||||
artwork_file = artwork.file.read()
|
||||
file_location_s = f"{artwork_path}/small.{file_ext}"
|
||||
@@ -70,7 +70,7 @@ async def add_collection(
|
||||
with open(file_location_l, "wb+") as artwork_l:
|
||||
artwork_l.write(artwork_file)
|
||||
else:
|
||||
path_cover_s, path_cover_l = fs_resource_handler.get_cover(
|
||||
path_cover_s, path_cover_l = await fs_resource_handler.get_cover(
|
||||
overwrite=True,
|
||||
entity=_added_collection,
|
||||
url_cover=_added_collection.url_cover,
|
||||
@@ -100,7 +100,8 @@ def get_collections(request: Request) -> list[CollectionSchema]:
|
||||
list[CollectionSchema]: List of collections
|
||||
"""
|
||||
|
||||
return db_collection_handler.get_collections(user_id=request.user.id)
|
||||
collections = db_collection_handler.get_collections()
|
||||
return CollectionSchema.for_user(request.user.id, collections)
|
||||
|
||||
|
||||
@protected_route(router.get, "/collections/{id}", ["collections.read"])
|
||||
@@ -128,6 +129,7 @@ async def update_collection(
|
||||
request: Request,
|
||||
id: int,
|
||||
remove_cover: bool = False,
|
||||
is_public: bool | None = None,
|
||||
artwork: UploadFile | None = None,
|
||||
) -> CollectionSchema:
|
||||
"""Update collection endpoint
|
||||
@@ -159,8 +161,8 @@ async def update_collection(
|
||||
cleaned_data = {
|
||||
"name": data.get("name", collection.name),
|
||||
"description": data.get("description", collection.description),
|
||||
"is_public": is_public if is_public is not None else collection.is_public,
|
||||
"roms": list(set(roms)),
|
||||
"is_public": data.get("is_public", collection.is_public),
|
||||
"user_id": request.user.id,
|
||||
}
|
||||
|
||||
@@ -174,7 +176,7 @@ async def update_collection(
|
||||
path_cover_l,
|
||||
path_cover_s,
|
||||
artwork_path,
|
||||
) = fs_resource_handler.build_artwork_path(collection, file_ext)
|
||||
) = await fs_resource_handler.build_artwork_path(collection, file_ext)
|
||||
|
||||
cleaned_data["path_cover_l"] = path_cover_l
|
||||
cleaned_data["path_cover_s"] = path_cover_s
|
||||
@@ -190,15 +192,13 @@ async def update_collection(
|
||||
artwork_l.write(artwork_file)
|
||||
cleaned_data.update({"url_cover": ""})
|
||||
else:
|
||||
if data.get(
|
||||
"url_cover", ""
|
||||
) != collection.url_cover or not fs_resource_handler.cover_exists(
|
||||
collection, CoverSize.BIG
|
||||
if data.get("url_cover", "") != collection.url_cover or not (
|
||||
await fs_resource_handler.cover_exists(collection, CoverSize.BIG)
|
||||
):
|
||||
cleaned_data.update(
|
||||
{"url_cover": data.get("url_cover", collection.url_cover)}
|
||||
)
|
||||
path_cover_s, path_cover_l = fs_resource_handler.get_cover(
|
||||
path_cover_s, path_cover_l = await fs_resource_handler.get_cover(
|
||||
overwrite=True,
|
||||
entity=collection,
|
||||
url_cover=data.get("url_cover", ""),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from datetime import datetime
|
||||
|
||||
from models.collection import Collection
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
@@ -22,3 +23,13 @@ class CollectionSchema(BaseModel):
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
@classmethod
|
||||
def for_user(
|
||||
cls, user_id: int, collections: list["Collection"]
|
||||
) -> list["CollectionSchema"]:
|
||||
return [
|
||||
cls.model_validate(c)
|
||||
for c in collections
|
||||
if c.user_id == user_id or c.is_public
|
||||
]
|
||||
|
||||
@@ -44,7 +44,7 @@ class RomUserSchema(BaseModel):
|
||||
from_attributes = True
|
||||
|
||||
@classmethod
|
||||
def for_user(cls, db_rom: Rom, user_id: int) -> RomUserSchema | None:
|
||||
def for_user(cls, user_id: int, db_rom: Rom) -> RomUserSchema | None:
|
||||
for n in db_rom.rom_users:
|
||||
if n.user_id == user_id:
|
||||
return cls.model_validate(n)
|
||||
@@ -52,7 +52,7 @@ class RomUserSchema(BaseModel):
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
def notes_for_user(cls, db_rom: Rom, user_id: int) -> list[UserNotesSchema]:
|
||||
def notes_for_user(cls, user_id: int, db_rom: Rom) -> list[UserNotesSchema]:
|
||||
return [
|
||||
{
|
||||
"user_id": n.user_id,
|
||||
@@ -123,7 +123,7 @@ class RomSchema(BaseModel):
|
||||
rom = cls.model_validate(db_rom)
|
||||
user_id = request.user.id
|
||||
|
||||
rom.rom_user = RomUserSchema.for_user(db_rom, user_id)
|
||||
rom.rom_user = RomUserSchema.for_user(user_id, db_rom)
|
||||
|
||||
return rom
|
||||
|
||||
@@ -155,8 +155,8 @@ class DetailedRomSchema(RomSchema):
|
||||
rom = cls.model_validate(db_rom)
|
||||
user_id = request.user.id
|
||||
|
||||
rom.rom_user = RomUserSchema.for_user(db_rom, user_id)
|
||||
rom.user_notes = RomUserSchema.notes_for_user(db_rom, user_id)
|
||||
rom.rom_user = RomUserSchema.for_user(user_id, db_rom)
|
||||
rom.user_notes = RomUserSchema.notes_for_user(user_id, db_rom)
|
||||
rom.sibling_roms = [
|
||||
RomSchema.model_validate(r) for r in db_rom.get_sibling_roms()
|
||||
]
|
||||
@@ -171,9 +171,9 @@ class DetailedRomSchema(RomSchema):
|
||||
for s in db_rom.screenshots
|
||||
if s.user_id == user_id
|
||||
]
|
||||
rom.user_collections = [
|
||||
CollectionSchema.model_validate(c) for c in db_rom.get_collections(user_id)
|
||||
]
|
||||
rom.user_collections = CollectionSchema.for_user(
|
||||
user_id, db_rom.get_collections()
|
||||
)
|
||||
|
||||
return rom
|
||||
|
||||
|
||||
@@ -302,9 +302,9 @@ async def update_rom(
|
||||
cleaned_data.get("moby_id", "")
|
||||
and int(cleaned_data.get("moby_id", "")) != rom.moby_id
|
||||
):
|
||||
moby_rom = meta_moby_handler.get_rom_by_id(cleaned_data["moby_id"])
|
||||
moby_rom = await meta_moby_handler.get_rom_by_id(cleaned_data["moby_id"])
|
||||
cleaned_data.update(moby_rom)
|
||||
path_screenshots = fs_resource_handler.get_rom_screenshots(
|
||||
path_screenshots = await fs_resource_handler.get_rom_screenshots(
|
||||
rom=rom,
|
||||
url_screenshots=cleaned_data.get("url_screenshots", []),
|
||||
)
|
||||
@@ -316,7 +316,7 @@ async def update_rom(
|
||||
):
|
||||
igdb_rom = meta_igdb_handler.get_rom_by_id(cleaned_data["igdb_id"])
|
||||
cleaned_data.update(igdb_rom)
|
||||
path_screenshots = fs_resource_handler.get_rom_screenshots(
|
||||
path_screenshots = await fs_resource_handler.get_rom_screenshots(
|
||||
rom=rom,
|
||||
url_screenshots=cleaned_data.get("url_screenshots", []),
|
||||
)
|
||||
@@ -372,7 +372,7 @@ async def update_rom(
|
||||
path_cover_l,
|
||||
path_cover_s,
|
||||
artwork_path,
|
||||
) = fs_resource_handler.build_artwork_path(rom, file_ext)
|
||||
) = await fs_resource_handler.build_artwork_path(rom, file_ext)
|
||||
|
||||
cleaned_data.update(
|
||||
{"path_cover_s": path_cover_s, "path_cover_l": path_cover_l}
|
||||
@@ -389,13 +389,11 @@ async def update_rom(
|
||||
artwork_l.write(artwork_file)
|
||||
cleaned_data.update({"url_cover": ""})
|
||||
else:
|
||||
if data.get(
|
||||
"url_cover", ""
|
||||
) != rom.url_cover or not fs_resource_handler.cover_exists(
|
||||
rom, CoverSize.BIG
|
||||
if data.get("url_cover", "") != rom.url_cover or not (
|
||||
await fs_resource_handler.cover_exists(rom, CoverSize.BIG)
|
||||
):
|
||||
cleaned_data.update({"url_cover": data.get("url_cover", rom.url_cover)})
|
||||
path_cover_s, path_cover_l = fs_resource_handler.get_cover(
|
||||
path_cover_s, path_cover_l = await fs_resource_handler.get_cover(
|
||||
overwrite=True,
|
||||
entity=rom,
|
||||
url_cover=data.get("url_cover", ""),
|
||||
|
||||
@@ -61,7 +61,7 @@ async def search_rom(
|
||||
igdb_matched_roms = meta_igdb_handler.get_matched_roms_by_id(
|
||||
int(search_term)
|
||||
)
|
||||
moby_matched_roms = meta_moby_handler.get_matched_roms_by_id(
|
||||
moby_matched_roms = await meta_moby_handler.get_matched_roms_by_id(
|
||||
int(search_term)
|
||||
)
|
||||
except ValueError as exc:
|
||||
@@ -74,7 +74,7 @@ async def search_rom(
|
||||
igdb_matched_roms = meta_igdb_handler.get_matched_roms_by_name(
|
||||
search_term, _get_main_platform_igdb_id(rom.platform)
|
||||
)
|
||||
moby_matched_roms = meta_moby_handler.get_matched_roms_by_name(
|
||||
moby_matched_roms = await meta_moby_handler.get_matched_roms_by_name(
|
||||
search_term, rom.platform.moby_id
|
||||
)
|
||||
|
||||
@@ -123,8 +123,6 @@ async def search_cover(
|
||||
detail="No SteamGridDB enabled",
|
||||
)
|
||||
|
||||
covers = await meta_sgdb_handler.get_details(
|
||||
requests_client=request.app.requests_client, search_term=search_term
|
||||
)
|
||||
covers = await meta_sgdb_handler.get_details(search_term=search_term)
|
||||
|
||||
return [SearchCoverSchema.model_validate(cover) for cover in covers]
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
from typing import Final
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Final
|
||||
|
||||
import emoji
|
||||
import socketio # type: ignore
|
||||
@@ -10,6 +13,7 @@ from exceptions.fs_exceptions import (
|
||||
FolderStructureNotMatchException,
|
||||
RomsNotFoundException,
|
||||
)
|
||||
from exceptions.socket_exceptions import ScanStoppedException
|
||||
from handler.database import db_firmware_handler, db_platform_handler, db_rom_handler
|
||||
from handler.filesystem import (
|
||||
fs_firmware_handler,
|
||||
@@ -23,24 +27,40 @@ from handler.redis_handler import high_prio_queue, redis_client, redis_url
|
||||
from handler.scan_handler import ScanType, scan_firmware, scan_platform, scan_rom
|
||||
from handler.socket_handler import socket_handler
|
||||
from logger.logger import log
|
||||
from models.platform import Platform
|
||||
from models.rom import Rom
|
||||
from rq import Worker
|
||||
from rq.job import Job
|
||||
from sqlalchemy.inspection import inspect
|
||||
from utils.context import initialize_context
|
||||
|
||||
EXCLUDED_FROM_DUMP: Final = {"created_at", "updated_at", "rom_user"}
|
||||
STOP_SCAN_FLAG: Final = "scan:stop"
|
||||
|
||||
|
||||
@dataclass
|
||||
class ScanStats:
|
||||
def __init__(self):
|
||||
self.scanned_platforms = 0
|
||||
self.added_platforms = 0
|
||||
self.metadata_platforms = 0
|
||||
self.scanned_roms = 0
|
||||
self.added_roms = 0
|
||||
self.metadata_roms = 0
|
||||
self.scanned_firmware = 0
|
||||
self.added_firmware = 0
|
||||
scanned_platforms: int = 0
|
||||
added_platforms: int = 0
|
||||
metadata_platforms: int = 0
|
||||
scanned_roms: int = 0
|
||||
added_roms: int = 0
|
||||
metadata_roms: int = 0
|
||||
scanned_firmware: int = 0
|
||||
added_firmware: int = 0
|
||||
|
||||
def __add__(self, other: Any) -> ScanStats:
|
||||
if not isinstance(other, ScanStats):
|
||||
return NotImplemented
|
||||
return ScanStats(
|
||||
scanned_platforms=self.scanned_platforms + other.scanned_platforms,
|
||||
added_platforms=self.added_platforms + other.added_platforms,
|
||||
metadata_platforms=self.metadata_platforms + other.metadata_platforms,
|
||||
scanned_roms=self.scanned_roms + other.scanned_roms,
|
||||
added_roms=self.added_roms + other.added_roms,
|
||||
metadata_roms=self.metadata_roms + other.metadata_roms,
|
||||
scanned_firmware=self.scanned_firmware + other.scanned_firmware,
|
||||
added_firmware=self.added_firmware + other.added_firmware,
|
||||
)
|
||||
|
||||
|
||||
def _get_socket_manager():
|
||||
@@ -78,6 +98,7 @@ def _should_scan_rom(scan_type: ScanType, rom: Rom, selected_roms: list):
|
||||
)
|
||||
|
||||
|
||||
@initialize_context()
|
||||
async def scan_platforms(
|
||||
platform_ids: list[int],
|
||||
scan_type: ScanType = ScanType.QUICK,
|
||||
@@ -115,6 +136,11 @@ async def scan_platforms(
|
||||
|
||||
scan_stats = ScanStats()
|
||||
|
||||
async def stop_scan():
|
||||
log.info(emoji.emojize(":stop_sign: Scan stopped manually"))
|
||||
await sm.emit("scan:done", scan_stats.__dict__)
|
||||
redis_client.delete(STOP_SCAN_FLAG)
|
||||
|
||||
try:
|
||||
platform_list = [
|
||||
db_platform_handler.get_platform(s).fs_slug for s in platform_ids
|
||||
@@ -128,164 +154,24 @@ async def scan_platforms(
|
||||
log.info(f"Found {len(platform_list)} platforms in file system ")
|
||||
|
||||
for platform_slug in platform_list:
|
||||
platform = db_platform_handler.get_platform_by_fs_slug(platform_slug)
|
||||
if platform and scan_type == ScanType.NEW_PLATFORMS:
|
||||
continue
|
||||
|
||||
scanned_platform = scan_platform(
|
||||
platform_slug, fs_platforms, metadata_sources=metadata_sources
|
||||
scan_stats += await _identify_platform(
|
||||
platform_slug=platform_slug,
|
||||
scan_type=scan_type,
|
||||
fs_platforms=fs_platforms,
|
||||
selected_roms=selected_roms,
|
||||
metadata_sources=metadata_sources,
|
||||
socket_manager=sm,
|
||||
)
|
||||
if platform:
|
||||
scanned_platform.id = platform.id
|
||||
# Keep the existing ids if they exist on the platform
|
||||
scanned_platform.igdb_id = scanned_platform.igdb_id or platform.igdb_id
|
||||
scanned_platform.moby_id = scanned_platform.moby_id or platform.moby_id
|
||||
|
||||
scan_stats.scanned_platforms += 1
|
||||
scan_stats.added_platforms += 1 if not platform else 0
|
||||
scan_stats.metadata_platforms += (
|
||||
1 if scanned_platform.igdb_id or scanned_platform.moby_id else 0
|
||||
)
|
||||
|
||||
platform = db_platform_handler.add_platform(scanned_platform)
|
||||
|
||||
await sm.emit(
|
||||
"scan:scanning_platform",
|
||||
PlatformSchema.model_validate(platform).model_dump(
|
||||
exclude=EXCLUDED_FROM_DUMP
|
||||
),
|
||||
)
|
||||
await sm.emit("", None)
|
||||
|
||||
# Scanning firmware
|
||||
try:
|
||||
fs_firmware = fs_firmware_handler.get_firmware(platform)
|
||||
except FirmwareNotFoundException:
|
||||
fs_firmware = []
|
||||
|
||||
if len(fs_firmware) == 0:
|
||||
log.warning(
|
||||
" ⚠️ No firmware found, skipping firmware scan for this platform"
|
||||
)
|
||||
else:
|
||||
log.info(f" {len(fs_firmware)} firmware files found")
|
||||
|
||||
for fs_fw in fs_firmware:
|
||||
firmware = db_firmware_handler.get_firmware_by_filename(
|
||||
platform.id, fs_fw
|
||||
)
|
||||
|
||||
scanned_firmware = scan_firmware(
|
||||
platform=platform,
|
||||
file_name=fs_fw,
|
||||
firmware=firmware,
|
||||
)
|
||||
|
||||
scan_stats.scanned_firmware += 1
|
||||
scan_stats.added_firmware += 1 if not firmware else 0
|
||||
|
||||
_added_firmware = db_firmware_handler.add_firmware(scanned_firmware)
|
||||
firmware = db_firmware_handler.get_firmware(_added_firmware.id)
|
||||
|
||||
# Scanning roms
|
||||
try:
|
||||
fs_roms = fs_rom_handler.get_roms(platform)
|
||||
except RomsNotFoundException as e:
|
||||
log.error(e)
|
||||
continue
|
||||
|
||||
if len(fs_roms) == 0:
|
||||
log.warning(
|
||||
" ⚠️ No roms found, verify that the folder structure is correct"
|
||||
)
|
||||
else:
|
||||
log.info(f" {len(fs_roms)} roms found")
|
||||
|
||||
for fs_rom in fs_roms:
|
||||
rom = db_rom_handler.get_rom_by_filename(
|
||||
platform.id, fs_rom["file_name"]
|
||||
)
|
||||
|
||||
if _should_scan_rom(
|
||||
scan_type=scan_type, rom=rom, selected_roms=selected_roms
|
||||
):
|
||||
scanned_rom = await scan_rom(
|
||||
platform=platform,
|
||||
rom_attrs=fs_rom,
|
||||
scan_type=scan_type,
|
||||
rom=rom,
|
||||
metadata_sources=metadata_sources,
|
||||
)
|
||||
|
||||
scan_stats.scanned_roms += 1
|
||||
scan_stats.added_roms += 1 if not rom else 0
|
||||
scan_stats.metadata_roms += (
|
||||
1 if scanned_rom.igdb_id or scanned_rom.moby_id else 0
|
||||
)
|
||||
|
||||
_added_rom = db_rom_handler.add_rom(scanned_rom)
|
||||
|
||||
path_cover_s, path_cover_l = fs_resource_handler.get_cover(
|
||||
overwrite=True,
|
||||
entity=_added_rom,
|
||||
url_cover=_added_rom.url_cover,
|
||||
)
|
||||
|
||||
path_screenshots = fs_resource_handler.get_rom_screenshots(
|
||||
rom=_added_rom,
|
||||
url_screenshots=_added_rom.url_screenshots,
|
||||
)
|
||||
|
||||
_added_rom.path_cover_s = path_cover_s
|
||||
_added_rom.path_cover_l = path_cover_l
|
||||
_added_rom.path_screenshots = path_screenshots
|
||||
# Update the scanned rom with the cover and screenshots paths and update database
|
||||
db_rom_handler.update_rom(
|
||||
_added_rom.id,
|
||||
{
|
||||
c: getattr(_added_rom, c)
|
||||
for c in inspect(_added_rom).mapper.column_attrs.keys()
|
||||
},
|
||||
)
|
||||
|
||||
await sm.emit(
|
||||
"scan:scanning_rom",
|
||||
{
|
||||
"platform_name": platform.name,
|
||||
"platform_slug": platform.slug,
|
||||
**RomSchema.model_validate(_added_rom).model_dump(
|
||||
exclude=EXCLUDED_FROM_DUMP
|
||||
),
|
||||
},
|
||||
)
|
||||
await sm.emit("", None)
|
||||
elif rom:
|
||||
# Just to update the filesystem data
|
||||
rom.file_name = fs_rom["file_name"]
|
||||
rom.multi = fs_rom["multi"]
|
||||
rom.files = fs_rom["files"]
|
||||
db_rom_handler.add_rom(rom)
|
||||
|
||||
# Only purge entries if there are some file remaining in the library
|
||||
# This protects against accidental deletion of entries when
|
||||
# the folder structure is not correct or the drive is not mounted
|
||||
if len(fs_roms) > 0:
|
||||
db_rom_handler.purge_roms(
|
||||
platform.id, [rom["file_name"] for rom in fs_roms]
|
||||
)
|
||||
|
||||
# Same protection for firmware
|
||||
if len(fs_firmware) > 0:
|
||||
db_firmware_handler.purge_firmware(
|
||||
platform.id, [fw for fw in fs_firmware]
|
||||
)
|
||||
|
||||
# Same protection for platforms
|
||||
if len(fs_platforms) > 0:
|
||||
db_platform_handler.purge_platforms(fs_platforms)
|
||||
|
||||
log.info(emoji.emojize(":check_mark: Scan completed "))
|
||||
log.info(emoji.emojize(":check_mark: Scan completed "))
|
||||
await sm.emit("scan:done", scan_stats.__dict__)
|
||||
except ScanStoppedException:
|
||||
await stop_scan()
|
||||
return
|
||||
except Exception as e:
|
||||
log.error(e)
|
||||
# Catch all exceptions and emit error to the client
|
||||
@@ -293,6 +179,204 @@ async def scan_platforms(
|
||||
return
|
||||
|
||||
|
||||
async def _identify_platform(
|
||||
platform_slug: str,
|
||||
scan_type: ScanType,
|
||||
fs_platforms: list[str],
|
||||
selected_roms: list[str],
|
||||
metadata_sources: list[str],
|
||||
socket_manager: socketio.AsyncRedisManager,
|
||||
) -> ScanStats:
|
||||
# Stop the scan if the flag is set
|
||||
if redis_client.get(STOP_SCAN_FLAG):
|
||||
raise ScanStoppedException()
|
||||
|
||||
scan_stats = ScanStats()
|
||||
|
||||
platform = db_platform_handler.get_platform_by_fs_slug(platform_slug)
|
||||
if platform and scan_type == ScanType.NEW_PLATFORMS:
|
||||
return scan_stats
|
||||
|
||||
scanned_platform = scan_platform(
|
||||
platform_slug, fs_platforms, metadata_sources=metadata_sources
|
||||
)
|
||||
if platform:
|
||||
scanned_platform.id = platform.id
|
||||
# Keep the existing ids if they exist on the platform
|
||||
scanned_platform.igdb_id = scanned_platform.igdb_id or platform.igdb_id
|
||||
scanned_platform.moby_id = scanned_platform.moby_id or platform.moby_id
|
||||
|
||||
scan_stats.scanned_platforms += 1
|
||||
scan_stats.added_platforms += 1 if not platform else 0
|
||||
scan_stats.metadata_platforms += (
|
||||
1 if scanned_platform.igdb_id or scanned_platform.moby_id else 0
|
||||
)
|
||||
|
||||
platform = db_platform_handler.add_platform(scanned_platform)
|
||||
|
||||
await socket_manager.emit(
|
||||
"scan:scanning_platform",
|
||||
PlatformSchema.model_validate(platform).model_dump(
|
||||
include={"id", "name", "slug"}
|
||||
),
|
||||
)
|
||||
await socket_manager.emit("", None)
|
||||
|
||||
# Scanning firmware
|
||||
try:
|
||||
fs_firmware = fs_firmware_handler.get_firmware(platform)
|
||||
except FirmwareNotFoundException:
|
||||
fs_firmware = []
|
||||
|
||||
if len(fs_firmware) == 0:
|
||||
log.warning(" ⚠️ No firmware found, skipping firmware scan for this platform")
|
||||
else:
|
||||
log.info(f" {len(fs_firmware)} firmware files found")
|
||||
|
||||
for fs_fw in fs_firmware:
|
||||
scan_stats += await _identify_firmware(
|
||||
platform=platform,
|
||||
fs_fw=fs_fw,
|
||||
)
|
||||
|
||||
# Scanning roms
|
||||
try:
|
||||
fs_roms = fs_rom_handler.get_roms(platform)
|
||||
except RomsNotFoundException as e:
|
||||
log.error(e)
|
||||
return scan_stats
|
||||
|
||||
if len(fs_roms) == 0:
|
||||
log.warning(" ⚠️ No roms found, verify that the folder structure is correct")
|
||||
else:
|
||||
log.info(f" {len(fs_roms)} roms found")
|
||||
|
||||
for fs_rom in fs_roms:
|
||||
scan_stats += await _identify_rom(
|
||||
platform=platform,
|
||||
fs_rom=fs_rom,
|
||||
scan_type=scan_type,
|
||||
selected_roms=selected_roms,
|
||||
metadata_sources=metadata_sources,
|
||||
socket_manager=socket_manager,
|
||||
)
|
||||
|
||||
# Only purge entries if there are some file remaining in the library
|
||||
# This protects against accidental deletion of entries when
|
||||
# the folder structure is not correct or the drive is not mounted
|
||||
|
||||
if len(fs_roms) > 0:
|
||||
db_rom_handler.purge_roms(platform.id, [rom["file_name"] for rom in fs_roms])
|
||||
|
||||
# Same protection for firmware
|
||||
if len(fs_firmware) > 0:
|
||||
db_firmware_handler.purge_firmware(platform.id, [fw for fw in fs_firmware])
|
||||
|
||||
return scan_stats
|
||||
|
||||
|
||||
async def _identify_firmware(
|
||||
platform: Platform,
|
||||
fs_fw: str,
|
||||
) -> ScanStats:
|
||||
scan_stats = ScanStats()
|
||||
|
||||
# Break early if the flag is set
|
||||
if redis_client.get(STOP_SCAN_FLAG):
|
||||
return scan_stats
|
||||
|
||||
firmware = db_firmware_handler.get_firmware_by_filename(platform.id, fs_fw)
|
||||
|
||||
scanned_firmware = scan_firmware(
|
||||
platform=platform,
|
||||
file_name=fs_fw,
|
||||
firmware=firmware,
|
||||
)
|
||||
|
||||
scan_stats.scanned_firmware += 1
|
||||
scan_stats.added_firmware += 1 if not firmware else 0
|
||||
|
||||
db_firmware_handler.add_firmware(scanned_firmware)
|
||||
return scan_stats
|
||||
|
||||
|
||||
async def _identify_rom(
|
||||
platform: Platform,
|
||||
fs_rom: dict,
|
||||
scan_type: ScanType,
|
||||
selected_roms: list[str],
|
||||
metadata_sources: list[str],
|
||||
socket_manager: socketio.AsyncRedisManager,
|
||||
) -> ScanStats:
|
||||
scan_stats = ScanStats()
|
||||
|
||||
# Break early if the flag is set
|
||||
if redis_client.get(STOP_SCAN_FLAG):
|
||||
return scan_stats
|
||||
|
||||
rom = db_rom_handler.get_rom_by_filename(platform.id, fs_rom["file_name"])
|
||||
|
||||
if not _should_scan_rom(scan_type=scan_type, rom=rom, selected_roms=selected_roms):
|
||||
# Just to update the filesystem data
|
||||
rom.file_name = fs_rom["file_name"]
|
||||
rom.multi = fs_rom["multi"]
|
||||
rom.files = fs_rom["files"]
|
||||
db_rom_handler.add_rom(rom)
|
||||
|
||||
return scan_stats
|
||||
|
||||
scanned_rom = await scan_rom(
|
||||
platform=platform,
|
||||
rom_attrs=fs_rom,
|
||||
scan_type=scan_type,
|
||||
rom=rom,
|
||||
metadata_sources=metadata_sources,
|
||||
)
|
||||
|
||||
scan_stats.scanned_roms += 1
|
||||
scan_stats.added_roms += 1 if not rom else 0
|
||||
scan_stats.metadata_roms += 1 if scanned_rom.igdb_id or scanned_rom.moby_id else 0
|
||||
|
||||
_added_rom = db_rom_handler.add_rom(scanned_rom)
|
||||
|
||||
path_cover_s, path_cover_l = await fs_resource_handler.get_cover(
|
||||
overwrite=True,
|
||||
entity=_added_rom,
|
||||
url_cover=_added_rom.url_cover,
|
||||
)
|
||||
|
||||
path_screenshots = await fs_resource_handler.get_rom_screenshots(
|
||||
rom=_added_rom,
|
||||
url_screenshots=_added_rom.url_screenshots,
|
||||
)
|
||||
|
||||
_added_rom.path_cover_s = path_cover_s
|
||||
_added_rom.path_cover_l = path_cover_l
|
||||
_added_rom.path_screenshots = path_screenshots
|
||||
# Update the scanned rom with the cover and screenshots paths and update database
|
||||
db_rom_handler.update_rom(
|
||||
_added_rom.id,
|
||||
{
|
||||
c: getattr(_added_rom, c)
|
||||
for c in inspect(_added_rom).mapper.column_attrs.keys()
|
||||
},
|
||||
)
|
||||
|
||||
await socket_manager.emit(
|
||||
"scan:scanning_rom",
|
||||
{
|
||||
"platform_name": platform.name,
|
||||
"platform_slug": platform.slug,
|
||||
**RomSchema.model_validate(_added_rom).model_dump(
|
||||
exclude={"created_at", "updated_at", "rom_user"}
|
||||
),
|
||||
},
|
||||
)
|
||||
await socket_manager.emit("", None)
|
||||
|
||||
return scan_stats
|
||||
|
||||
|
||||
@socket_handler.socket_server.on("scan")
|
||||
async def scan_handler(_sid: str, options: dict):
|
||||
"""Scan socket endpoint
|
||||
@@ -323,14 +407,12 @@ async def scan_handler(_sid: str, options: dict):
|
||||
async def stop_scan_handler(_sid: str):
|
||||
"""Stop scan socket endpoint"""
|
||||
|
||||
log.info(emoji.emojize(":stop_button: Stopping scan..."))
|
||||
log.info(emoji.emojize(":stop_button: Stop scan requested..."))
|
||||
|
||||
async def cancel_job(job: Job):
|
||||
job.cancel()
|
||||
log.info(emoji.emojize(":stop_button: Scan stopped"))
|
||||
|
||||
sm = _get_socket_manager()
|
||||
await sm.emit("scan:done_ko", "manually stopped")
|
||||
redis_client.set(STOP_SCAN_FLAG, 1)
|
||||
log.info(emoji.emojize(":stop_button: Job found, stopping scan..."))
|
||||
|
||||
existing_jobs = high_prio_queue.get_jobs()
|
||||
for job in existing_jobs:
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
from main import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
with TestClient(app) as client:
|
||||
yield client
|
||||
|
||||
|
||||
def test_delete_saves(access_token, save):
|
||||
def test_delete_saves(client, access_token, save):
|
||||
response = client.post(
|
||||
"/saves/delete",
|
||||
headers={"Authorization": f"Bearer {access_token}"},
|
||||
@@ -16,7 +21,7 @@ def test_delete_saves(access_token, save):
|
||||
assert body["msg"] == "Successfully deleted 1 saves"
|
||||
|
||||
|
||||
def test_delete_states(access_token, state):
|
||||
def test_delete_states(client, access_token, state):
|
||||
response = client.post(
|
||||
"/states/delete",
|
||||
headers={"Authorization": f"Bearer {access_token}"},
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
from main import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
with TestClient(app) as client:
|
||||
yield client
|
||||
|
||||
|
||||
def test_config():
|
||||
def test_config(client):
|
||||
response = client.get("/config")
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
from main import app
|
||||
from utils import get_version
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
with TestClient(app) as client:
|
||||
yield client
|
||||
|
||||
|
||||
def test_heartbeat():
|
||||
def test_heartbeat(client):
|
||||
response = client.get("/heartbeat")
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
@@ -2,20 +2,24 @@ import base64
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
from handler.redis_handler import cache
|
||||
from handler.redis_handler import sync_cache
|
||||
from main import app
|
||||
from models.user import Role
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
with TestClient(app) as client:
|
||||
yield client
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def clear_cache():
|
||||
yield
|
||||
cache.flushall()
|
||||
sync_cache.flushall()
|
||||
|
||||
|
||||
def test_login_logout(admin_user):
|
||||
def test_login_logout(client, admin_user):
|
||||
response = client.get("/login")
|
||||
|
||||
assert response.status_code == 405
|
||||
@@ -24,7 +28,7 @@ def test_login_logout(admin_user):
|
||||
response = client.post("/login", headers={"Authorization": f"Basic {basic_auth}"})
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.cookies.get("session")
|
||||
assert response.cookies.get("romm_session")
|
||||
assert response.json()["msg"] == "Successfully logged in"
|
||||
|
||||
response = client.post("/logout")
|
||||
@@ -33,7 +37,7 @@ def test_login_logout(admin_user):
|
||||
assert response.json()["msg"] == "Successfully logged out"
|
||||
|
||||
|
||||
def test_get_all_users(access_token):
|
||||
def test_get_all_users(client, access_token):
|
||||
response = client.get("/users", headers={"Authorization": f"Bearer {access_token}"})
|
||||
assert response.status_code == 200
|
||||
|
||||
@@ -42,7 +46,7 @@ def test_get_all_users(access_token):
|
||||
assert users[0]["username"] == "test_admin"
|
||||
|
||||
|
||||
def test_get_user(access_token, editor_user):
|
||||
def test_get_user(client, access_token, editor_user):
|
||||
response = client.get(
|
||||
f"/users/{editor_user.id}", headers={"Authorization": f"Bearer {access_token}"}
|
||||
)
|
||||
@@ -52,7 +56,7 @@ def test_get_user(access_token, editor_user):
|
||||
assert user["username"] == "test_editor"
|
||||
|
||||
|
||||
def test_create_user(access_token):
|
||||
def test_create_user(client, access_token):
|
||||
response = client.post(
|
||||
"/users",
|
||||
params={
|
||||
@@ -69,7 +73,7 @@ def test_create_user(access_token):
|
||||
assert user["role"] == "viewer"
|
||||
|
||||
|
||||
def test_update_user(access_token, editor_user):
|
||||
def test_update_user(client, access_token, editor_user):
|
||||
assert editor_user.role == Role.EDITOR
|
||||
|
||||
response = client.put(
|
||||
@@ -83,7 +87,7 @@ def test_update_user(access_token, editor_user):
|
||||
assert user["role"] == "viewer"
|
||||
|
||||
|
||||
def test_delete_user(access_token, editor_user):
|
||||
def test_delete_user(client, access_token, editor_user):
|
||||
response = client.delete(
|
||||
f"/users/{editor_user.id}", headers={"Authorization": f"Bearer {access_token}"}
|
||||
)
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
import pytest
|
||||
from endpoints.auth import ACCESS_TOKEN_EXPIRE_MINUTES
|
||||
from fastapi.exceptions import HTTPException
|
||||
from fastapi.testclient import TestClient
|
||||
from handler.auth.base_handler import WRITE_SCOPES
|
||||
from main import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
with TestClient(app) as client:
|
||||
yield client
|
||||
|
||||
|
||||
def test_refreshing_oauth_token_basic(refresh_token):
|
||||
def test_refreshing_oauth_token_basic(client, refresh_token):
|
||||
response = client.post(
|
||||
"/token",
|
||||
data={
|
||||
@@ -23,7 +28,7 @@ def test_refreshing_oauth_token_basic(refresh_token):
|
||||
assert body["expires"] == ACCESS_TOKEN_EXPIRE_MINUTES * 60
|
||||
|
||||
|
||||
def test_refreshing_oauth_token_without_refresh_token():
|
||||
def test_refreshing_oauth_token_without_refresh_token(client):
|
||||
try:
|
||||
client.post(
|
||||
"/token",
|
||||
@@ -36,7 +41,7 @@ def test_refreshing_oauth_token_without_refresh_token():
|
||||
assert e.detail == "Missing refresh token"
|
||||
|
||||
|
||||
def test_refreshing_oauth_token_with_invalid_refresh_token():
|
||||
def test_refreshing_oauth_token_with_invalid_refresh_token(client):
|
||||
try:
|
||||
client.post(
|
||||
"/token",
|
||||
@@ -50,7 +55,7 @@ def test_refreshing_oauth_token_with_invalid_refresh_token():
|
||||
assert e.detail == "Invalid refresh token"
|
||||
|
||||
|
||||
def test_auth_via_upass(admin_user):
|
||||
def test_auth_via_upass(client, admin_user):
|
||||
response = client.post(
|
||||
"/token",
|
||||
data={
|
||||
@@ -68,7 +73,7 @@ def test_auth_via_upass(admin_user):
|
||||
assert body["expires"] == ACCESS_TOKEN_EXPIRE_MINUTES * 60
|
||||
|
||||
|
||||
def test_auth_via_upass_with_invalid_credentials(admin_user):
|
||||
def test_auth_via_upass_with_invalid_credentials(client, admin_user):
|
||||
try:
|
||||
client.post(
|
||||
"/token",
|
||||
@@ -83,7 +88,7 @@ def test_auth_via_upass_with_invalid_credentials(admin_user):
|
||||
assert e.detail == "Invalid username or password"
|
||||
|
||||
|
||||
def test_auth_via_upass_with_excess_scopes(viewer_user):
|
||||
def test_auth_via_upass_with_excess_scopes(client, viewer_user):
|
||||
try:
|
||||
client.post(
|
||||
"/token",
|
||||
@@ -99,7 +104,7 @@ def test_auth_via_upass_with_excess_scopes(viewer_user):
|
||||
assert e.detail == "Insufficient scope"
|
||||
|
||||
|
||||
def test_auth_with_invalid_grant_type():
|
||||
def test_auth_with_invalid_grant_type(client):
|
||||
try:
|
||||
client.post(
|
||||
"/token",
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
from main import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
with TestClient(app) as client:
|
||||
yield client
|
||||
|
||||
|
||||
def test_get_platforms(access_token, platform):
|
||||
def test_get_platforms(client, access_token, platform):
|
||||
response = client.get("/platforms")
|
||||
assert response.status_code == 403
|
||||
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
from main import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
with TestClient(app) as client:
|
||||
yield client
|
||||
|
||||
|
||||
def test_get_raw_asset(access_token):
|
||||
def test_get_raw_asset(client, access_token):
|
||||
response = client.get(
|
||||
"/raw/assets/users/557365723a31/saves/n64/mupen64/Super Mario 64 (J) (Rev A).sav"
|
||||
)
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
from handler.filesystem.roms_handler import FSRomsHandler
|
||||
from handler.metadata.igdb_handler import IGDBBaseHandler
|
||||
from main import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
with TestClient(app) as client:
|
||||
yield client
|
||||
|
||||
|
||||
def test_get_rom(access_token, rom):
|
||||
def test_get_rom(client, access_token, rom):
|
||||
response = client.get(
|
||||
f"/roms/{rom.id}",
|
||||
headers={"Authorization": f"Bearer {access_token}"},
|
||||
@@ -17,7 +24,7 @@ def test_get_rom(access_token, rom):
|
||||
assert body["id"] == rom.id
|
||||
|
||||
|
||||
def test_get_all_roms(access_token, rom, platform):
|
||||
def test_get_all_roms(client, access_token, rom, platform):
|
||||
response = client.get(
|
||||
"/roms",
|
||||
headers={"Authorization": f"Bearer {access_token}"},
|
||||
@@ -30,9 +37,9 @@ def test_get_all_roms(access_token, rom, platform):
|
||||
assert body[0]["id"] == rom.id
|
||||
|
||||
|
||||
@patch("endpoints.rom.fs_rom_handler.rename_file")
|
||||
@patch("endpoints.rom.meta_igdb_handler.get_rom_by_id")
|
||||
def test_update_rom(rename_file_mock, get_rom_by_id_mock, access_token, rom):
|
||||
@patch.object(FSRomsHandler, "rename_file")
|
||||
@patch.object(IGDBBaseHandler, "get_rom_by_id")
|
||||
def test_update_rom(rename_file_mock, get_rom_by_id_mock, client, access_token, rom):
|
||||
response = client.put(
|
||||
f"/roms/{rom.id}",
|
||||
headers={"Authorization": f"Bearer {access_token}"},
|
||||
@@ -67,7 +74,7 @@ def test_update_rom(rename_file_mock, get_rom_by_id_mock, access_token, rom):
|
||||
assert get_rom_by_id_mock.called
|
||||
|
||||
|
||||
def test_delete_roms(access_token, rom):
|
||||
def test_delete_roms(client, access_token, rom):
|
||||
response = client.post(
|
||||
"/roms/delete",
|
||||
headers={"Authorization": f"Bearer {access_token}"},
|
||||
|
||||
1
backend/exceptions/socket_exceptions.py
Normal file
1
backend/exceptions/socket_exceptions.py
Normal file
@@ -0,0 +1 @@
|
||||
class ScanStoppedException(Exception): ...
|
||||
@@ -28,15 +28,9 @@ class DBCollectionsHandler(DBBaseHandler):
|
||||
)
|
||||
|
||||
@begin_session
|
||||
def get_collections(
|
||||
self, user_id: int, session: Session = None
|
||||
) -> Select[tuple[Collection]]:
|
||||
def get_collections(self, session: Session = None) -> Select[tuple[Collection]]:
|
||||
return (
|
||||
session.scalars(
|
||||
select(Collection)
|
||||
.filter_by(user_id=user_id)
|
||||
.order_by(Collection.name.asc())
|
||||
) # type: ignore[attr-defined]
|
||||
session.scalars(select(Collection).order_by(Collection.name.asc())) # type: ignore[attr-defined]
|
||||
.unique()
|
||||
.all()
|
||||
)
|
||||
|
||||
@@ -29,7 +29,7 @@ class DBPlatformsHandler(DBBaseHandler):
|
||||
@with_roms
|
||||
def add_platform(
|
||||
self, platform: Platform, query: Query = None, session: Session = None
|
||||
) -> Platform | None:
|
||||
) -> Platform:
|
||||
platform = session.merge(platform)
|
||||
session.flush()
|
||||
|
||||
|
||||
@@ -181,16 +181,12 @@ class DBRomsHandler(DBBaseHandler):
|
||||
|
||||
@begin_session
|
||||
def get_rom_collections(
|
||||
self, rom: Rom, user_id: int, session: Session = None
|
||||
self, rom: Rom, session: Session = None
|
||||
) -> list[Collection]:
|
||||
|
||||
return (
|
||||
session.scalars(
|
||||
select(Collection)
|
||||
.filter(
|
||||
func.json_contains(Collection.roms, f"{rom.id}"),
|
||||
Collection.user_id == user_id,
|
||||
)
|
||||
.filter(func.json_contains(Collection.roms, f"{rom.id}"))
|
||||
.order_by(Collection.name.asc())
|
||||
)
|
||||
.unique()
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import glob
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
import requests
|
||||
import httpx
|
||||
from anyio import Path, open_file
|
||||
from config import RESOURCES_BASE_PATH
|
||||
from fastapi import HTTPException, status
|
||||
from logger.logger import log
|
||||
@@ -10,16 +9,14 @@ from models.collection import Collection
|
||||
from models.rom import Rom
|
||||
from PIL import Image
|
||||
from urllib3.exceptions import ProtocolError
|
||||
from utils.context import ctx_httpx_client
|
||||
|
||||
from .base_handler import CoverSize, FSHandler
|
||||
|
||||
|
||||
class FSResourcesHandler(FSHandler):
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def cover_exists(entity: Rom | Collection, size: CoverSize) -> bool:
|
||||
async def cover_exists(entity: Rom | Collection, size: CoverSize) -> bool:
|
||||
"""Check if rom cover exists in filesystem
|
||||
|
||||
Args:
|
||||
@@ -29,10 +26,12 @@ class FSResourcesHandler(FSHandler):
|
||||
Returns
|
||||
True if cover exists in filesystem else False
|
||||
"""
|
||||
matched_files = glob.glob(
|
||||
f"{RESOURCES_BASE_PATH}/{entity.fs_resources_path}/cover/{size.value}.*"
|
||||
)
|
||||
return len(matched_files) > 0
|
||||
async for _ in Path(
|
||||
f"{RESOURCES_BASE_PATH}/{entity.fs_resources_path}/cover"
|
||||
).glob(f"{size.value}.*"):
|
||||
# At least one file found.
|
||||
return True
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def resize_cover_to_small(cover_path: str) -> None:
|
||||
@@ -48,7 +47,7 @@ class FSResourcesHandler(FSHandler):
|
||||
small_img = cover.resize(small_size)
|
||||
small_img.save(cover_path)
|
||||
|
||||
def _store_cover(
|
||||
async def _store_cover(
|
||||
self, entity: Rom | Collection, url_cover: str, size: CoverSize
|
||||
) -> None:
|
||||
"""Store roms resources in filesystem
|
||||
@@ -62,27 +61,25 @@ class FSResourcesHandler(FSHandler):
|
||||
cover_file = f"{size.value}.png"
|
||||
cover_path = f"{RESOURCES_BASE_PATH}/{entity.fs_resources_path}/cover"
|
||||
|
||||
httpx_client = ctx_httpx_client.get()
|
||||
try:
|
||||
res = requests.get(
|
||||
url_cover,
|
||||
stream=True,
|
||||
timeout=120,
|
||||
)
|
||||
except requests.exceptions.ConnectionError as exc:
|
||||
async with httpx_client.stream("GET", url_cover, timeout=120) as response:
|
||||
if response.status_code == 200:
|
||||
await Path(cover_path).mkdir(parents=True, exist_ok=True)
|
||||
async with await open_file(f"{cover_path}/{cover_file}", "wb") as f:
|
||||
async for chunk in response.aiter_raw():
|
||||
await f.write(chunk)
|
||||
except httpx.NetworkError as exc:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
|
||||
detail=f"Unable to fetch cover at {url_cover}: {str(exc)}",
|
||||
) from exc
|
||||
|
||||
if res.status_code == 200:
|
||||
Path(cover_path).mkdir(parents=True, exist_ok=True)
|
||||
with open(f"{cover_path}/{cover_file}", "wb") as f:
|
||||
shutil.copyfileobj(res.raw, f)
|
||||
if size == CoverSize.SMALL:
|
||||
self.resize_cover_to_small(f"{cover_path}/{cover_file}")
|
||||
if size == CoverSize.SMALL:
|
||||
self.resize_cover_to_small(f"{cover_path}/{cover_file}")
|
||||
|
||||
@staticmethod
|
||||
def _get_cover_path(entity: Rom | Collection, size: CoverSize) -> str:
|
||||
async def _get_cover_path(entity: Rom | Collection, size: CoverSize) -> str:
|
||||
"""Returns rom cover filesystem path adapted to frontend folder structure
|
||||
|
||||
Args:
|
||||
@@ -90,33 +87,35 @@ class FSResourcesHandler(FSHandler):
|
||||
file_name: name of rom file
|
||||
size: size of the cover
|
||||
"""
|
||||
file_path = (
|
||||
f"{RESOURCES_BASE_PATH}/{entity.fs_resources_path}/cover/{size.value}.*"
|
||||
)
|
||||
matched_files = glob.glob(file_path, recursive=True)
|
||||
return (
|
||||
matched_files[0].replace(RESOURCES_BASE_PATH, "") if matched_files else ""
|
||||
)
|
||||
async for matched_file in Path(
|
||||
f"{RESOURCES_BASE_PATH}/{entity.fs_resources_path}/cover"
|
||||
).glob(f"{size.value}.*"):
|
||||
return str(matched_file.relative_to(RESOURCES_BASE_PATH))
|
||||
return ""
|
||||
|
||||
def get_cover(
|
||||
async def get_cover(
|
||||
self, entity: Rom | Collection | None, overwrite: bool, url_cover: str = ""
|
||||
) -> tuple[str, str]:
|
||||
if not entity:
|
||||
return "", ""
|
||||
|
||||
if (overwrite or not self.cover_exists(entity, CoverSize.SMALL)) and url_cover:
|
||||
self._store_cover(entity, url_cover, CoverSize.SMALL)
|
||||
small_cover_exists = await self.cover_exists(entity, CoverSize.SMALL)
|
||||
if url_cover and (overwrite or not small_cover_exists):
|
||||
await self._store_cover(entity, url_cover, CoverSize.SMALL)
|
||||
small_cover_exists = await self.cover_exists(entity, CoverSize.SMALL)
|
||||
path_cover_s = (
|
||||
self._get_cover_path(entity, CoverSize.SMALL)
|
||||
if self.cover_exists(entity, CoverSize.SMALL)
|
||||
(await self._get_cover_path(entity, CoverSize.SMALL))
|
||||
if small_cover_exists
|
||||
else ""
|
||||
)
|
||||
|
||||
if (overwrite or not self.cover_exists(entity, CoverSize.BIG)) and url_cover:
|
||||
self._store_cover(entity, url_cover, CoverSize.BIG)
|
||||
big_cover_exists = await self.cover_exists(entity, CoverSize.BIG)
|
||||
if url_cover and (overwrite or not big_cover_exists):
|
||||
await self._store_cover(entity, url_cover, CoverSize.BIG)
|
||||
big_cover_exists = await self.cover_exists(entity, CoverSize.BIG)
|
||||
path_cover_l = (
|
||||
self._get_cover_path(entity, CoverSize.BIG)
|
||||
if self.cover_exists(entity, CoverSize.BIG)
|
||||
(await self._get_cover_path(entity, CoverSize.BIG))
|
||||
if big_cover_exists
|
||||
else ""
|
||||
)
|
||||
|
||||
@@ -127,8 +126,8 @@ class FSResourcesHandler(FSHandler):
|
||||
if not entity:
|
||||
return {"path_cover_s": "", "path_cover_l": ""}
|
||||
|
||||
cover_path = f"{RESOURCES_BASE_PATH}/{entity.fs_resources_path}/cover"
|
||||
try:
|
||||
cover_path = f"{RESOURCES_BASE_PATH}/{entity.fs_resources_path}/cover"
|
||||
shutil.rmtree(cover_path)
|
||||
except FileNotFoundError:
|
||||
log.warning(
|
||||
@@ -138,23 +137,20 @@ class FSResourcesHandler(FSHandler):
|
||||
return {"path_cover_s": "", "path_cover_l": ""}
|
||||
|
||||
@staticmethod
|
||||
def build_artwork_path(entity: Rom | Collection | None, file_ext: str):
|
||||
async def build_artwork_path(entity: Rom | Collection | None, file_ext: str):
|
||||
if not entity:
|
||||
return "", "", ""
|
||||
|
||||
path_cover_l = (
|
||||
f"{entity.fs_resources_path}/cover/{CoverSize.BIG.value}.{file_ext}"
|
||||
)
|
||||
path_cover_s = (
|
||||
f"{entity.fs_resources_path}/cover/{CoverSize.SMALL.value}.{file_ext}"
|
||||
)
|
||||
path_cover = f"{entity.fs_resources_path}/cover"
|
||||
path_cover_l = f"{path_cover}/{CoverSize.BIG.value}.{file_ext}"
|
||||
path_cover_s = f"{path_cover}/{CoverSize.SMALL.value}.{file_ext}"
|
||||
artwork_path = f"{RESOURCES_BASE_PATH}/{entity.fs_resources_path}/cover"
|
||||
Path(artwork_path).mkdir(parents=True, exist_ok=True)
|
||||
await Path(artwork_path).mkdir(parents=True, exist_ok=True)
|
||||
|
||||
return path_cover_l, path_cover_s, artwork_path
|
||||
|
||||
@staticmethod
|
||||
def _store_screenshot(rom: Rom, url: str, idx: int):
|
||||
async def _store_screenshot(rom: Rom, url: str, idx: int):
|
||||
"""Store roms resources in filesystem
|
||||
|
||||
Args:
|
||||
@@ -165,23 +161,23 @@ class FSResourcesHandler(FSHandler):
|
||||
screenshot_file = f"{idx}.jpg"
|
||||
screenshot_path = f"{RESOURCES_BASE_PATH}/{rom.fs_resources_path}/screenshots"
|
||||
|
||||
httpx_client = ctx_httpx_client.get()
|
||||
try:
|
||||
res = requests.get(url, stream=True, timeout=120)
|
||||
except requests.exceptions.ConnectionError as exc:
|
||||
async with httpx_client.stream("GET", url, timeout=120) as response:
|
||||
if response.status_code == 200:
|
||||
await Path(screenshot_path).mkdir(parents=True, exist_ok=True)
|
||||
async with await open_file(
|
||||
f"{screenshot_path}/{screenshot_file}", "wb"
|
||||
) as f:
|
||||
async for chunk in response.aiter_raw():
|
||||
await f.write(chunk)
|
||||
except httpx.NetworkError as exc:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
|
||||
detail=f"Unable to fetch screenshot at {url}: {str(exc)}",
|
||||
) from exc
|
||||
|
||||
if res.status_code == 200:
|
||||
Path(screenshot_path).mkdir(parents=True, exist_ok=True)
|
||||
with open(f"{screenshot_path}/{screenshot_file}", "wb") as f:
|
||||
try:
|
||||
shutil.copyfileobj(res.raw, f)
|
||||
except ProtocolError:
|
||||
log.warning(
|
||||
f"Failure writing screenshot {url} to file (ProtocolError)"
|
||||
)
|
||||
except ProtocolError:
|
||||
log.warning(f"Failure writing screenshot {url} to file (ProtocolError)")
|
||||
|
||||
@staticmethod
|
||||
def _get_screenshot_path(rom: Rom, idx: str):
|
||||
@@ -194,13 +190,15 @@ class FSResourcesHandler(FSHandler):
|
||||
"""
|
||||
return f"{rom.fs_resources_path}/screenshots/{idx}.jpg"
|
||||
|
||||
def get_rom_screenshots(self, rom: Rom | None, url_screenshots: list) -> list[str]:
|
||||
async def get_rom_screenshots(
|
||||
self, rom: Rom | None, url_screenshots: list
|
||||
) -> list[str]:
|
||||
if not rom:
|
||||
return []
|
||||
|
||||
path_screenshots: list[str] = []
|
||||
for idx, url in enumerate(url_screenshots):
|
||||
self._store_screenshot(rom, url, idx)
|
||||
await self._store_screenshot(rom, url, idx)
|
||||
path_screenshots.append(self._get_screenshot_path(rom, str(idx)))
|
||||
|
||||
return path_screenshots
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,14 +1,12 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from handler.filesystem import fs_platform_handler, fs_resource_handler, fs_rom_handler
|
||||
from models.platform import Platform
|
||||
|
||||
|
||||
@pytest.mark.vcr
|
||||
def test_get_rom_cover():
|
||||
path_cover_s, path_cover_l = fs_resource_handler.get_cover(
|
||||
async def test_get_rom_cover():
|
||||
path_cover_s, path_cover_l = await fs_resource_handler.get_cover(
|
||||
overwrite=False, entity=None, url_cover=""
|
||||
)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import re
|
||||
import unicodedata
|
||||
from typing import Final
|
||||
|
||||
from handler.redis_handler import cache
|
||||
from handler.redis_handler import async_cache, sync_cache
|
||||
from logger.logger import log
|
||||
from tasks.update_switch_titledb import (
|
||||
SWITCH_PRODUCT_ID_KEY,
|
||||
@@ -18,9 +18,9 @@ def conditionally_set_cache(
|
||||
index_key: str, filename: str, parent_dir: str = os.path.dirname(__file__)
|
||||
) -> None:
|
||||
fixtures_path = os.path.join(parent_dir, "fixtures")
|
||||
if not cache.exists(index_key):
|
||||
if not sync_cache.exists(index_key):
|
||||
index_data = json.loads(open(os.path.join(fixtures_path, filename)).read())
|
||||
with cache.pipeline() as pipe:
|
||||
with sync_cache.pipeline() as pipe:
|
||||
for data_batch in batched(index_data.items(), 2000):
|
||||
data_map = {k: json.dumps(v) for k, v in dict(data_batch).items()}
|
||||
pipe.hset(index_key, mapping=data_map)
|
||||
@@ -99,7 +99,7 @@ class MetadataHandler:
|
||||
|
||||
async def _ps2_opl_format(self, match: re.Match[str], search_term: str) -> str:
|
||||
serial_code = match.group(1)
|
||||
index_entry = cache.hget(PS2_OPL_KEY, serial_code)
|
||||
index_entry = await async_cache.hget(PS2_OPL_KEY, serial_code)
|
||||
if index_entry:
|
||||
index_entry = json.loads(index_entry)
|
||||
search_term = index_entry["Name"] # type: ignore
|
||||
@@ -107,7 +107,7 @@ class MetadataHandler:
|
||||
return search_term
|
||||
|
||||
async def _sony_serial_format(self, index_key: str, serial_code: str) -> str | None:
|
||||
index_entry = cache.hget(index_key, serial_code)
|
||||
index_entry = await async_cache.hget(index_key, serial_code)
|
||||
if index_entry:
|
||||
index_entry = json.loads(index_entry)
|
||||
return index_entry["title"]
|
||||
@@ -140,15 +140,15 @@ class MetadataHandler:
|
||||
) -> tuple[str, dict | None]:
|
||||
title_id = match.group(1)
|
||||
|
||||
if not cache.exists(SWITCH_TITLEDB_INDEX_KEY):
|
||||
if not (await async_cache.exists(SWITCH_TITLEDB_INDEX_KEY)):
|
||||
log.warning("Fetching the Switch titleID index file...")
|
||||
await update_switch_titledb_task.run(force=True)
|
||||
|
||||
if not cache.exists(SWITCH_TITLEDB_INDEX_KEY):
|
||||
if not (await async_cache.exists(SWITCH_TITLEDB_INDEX_KEY)):
|
||||
log.error("Could not fetch the Switch titleID index file")
|
||||
return search_term, None
|
||||
|
||||
index_entry = cache.hget(SWITCH_TITLEDB_INDEX_KEY, title_id)
|
||||
index_entry = await async_cache.hget(SWITCH_TITLEDB_INDEX_KEY, title_id)
|
||||
if index_entry:
|
||||
index_entry = json.loads(index_entry)
|
||||
return index_entry["name"], index_entry
|
||||
@@ -165,15 +165,15 @@ class MetadataHandler:
|
||||
product_id[-3] = "0"
|
||||
product_id = "".join(product_id)
|
||||
|
||||
if not cache.exists(SWITCH_PRODUCT_ID_KEY):
|
||||
if not (await async_cache.exists(SWITCH_PRODUCT_ID_KEY)):
|
||||
log.warning("Fetching the Switch productID index file...")
|
||||
await update_switch_titledb_task.run(force=True)
|
||||
|
||||
if not cache.exists(SWITCH_PRODUCT_ID_KEY):
|
||||
if not (await async_cache.exists(SWITCH_PRODUCT_ID_KEY)):
|
||||
log.error("Could not fetch the Switch productID index file")
|
||||
return search_term, None
|
||||
|
||||
index_entry = cache.hget(SWITCH_PRODUCT_ID_KEY, product_id)
|
||||
index_entry = await async_cache.hget(SWITCH_PRODUCT_ID_KEY, product_id)
|
||||
if index_entry:
|
||||
index_entry = json.loads(index_entry)
|
||||
return index_entry["name"], index_entry
|
||||
@@ -183,7 +183,7 @@ class MetadataHandler:
|
||||
async def _mame_format(self, search_term: str) -> str:
|
||||
from handler.filesystem import fs_rom_handler
|
||||
|
||||
index_entry = cache.hget(MAME_XML_KEY, search_term)
|
||||
index_entry = await async_cache.hget(MAME_XML_KEY, search_term)
|
||||
if index_entry:
|
||||
index_entry = json.loads(index_entry)
|
||||
search_term = fs_rom_handler.get_file_name_with_no_tags(
|
||||
|
||||
@@ -8,7 +8,7 @@ import pydash
|
||||
import requests
|
||||
from config import IGDB_CLIENT_ID, IGDB_CLIENT_SECRET
|
||||
from fastapi import HTTPException, status
|
||||
from handler.redis_handler import cache
|
||||
from handler.redis_handler import sync_cache
|
||||
from logger.logger import log
|
||||
from requests.exceptions import HTTPError, Timeout
|
||||
from typing_extensions import TypedDict
|
||||
@@ -592,8 +592,8 @@ class TwitchAuth:
|
||||
return ""
|
||||
|
||||
# Set token in redis to expire in <expires_in> seconds
|
||||
cache.set("romm:twitch_token", token, ex=expires_in - 10) # type: ignore[attr-defined]
|
||||
cache.set("romm:twitch_token_expires_at", time.time() + expires_in - 10) # type: ignore[attr-defined]
|
||||
sync_cache.set("romm:twitch_token", token, ex=expires_in - 10) # type: ignore[attr-defined]
|
||||
sync_cache.set("romm:twitch_token_expires_at", time.time() + expires_in - 10) # type: ignore[attr-defined]
|
||||
|
||||
log.info("Twitch token fetched!")
|
||||
|
||||
@@ -608,8 +608,8 @@ class TwitchAuth:
|
||||
return ""
|
||||
|
||||
# Fetch the token cache
|
||||
token = cache.get("romm:twitch_token") # type: ignore[attr-defined]
|
||||
token_expires_at = cache.get("romm:twitch_token_expires_at") # type: ignore[attr-defined]
|
||||
token = sync_cache.get("romm:twitch_token") # type: ignore[attr-defined]
|
||||
token_expires_at = sync_cache.get("romm:twitch_token_expires_at") # type: ignore[attr-defined]
|
||||
|
||||
if not token or time.time() > float(token_expires_at or 0):
|
||||
log.warning("Twitch token invalid: fetching a new one...")
|
||||
@@ -840,7 +840,7 @@ IGDB_PLATFORM_LIST = [
|
||||
{"slug": "sinclair-zx81", "name": "Sinclair ZX81"},
|
||||
{"slug": "pc-8800-series", "name": "PC-8800 Series"},
|
||||
{"slug": "microvision--1", "name": "Microvision"},
|
||||
{"slug": "game-and-watch", "name": "Game & Watch"},
|
||||
{"slug": "g-and-w", "name": "Game & Watch"},
|
||||
{"slug": "atari8bit", "name": "Atari 8-bit"},
|
||||
{"slug": "trs-80-color-computer", "name": "TRS-80 Color Computer"},
|
||||
{
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
import asyncio
|
||||
import http
|
||||
import re
|
||||
import time
|
||||
from typing import Final, NotRequired
|
||||
from urllib.parse import quote
|
||||
|
||||
import httpx
|
||||
import pydash
|
||||
import requests
|
||||
import yarl
|
||||
from config import MOBYGAMES_API_KEY
|
||||
from fastapi import HTTPException, status
|
||||
from logger.logger import log
|
||||
from requests.exceptions import HTTPError, Timeout
|
||||
from typing_extensions import TypedDict
|
||||
from unidecode import unidecode as uc
|
||||
from utils.context import ctx_httpx_client
|
||||
|
||||
from .base_hander import (
|
||||
PS2_OPL_REGEX,
|
||||
@@ -81,38 +82,43 @@ class MobyGamesHandler(MetadataHandler):
|
||||
self.platform_url = "https://api.mobygames.com/v1/platforms"
|
||||
self.games_url = "https://api.mobygames.com/v1/games"
|
||||
|
||||
def _request(self, url: str, timeout: int = 120) -> dict:
|
||||
async def _request(self, url: str, timeout: int = 120) -> dict:
|
||||
httpx_client = ctx_httpx_client.get()
|
||||
authorized_url = yarl.URL(url).update_query(api_key=MOBYGAMES_API_KEY)
|
||||
try:
|
||||
res = requests.get(authorized_url, timeout=timeout)
|
||||
res = await httpx_client.get(str(authorized_url), timeout=timeout)
|
||||
res.raise_for_status()
|
||||
return res.json()
|
||||
except requests.exceptions.ConnectionError as exc:
|
||||
except httpx.NetworkError as exc:
|
||||
log.critical("Connection error: can't connect to Mobygames", exc_info=True)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
|
||||
detail="Can't connect to Mobygames, check your internet connection",
|
||||
) from exc
|
||||
except HTTPError as err:
|
||||
if err.response.status_code == 401:
|
||||
except httpx.HTTPStatusError as err:
|
||||
if err.response.status_code == http.HTTPStatus.UNAUTHORIZED:
|
||||
# Sometimes Mobygames returns 401 even with a valid API key
|
||||
log.error(err)
|
||||
return {}
|
||||
elif err.response.status_code == 429:
|
||||
elif err.response.status_code == http.HTTPStatus.TOO_MANY_REQUESTS:
|
||||
# Retry after 2 seconds if rate limit hit
|
||||
time.sleep(2)
|
||||
await asyncio.sleep(2)
|
||||
else:
|
||||
# Log the error and return an empty dict if the request fails with a different code
|
||||
log.error(err)
|
||||
return {}
|
||||
except Timeout:
|
||||
except httpx.TimeoutException:
|
||||
# Retry the request once if it times out
|
||||
pass
|
||||
|
||||
try:
|
||||
res = requests.get(url, timeout=timeout)
|
||||
res = await httpx_client.get(url, timeout=timeout)
|
||||
res.raise_for_status()
|
||||
except (HTTPError, Timeout) as err:
|
||||
if err.response.status_code == 401:
|
||||
except (httpx.HTTPStatusError, httpx.TimeoutException) as err:
|
||||
if (
|
||||
isinstance(err, httpx.HTTPStatusError)
|
||||
and err.response.status_code == http.HTTPStatus.UNAUTHORIZED
|
||||
):
|
||||
# Sometimes Mobygames returns 401 even with a valid API key
|
||||
return {}
|
||||
|
||||
@@ -122,7 +128,7 @@ class MobyGamesHandler(MetadataHandler):
|
||||
|
||||
return res.json()
|
||||
|
||||
def _search_rom(self, search_term: str, platform_moby_id: int) -> dict | None:
|
||||
async def _search_rom(self, search_term: str, platform_moby_id: int) -> dict | None:
|
||||
if not platform_moby_id:
|
||||
return None
|
||||
|
||||
@@ -131,7 +137,7 @@ class MobyGamesHandler(MetadataHandler):
|
||||
platform=[platform_moby_id],
|
||||
title=quote(search_term, safe="/ "),
|
||||
)
|
||||
roms = self._request(str(url)).get("games", [])
|
||||
roms = (await self._request(str(url))).get("games", [])
|
||||
|
||||
exact_matches = [
|
||||
rom
|
||||
@@ -227,19 +233,19 @@ class MobyGamesHandler(MetadataHandler):
|
||||
fallback_rom = MobyGamesRom(moby_id=None, name=search_term)
|
||||
|
||||
search_term = self.normalize_search_term(search_term)
|
||||
res = self._search_rom(search_term, platform_moby_id)
|
||||
res = await self._search_rom(search_term, platform_moby_id)
|
||||
|
||||
# Split the search term since mobygames search doesn't support special caracters
|
||||
if not res and ":" in search_term:
|
||||
for term in search_term.split(":")[::-1]:
|
||||
res = self._search_rom(term, platform_moby_id)
|
||||
res = await self._search_rom(term, platform_moby_id)
|
||||
if res:
|
||||
break
|
||||
|
||||
# Some MAME games have two titles split by a slash
|
||||
if not res and "/" in search_term:
|
||||
for term in search_term.split("/"):
|
||||
res = self._search_rom(term.strip(), platform_moby_id)
|
||||
res = await self._search_rom(term.strip(), platform_moby_id)
|
||||
if res:
|
||||
break
|
||||
|
||||
@@ -258,12 +264,12 @@ class MobyGamesHandler(MetadataHandler):
|
||||
|
||||
return MobyGamesRom({k: v for k, v in rom.items() if v}) # type: ignore[misc]
|
||||
|
||||
def get_rom_by_id(self, moby_id: int) -> MobyGamesRom:
|
||||
async def get_rom_by_id(self, moby_id: int) -> MobyGamesRom:
|
||||
if not MOBY_API_ENABLED:
|
||||
return MobyGamesRom(moby_id=None)
|
||||
|
||||
url = yarl.URL(self.games_url).with_query(id=moby_id)
|
||||
roms = self._request(str(url)).get("games", [])
|
||||
roms = (await self._request(str(url))).get("games", [])
|
||||
res = pydash.get(roms, "[0]", None)
|
||||
|
||||
if not res:
|
||||
@@ -281,14 +287,14 @@ class MobyGamesHandler(MetadataHandler):
|
||||
|
||||
return MobyGamesRom({k: v for k, v in rom.items() if v}) # type: ignore[misc]
|
||||
|
||||
def get_matched_roms_by_id(self, moby_id: int) -> list[MobyGamesRom]:
|
||||
async def get_matched_roms_by_id(self, moby_id: int) -> list[MobyGamesRom]:
|
||||
if not MOBY_API_ENABLED:
|
||||
return []
|
||||
|
||||
rom = self.get_rom_by_id(moby_id)
|
||||
rom = await self.get_rom_by_id(moby_id)
|
||||
return [rom] if rom["moby_id"] else []
|
||||
|
||||
def get_matched_roms_by_name(
|
||||
async def get_matched_roms_by_name(
|
||||
self, search_term: str, platform_moby_id: int
|
||||
) -> list[MobyGamesRom]:
|
||||
if not MOBY_API_ENABLED:
|
||||
@@ -301,7 +307,7 @@ class MobyGamesHandler(MetadataHandler):
|
||||
url = yarl.URL(self.games_url).with_query(
|
||||
platform=[platform_moby_id], title=quote(search_term, safe="/ ")
|
||||
)
|
||||
matched_roms = self._request(str(url)).get("games", [])
|
||||
matched_roms = (await self._request(str(url))).get("games", [])
|
||||
|
||||
return [
|
||||
MobyGamesRom( # type: ignore[misc]
|
||||
@@ -450,6 +456,7 @@ SLUG_TO_MOBY_ID: dict[str, SlugToMobyId] = {
|
||||
"fire-os": {"id": 159, "name": "Fire OS"},
|
||||
"amazon-fire-tv": {"id": 159, "name": "Fire TV"},
|
||||
"freebox": {"id": 268, "name": "Freebox"},
|
||||
"g-and-w": {"id": 205, "name": "Dedicated handheld"}, # IGDB (Game & Watch)
|
||||
"g-cluster": {"id": 302, "name": "G-cluster"},
|
||||
"gimini": {"id": 251, "name": "GIMINI"},
|
||||
"gnex": {"id": 258, "name": "GNEX"},
|
||||
|
||||
@@ -2,9 +2,9 @@ import asyncio
|
||||
import itertools
|
||||
from typing import Any, Final
|
||||
|
||||
import httpx
|
||||
from config import STEAMGRIDDB_API_KEY
|
||||
from logger.logger import log
|
||||
from utils.context import ctx_httpx_client
|
||||
|
||||
# Used to display the Mobygames API status in the frontend
|
||||
STEAMGRIDDB_API_ENABLED: Final = bool(STEAMGRIDDB_API_KEY)
|
||||
@@ -33,11 +33,10 @@ class SGDBBaseHandler:
|
||||
"Accept": "*/*",
|
||||
}
|
||||
|
||||
async def get_details(
|
||||
self, requests_client: httpx.AsyncClient, search_term: str
|
||||
) -> list[dict[str, Any]]:
|
||||
async def get_details(self, search_term: str) -> list[dict[str, Any]]:
|
||||
httpx_client = ctx_httpx_client.get()
|
||||
search_response = (
|
||||
await requests_client.get(
|
||||
await httpx_client.get(
|
||||
f"{self.search_endpoint}/{search_term}",
|
||||
headers=self.headers,
|
||||
timeout=120,
|
||||
@@ -49,11 +48,7 @@ class SGDBBaseHandler:
|
||||
return []
|
||||
|
||||
tasks = [
|
||||
self._get_game_covers(
|
||||
requests_client=requests_client,
|
||||
game_id=game["id"],
|
||||
game_name=game["name"],
|
||||
)
|
||||
self._get_game_covers(game_id=game["id"], game_name=game["name"])
|
||||
for game in search_response["data"]
|
||||
]
|
||||
results = await asyncio.gather(*tasks)
|
||||
@@ -61,12 +56,13 @@ class SGDBBaseHandler:
|
||||
return list(filter(None, results))
|
||||
|
||||
async def _get_game_covers(
|
||||
self, requests_client: httpx.AsyncClient, game_id: int, game_name: str
|
||||
self, game_id: int, game_name: str
|
||||
) -> dict[str, Any] | None:
|
||||
httpx_client = ctx_httpx_client.get()
|
||||
game_covers = []
|
||||
for page in itertools.count(start=0):
|
||||
covers_response = (
|
||||
await requests_client.get(
|
||||
await httpx_client.get(
|
||||
f"{self.grid_endpoint}/{game_id}",
|
||||
headers=self.headers,
|
||||
timeout=120,
|
||||
|
||||
@@ -3,7 +3,8 @@ from enum import Enum
|
||||
|
||||
from config import REDIS_DB, REDIS_HOST, REDIS_PASSWORD, REDIS_PORT, REDIS_USERNAME
|
||||
from logger.logger import log
|
||||
from redis import Redis, StrictRedis
|
||||
from redis import Redis
|
||||
from redis.asyncio import Redis as AsyncRedis
|
||||
from rq import Queue
|
||||
|
||||
|
||||
@@ -31,12 +32,12 @@ default_queue = Queue(name=QueuePrio.DEFAULT.value, connection=redis_client)
|
||||
low_prio_queue = Queue(name=QueuePrio.LOW.value, connection=redis_client)
|
||||
|
||||
|
||||
def __get_cache() -> StrictRedis:
|
||||
def __get_sync_cache() -> Redis:
|
||||
if "pytest" in sys.modules:
|
||||
# Only import fakeredis when running tests, as it is a test dependency.
|
||||
from fakeredis import FakeStrictRedis
|
||||
from fakeredis import FakeRedis
|
||||
|
||||
return FakeStrictRedis(version=7)
|
||||
return FakeRedis(version=7)
|
||||
|
||||
log.info(f"Connecting to redis in {sys.argv[0]}...")
|
||||
# A separate client that auto-decodes responses is needed
|
||||
@@ -52,4 +53,26 @@ def __get_cache() -> StrictRedis:
|
||||
return client
|
||||
|
||||
|
||||
cache = __get_cache()
|
||||
def __get_async_cache() -> AsyncRedis:
|
||||
if "pytest" in sys.modules:
|
||||
# Only import fakeredis when running tests, as it is a test dependency.
|
||||
from fakeredis import FakeAsyncRedis
|
||||
|
||||
return FakeAsyncRedis(version=7)
|
||||
|
||||
log.info(f"Connecting to redis in {sys.argv[0]}...")
|
||||
# A separate client that auto-decodes responses is needed
|
||||
client = AsyncRedis(
|
||||
host=REDIS_HOST,
|
||||
port=REDIS_PORT,
|
||||
password=REDIS_PASSWORD,
|
||||
username=REDIS_USERNAME,
|
||||
db=REDIS_DB,
|
||||
decode_responses=True,
|
||||
)
|
||||
log.info(f"Redis connection established in {sys.argv[0]}!")
|
||||
return client
|
||||
|
||||
|
||||
sync_cache = __get_sync_cache()
|
||||
async_cache = __get_async_cache()
|
||||
|
||||
@@ -263,7 +263,7 @@ async def scan_rom(
|
||||
)
|
||||
):
|
||||
moby_handler_rom = await meta_moby_handler.get_rom(
|
||||
rom_attrs["file_name"], platform.moby_id
|
||||
rom_attrs["file_name"], platform_moby_id=platform.moby_id
|
||||
)
|
||||
|
||||
# Reversed to prioritize IGDB
|
||||
|
||||
@@ -1,260 +0,0 @@
|
||||
interactions:
|
||||
- request:
|
||||
body:
|
||||
fields id,name,slug,summary,total_rating,aggregated_rating,genres.name,alternative_names.name,artworks.url,cover.url,screenshots.url,franchise.name,franchises.name,collections.name,expansions.name,expansions.slug,expansions.cover.url,expanded_games.name,expanded_games.cover.url,dlcs.name,dlcs.slug,dlcs.cover.url,remakes.name,remakes.cover.url,remasters.name,remasters.cover.url,involved_companies.company.name,platforms.name,first_release_date,game_modes.name,player_perspectives.name,ports.name,similar_games.name,language_supports.language.name,external_games.uid,external_games.category;
|
||||
where id=3340; limit 200;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer test_token
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "618"
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/games
|
||||
response:
|
||||
body:
|
||||
string:
|
||||
"{\n \"message\": \"Authorization Failure. Have you tried:\",\n \"Tip
|
||||
1\": \"Ensure you are sending Authorization and Client-ID as headers.\",\n
|
||||
\ \"Tip 2\": \"Ensure Authorization value starts with 'Bearer ', including
|
||||
the space\",\n \"Tip 3\": \"Ensure Authorization value ends with the App
|
||||
Access Token you generated, NOT your Client Secret.\",\n \"Docs\": \"https://api-docs.igdb.com/#authentication\",\n
|
||||
\ \"Discord\": \"https://discord.gg/FrvfwQg\"\n}\n"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 850a6aa98bd16c85-ZAG
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "437"
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Mon, 05 Feb 2024 10:19:43 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=idsNnYjxs8v_3Xm2bnIfGxJGCZ6Ez23X0PApeu2WoJc-1707128383-1-ARoau+8n2A6HcPBwbeTGM2ZpBgHc+YUTpcdHConVruaz6eigsfYp9g/ql0IwVW6YR9uIxWwiLHBAGJJdvGdtnns=;
|
||||
path=/; expires=Mon, 05-Feb-24 10:49:43 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 4e3b2e1fa2acb7612ea516b89c06af70.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- 4-aVMXkKBO6ANF1XqkKrv3bwoniQz54ulf5eoSHcxSUn0RZ-HmLLPQ==
|
||||
X-Amz-Cf-Pop:
|
||||
- VIE50-C2
|
||||
X-Cache:
|
||||
- Error from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- SqFp5GvgPHcEOGw=
|
||||
x-amzn-ErrorType:
|
||||
- AccessDeniedException
|
||||
x-amzn-RequestId:
|
||||
- 02e5e6b4-3c1d-4afa-8521-99ab5b70b38d
|
||||
status:
|
||||
code: 401
|
||||
message: Unauthorized
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Accept:
|
||||
- "*/*"
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "0"
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://id.twitch.tv/oauth2/token?client_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&client_secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&grant_type=client_credentials
|
||||
response:
|
||||
body:
|
||||
string:
|
||||
'{"access_token":"0ajdkw27v1u71kprgniwm19kqh8stt","expires_in":4993399,"token_type":"bearer"}
|
||||
|
||||
'
|
||||
headers:
|
||||
Access-Control-Allow-Origin:
|
||||
- "*"
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "93"
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Mon, 05 Feb 2024 10:19:44 GMT
|
||||
Server:
|
||||
- nginx
|
||||
X-Ctxlog-Logid:
|
||||
- 1-65c0b640-45264976263a955c66dec3d5
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body:
|
||||
fields id,name,slug,summary,total_rating,aggregated_rating,genres.name,alternative_names.name,artworks.url,cover.url,screenshots.url,franchise.name,franchises.name,collections.name,expansions.name,expansions.slug,expansions.cover.url,expanded_games.name,expanded_games.cover.url,dlcs.name,dlcs.slug,dlcs.cover.url,remakes.name,remakes.cover.url,remasters.name,remasters.cover.url,involved_companies.company.name,platforms.name,first_release_date,game_modes.name,player_perspectives.name,ports.name,similar_games.name,language_supports.language.name,external_games.uid,external_games.category;
|
||||
where id=3340; limit 200;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer 0ajdkw27v1u71kprgniwm19kqh8stt
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "618"
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/games
|
||||
response:
|
||||
body:
|
||||
string:
|
||||
"[\n {\n \"id\": 3340,\n \"aggregated_rating\": 90.0,\n \"alternative_names\":
|
||||
[\n {\n \"id\": 39105,\n \"name\": \"Zhi Pian Mario\"\n
|
||||
\ },\n {\n \"id\": 51791,\n \"name\": \"\u30DE\u30EA\u30AA\u30B9\u30C8\u30FC\u30EA\u30FC\"\n
|
||||
\ },\n {\n \"id\": 51792,\n \"name\": \"\u7EB8\u7247\u9A6C\u91CC\u5965\"\n
|
||||
\ },\n {\n \"id\": 78718,\n \"name\": \"Mario Story\"\n
|
||||
\ },\n {\n \"id\": 88088,\n \"name\": \"Super Mario
|
||||
RPG 2\"\n },\n {\n \"id\": 119107,\n \"name\": \"\u7EB8\u7247\u9A6C\u529B\u6B27\"\n
|
||||
\ },\n {\n \"id\": 137285,\n \"name\": \"\uD398\uC774\uD37C
|
||||
\uB9C8\uB9AC\uC624\"\n }\n ],\n \"artworks\": [\n {\n \"id\":
|
||||
73649,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/ar1ktt.jpg\"\n
|
||||
\ }\n ],\n \"cover\": {\n \"id\": 80830,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/co1qda.jpg\"\n
|
||||
\ },\n \"external_games\": [\n {\n \"id\": 138931,\n \"category\":
|
||||
3,\n \"uid\": \"19929\"\n },\n {\n \"id\": 245769,\n
|
||||
\ \"category\": 14,\n \"uid\": \"18231\"\n },\n {\n
|
||||
\ \"id\": 1931441,\n \"category\": 20,\n \"uid\": \"B01BLAWHKI\"\n
|
||||
\ },\n {\n \"id\": 1931588,\n \"category\": 20,\n \"uid\":
|
||||
\"B003ZDOH3K\"\n },\n {\n \"id\": 1933352,\n \"category\":
|
||||
20,\n \"uid\": \"B009LUDMJQ\"\n }\n ],\n \"first_release_date\":
|
||||
965952000,\n \"franchises\": [\n {\n \"id\": 845,\n \"name\":
|
||||
\"Mario\"\n }\n ],\n \"game_modes\": [\n {\n \"id\":
|
||||
1,\n \"name\": \"Single player\"\n }\n ],\n \"genres\":
|
||||
[\n {\n \"id\": 12,\n \"name\": \"Role-playing (RPG)\"\n
|
||||
\ },\n {\n \"id\": 16,\n \"name\": \"Turn-based strategy
|
||||
(TBS)\"\n },\n {\n \"id\": 31,\n \"name\": \"Adventure\"\n
|
||||
\ }\n ],\n \"involved_companies\": [\n {\n \"id\": 148214,\n
|
||||
\ \"company\": {\n \"id\": 70,\n \"name\": \"Nintendo\"\n
|
||||
\ }\n },\n {\n \"id\": 148215,\n \"company\":
|
||||
{\n \"id\": 765,\n \"name\": \"Intelligent Systems Co.,
|
||||
Ltd.\"\n }\n },\n {\n \"id\": 225578,\n \"company\":
|
||||
{\n \"id\": 5163,\n \"name\": \"iQue\"\n }\n },\n
|
||||
\ {\n \"id\": 225579,\n \"company\": {\n \"id\":
|
||||
812,\n \"name\": \"Gradiente\"\n }\n }\n ],\n \"name\":
|
||||
\"Paper Mario\",\n \"platforms\": [\n {\n \"id\": 4,\n \"name\":
|
||||
\"Nintendo 64\"\n },\n {\n \"id\": 5,\n \"name\":
|
||||
\"Wii\"\n },\n {\n \"id\": 41,\n \"name\": \"Wii U\"\n
|
||||
\ }\n ],\n \"player_perspectives\": [\n {\n \"id\":
|
||||
2,\n \"name\": \"Third person\"\n },\n {\n \"id\":
|
||||
4,\n \"name\": \"Side view\"\n }\n ],\n \"screenshots\":
|
||||
[\n {\n \"id\": 24167,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/a5r3k2lf3lgvifrycqeg.jpg\"\n
|
||||
\ },\n {\n \"id\": 24168,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/hdxgs9nruycvrzcgvseu.jpg\"\n
|
||||
\ },\n {\n \"id\": 24169,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/ig9ainu9fershqdinox1.jpg\"\n
|
||||
\ },\n {\n \"id\": 24170,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/jz66se3deczeta6hd4ys.jpg\"\n
|
||||
\ },\n {\n \"id\": 24171,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/kjnf90jnud6njmwto3th.jpg\"\n
|
||||
\ }\n ],\n \"similar_games\": [\n {\n \"id\": 358,\n
|
||||
\ \"name\": \"Super Mario Bros.\"\n },\n {\n \"id\":
|
||||
660,\n \"name\": \"Darkstone\"\n },\n {\n \"id\":
|
||||
1026,\n \"name\": \"The Legend of Zelda: A Link to the Past\"\n },\n
|
||||
\ {\n \"id\": 1035,\n \"name\": \"The Legend of Zelda: The
|
||||
Minish Cap\"\n },\n {\n \"id\": 1068,\n \"name\":
|
||||
\"Super Mario Bros. 3\"\n },\n {\n \"id\": 1280,\n \"name\":
|
||||
\"Breath of Fire IV\"\n },\n {\n \"id\": 2148,\n \"name\":
|
||||
\"Banjo-Kazooie\"\n },\n {\n \"id\": 3349,\n \"name\":
|
||||
\"Paper Mario: The Thousand-Year Door\"\n },\n {\n \"id\":
|
||||
3351,\n \"name\": \"Mario \\u0026 Luigi: Superstar Saga\"\n },\n
|
||||
\ {\n \"id\": 22387,\n \"name\": \"Legrand Legacy\"\n }\n
|
||||
\ ],\n \"slug\": \"paper-mario\",\n \"summary\": \"Paper Mario, a
|
||||
turn-based JRPG entry in the Mario franchise with a paper-based aesthetic
|
||||
and platforming elements, sees the titular character working his way through
|
||||
the Mushroom Kingdom\\u0027s diverse locales and biomes, meeting its inhabitants,
|
||||
fighthing unruly enemies and recruiting an array of companions in order to
|
||||
once again save Princess Peach from the clutches of the evil Koopa King Bowser.\",\n
|
||||
\ \"total_rating\": 88.63944908765737,\n \"language_supports\": [\n {\n
|
||||
\ \"id\": 473450,\n \"language\": {\n \"id\": 3,\n \"name\":
|
||||
\"Chinese (Traditional)\"\n }\n },\n {\n \"id\": 473451,\n
|
||||
\ \"language\": {\n \"id\": 7,\n \"name\": \"English\"\n
|
||||
\ }\n },\n {\n \"id\": 473452,\n \"language\":
|
||||
{\n \"id\": 16,\n \"name\": \"Japanese\"\n }\n },\n
|
||||
\ {\n \"id\": 492896,\n \"language\": {\n \"id\":
|
||||
12,\n \"name\": \"French\"\n }\n },\n {\n \"id\":
|
||||
492897,\n \"language\": {\n \"id\": 27,\n \"name\":
|
||||
\"German\"\n }\n },\n {\n \"id\": 492898,\n \"language\":
|
||||
{\n \"id\": 9,\n \"name\": \"Spanish (Spain)\"\n }\n
|
||||
\ }\n ],\n \"collections\": [\n {\n \"id\": 240,\n \"name\":
|
||||
\"Super Mario\"\n },\n {\n \"id\": 593,\n \"name\":
|
||||
\"Paper Mario\"\n }\n ]\n }\n]"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 850a6ab38d90247e-ZAG
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Encoding:
|
||||
- gzip
|
||||
Content-Length:
|
||||
- "1538"
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Mon, 05 Feb 2024 10:19:44 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=AWDtDNBesiBNRG_TAxOGiuFwRFLkVaMKKzacjuSfN1A-1707128384-1-AZI98at0D2lKevu+JZmue7g+iAQDTWUztnF+TYef4qpdJwzWz5QM6WAT6R4v8/uSMGLSpUNPeyVatb7wLRpmQzQ=;
|
||||
path=/; expires=Mon, 05-Feb-24 10:49:44 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 4e3b2e1fa2acb7612ea516b89c06af70.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- qO4AjLq5N8IuebEhbM-ll0ZIUdDLcpk5TUQEyihZkZ4KsQysKFyAug==
|
||||
X-Amz-Cf-Pop:
|
||||
- VIE50-C2
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- "1"
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- SqFqJGvLPHcEmEQ=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- "1538"
|
||||
x-amzn-Remapped-Date:
|
||||
- Mon, 05 Feb 2024 10:19:44 GMT
|
||||
x-amzn-RequestId:
|
||||
- e60e2362-b0b4-4e60-8ca2-31f3a4a96fb3
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
||||
File diff suppressed because it is too large
Load Diff
426
backend/handler/tests/cassettes/test_get_platform.yaml
generated
426
backend/handler/tests/cassettes/test_get_platform.yaml
generated
@@ -1,426 +0,0 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: fields id,name; where slug="n64"; limit 200;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer test_token
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "44"
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/platforms
|
||||
response:
|
||||
body:
|
||||
string:
|
||||
"{\n \"message\": \"Authorization Failure. Have you tried:\",\n \"Tip
|
||||
1\": \"Ensure you are sending Authorization and Client-ID as headers.\",\n
|
||||
\ \"Tip 2\": \"Ensure Authorization value starts with 'Bearer ', including
|
||||
the space\",\n \"Tip 3\": \"Ensure Authorization value ends with the App
|
||||
Access Token you generated, NOT your Client Secret.\",\n \"Docs\": \"https://api-docs.igdb.com/#authentication\",\n
|
||||
\ \"Discord\": \"https://discord.gg/FrvfwQg\"\n}\n"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 850a6a084fe22491-ZAG
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "437"
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Mon, 05 Feb 2024 10:19:17 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=wI5qRiMVg9zeRFC16EWmg5QX4LC2PiWBKed5CMdjsrs-1707128357-1-AdqBajl1HykmrPno2Olmo7Zpm1T2Izl1AN267NfkMklNUNsMll5MKFYK9+X0hB6xMDwYFuaYqPMsN1TIEfK0bLA=;
|
||||
path=/; expires=Mon, 05-Feb-24 10:49:17 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 4ca98b546b8d71c72caf6a3d8f75dc24.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- QvQSlzbZxMCrYfGYRZS0RrTn75PhhgRT3v52Ht0I77p2OfVZIe_kEQ==
|
||||
X-Amz-Cf-Pop:
|
||||
- VIE50-C2
|
||||
X-Cache:
|
||||
- Error from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- SqFl3EmCvHcEiEw=
|
||||
x-amzn-ErrorType:
|
||||
- AccessDeniedException
|
||||
x-amzn-RequestId:
|
||||
- 33d240f8-5a87-42ee-bb46-fa1364caa51e
|
||||
status:
|
||||
code: 401
|
||||
message: Unauthorized
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Accept:
|
||||
- "*/*"
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "0"
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://id.twitch.tv/oauth2/token?client_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&client_secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&grant_type=client_credentials
|
||||
response:
|
||||
body:
|
||||
string:
|
||||
'{"access_token":"g7ae578ve5tifqtdn3bezx80bstfue","expires_in":5314976,"token_type":"bearer"}
|
||||
|
||||
'
|
||||
headers:
|
||||
Access-Control-Allow-Origin:
|
||||
- "*"
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "93"
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Mon, 05 Feb 2024 10:19:18 GMT
|
||||
Server:
|
||||
- nginx
|
||||
X-Ctxlog-Logid:
|
||||
- 1-65c0b626-79607bfc1350e4771b26d79a
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: fields id,name; where slug="n64"; limit 200;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer g7ae578ve5tifqtdn3bezx80bstfue
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "44"
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/platforms
|
||||
response:
|
||||
body:
|
||||
string: "[\n {\n \"id\": 4,\n \"name\": \"Nintendo 64\"\n }\n]"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 850a6a127e4a2480-ZAG
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Encoding:
|
||||
- gzip
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Mon, 05 Feb 2024 10:19:19 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=BhoByQbyH5w5XxZfGFgNDyCdYOO4_tsv4VbwckN.V.k-1707128359-1-AfyHumutGxUowqCOTMklr91ddX5Q0JcCx3fEVGCMDj/EgPxnZ1+MTSPUUqHNzKEXgv7ofFoFgRd4Sm2PbA7yf9A=;
|
||||
path=/; expires=Mon, 05-Feb-24 10:49:19 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
Via:
|
||||
- 1.1 4ca98b546b8d71c72caf6a3d8f75dc24.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- Q-_mlygniUPJuoMIWeVazYnAUKO-JwlI6ICG8BHyyU7LqUtioQBnqA==
|
||||
X-Amz-Cf-Pop:
|
||||
- VIE50-C2
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- "1"
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- SqFmLEj9vHcEY_Q=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- "50"
|
||||
x-amzn-Remapped-Date:
|
||||
- Mon, 05 Feb 2024 10:19:19 GMT
|
||||
x-amzn-RequestId:
|
||||
- fff69edb-7d6d-4333-9b3f-866113a347b7
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: fields id,name; where slug="not-real"; limit 200;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer test_token
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "49"
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/platforms
|
||||
response:
|
||||
body:
|
||||
string:
|
||||
"{\n \"message\": \"Authorization Failure. Have you tried:\",\n \"Tip
|
||||
1\": \"Ensure you are sending Authorization and Client-ID as headers.\",\n
|
||||
\ \"Tip 2\": \"Ensure Authorization value starts with 'Bearer ', including
|
||||
the space\",\n \"Tip 3\": \"Ensure Authorization value ends with the App
|
||||
Access Token you generated, NOT your Client Secret.\",\n \"Docs\": \"https://api-docs.igdb.com/#authentication\",\n
|
||||
\ \"Discord\": \"https://discord.gg/FrvfwQg\"\n}\n"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 850a6a17aaf22480-ZAG
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "437"
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Mon, 05 Feb 2024 10:19:19 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=VCUWPaFo1l0.hhcoY8TNbX.7v.sHgv3o5msGbW4IwY4-1707128359-1-AV/UMB6hyybtdlkNtDX05HkPHB47tI6KsqFMb3tqKal7TTIv6Xz/vDTpEhLXDk7N4+UU5aMO6QKlmosR6ZUvL7c=;
|
||||
path=/; expires=Mon, 05-Feb-24 10:49:19 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 c8710a117c1dfdaea4e9dfc4d41970d2.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- vbQSmJ-mKi0-ExOR5HRDVL-iUet_f91se4KurIK-GWFAtJPMaw9Vgg==
|
||||
X-Amz-Cf-Pop:
|
||||
- VIE50-C2
|
||||
X-Cache:
|
||||
- Error from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- SqFmQEslvHcEnmg=
|
||||
x-amzn-ErrorType:
|
||||
- AccessDeniedException
|
||||
x-amzn-RequestId:
|
||||
- c4f1e9b7-87a1-48a8-9ff3-c829e6a79f5e
|
||||
status:
|
||||
code: 401
|
||||
message: Unauthorized
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Accept:
|
||||
- "*/*"
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "0"
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://id.twitch.tv/oauth2/token?client_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&client_secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&grant_type=client_credentials
|
||||
response:
|
||||
body:
|
||||
string:
|
||||
'{"access_token":"ce0q1kmen9ztee5526s91upn2pgrjt","expires_in":5469004,"token_type":"bearer"}
|
||||
|
||||
'
|
||||
headers:
|
||||
Access-Control-Allow-Origin:
|
||||
- "*"
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "93"
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Mon, 05 Feb 2024 10:19:21 GMT
|
||||
Server:
|
||||
- nginx
|
||||
X-Ctxlog-Logid:
|
||||
- 1-65c0b628-6500ce7102a2dac52cf782d3
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: fields id,name; where slug="not-real"; limit 200;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer ce0q1kmen9ztee5526s91upn2pgrjt
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "49"
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/platforms
|
||||
response:
|
||||
body:
|
||||
string: "[]"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 850a6a218ce1248e-ZAG
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "2"
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Mon, 05 Feb 2024 10:19:21 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=b2uiyDgwdN2kh1po30EhKiAv01njluEztOl8HzJbnD0-1707128361-1-ASLaLYhc5sa6VxDrZrhxgDGbLyZSyc8cNz0JRYqQ25IYOH50R7Dn5Q/Q0hc6AnIZ+MMW49mpgnyOyWDJ9WV2eyk=;
|
||||
path=/; expires=Mon, 05-Feb-24 10:49:21 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 4ca98b546b8d71c72caf6a3d8f75dc24.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- FT_JcJCfNPxDIlcySLiCDv_yJNkstWHK9QQ_xsKwOjEFQKMPEhzFUQ==
|
||||
X-Amz-Cf-Pop:
|
||||
- VIE50-C2
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- "0"
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- SqFmjGMnvHcEB1w=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- "2"
|
||||
x-amzn-Remapped-Date:
|
||||
- Mon, 05 Feb 2024 10:19:21 GMT
|
||||
x-amzn-RequestId:
|
||||
- 90fcc208-1691-49ea-97bf-ccab670458d1
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: fields id,name; where slug="not-real"; limit 200;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer ce0q1kmen9ztee5526s91upn2pgrjt
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "49"
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/platform_versions
|
||||
response:
|
||||
body:
|
||||
string: "[]"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 850a6a269fbc5ac5-VIE
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "2"
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Mon, 05 Feb 2024 10:19:22 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=W72fEd3tkalmetq_mNQ7n_UmFAMwTugWoyt6q.tSK0I-1707128362-1-AZq/POkqXl2I0+NMDFqTHngxKUwQ5ehSRihAQE9jYEPPQKQV7W0tP+QteV9RNNRE6AkaIUkjsZWu3VWJXeSFyUw=;
|
||||
path=/; expires=Mon, 05-Feb-24 10:49:22 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 a4035907ac3c3ba8d1fd116b6b6b9a4c.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- C9AU5yakduVKlqWfBlMyFazD5JPOlFjlfdMHvqrnqVriqauKZPezMg==
|
||||
X-Amz-Cf-Pop:
|
||||
- VIE50-C2
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- "0"
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- SqFmoEvUvHcEHqg=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- "2"
|
||||
x-amzn-Remapped-Date:
|
||||
- Mon, 05 Feb 2024 10:19:22 GMT
|
||||
x-amzn-RequestId:
|
||||
- 9b7de1ff-7b8a-4cb4-82be-b90a45f9ab44
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
||||
@@ -1,380 +0,0 @@
|
||||
interactions:
|
||||
- request:
|
||||
body:
|
||||
search "WWE Smack"; fields id,name,slug,summary,total_rating,aggregated_rating,genres.name,alternative_names.name,artworks.url,cover.url,screenshots.url,franchise.name,franchises.name,collections.name,expansions.name,expansions.slug,expansions.cover.url,expanded_games.name,expanded_games.cover.url,dlcs.name,dlcs.slug,dlcs.cover.url,remakes.name,remakes.cover.url,remasters.name,remasters.cover.url,involved_companies.company.name,platforms.name,first_release_date,game_modes.name,player_perspectives.name,ports.name,similar_games.name,language_supports.language.name,external_games.uid,external_games.category;
|
||||
where platforms=[8] ; limit 200;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer test_token
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "645"
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/games
|
||||
response:
|
||||
body:
|
||||
string:
|
||||
"{\n \"message\": \"Authorization Failure. Have you tried:\",\n \"Tip
|
||||
1\": \"Ensure you are sending Authorization and Client-ID as headers.\",\n
|
||||
\ \"Tip 2\": \"Ensure Authorization value starts with 'Bearer ', including
|
||||
the space\",\n \"Tip 3\": \"Ensure Authorization value ends with the App
|
||||
Access Token you generated, NOT your Client Secret.\",\n \"Docs\": \"https://api-docs.igdb.com/#authentication\",\n
|
||||
\ \"Discord\": \"https://discord.gg/FrvfwQg\"\n}\n"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 850a6a6cc862248a-ZAG
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "437"
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Mon, 05 Feb 2024 10:19:33 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=q9RZ2oX2yUNILpRZVW5OoxHlMGDvBPehxTGDol4K2oI-1707128373-1-AV4dvQqWExP3Dtve1W7vyWoYIbFdjDLAuobb7kXhAgK9VeOuXyVdYFt4J8CHGqbLYqRqXo2qRom19qjprAWkxH4=;
|
||||
path=/; expires=Mon, 05-Feb-24 10:49:33 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 c8710a117c1dfdaea4e9dfc4d41970d2.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- V2CITeT8MTu0_1ivYUqp2mwvEhRlhwvKoYXDsDCNwCQ7nS_Jp8vl9w==
|
||||
X-Amz-Cf-Pop:
|
||||
- VIE50-C2
|
||||
X-Cache:
|
||||
- Error from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- SqFobF8DPHcEaEA=
|
||||
x-amzn-ErrorType:
|
||||
- AccessDeniedException
|
||||
x-amzn-RequestId:
|
||||
- 303a827f-7960-4f11-9625-6da894bd89f0
|
||||
status:
|
||||
code: 401
|
||||
message: Unauthorized
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Accept:
|
||||
- "*/*"
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "0"
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://id.twitch.tv/oauth2/token?client_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&client_secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&grant_type=client_credentials
|
||||
response:
|
||||
body:
|
||||
string:
|
||||
'{"access_token":"ceowppsaubbqnesvgmn8bxq2bz1e93","expires_in":5232645,"token_type":"bearer"}
|
||||
|
||||
'
|
||||
headers:
|
||||
Access-Control-Allow-Origin:
|
||||
- "*"
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "93"
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Mon, 05 Feb 2024 10:19:34 GMT
|
||||
Server:
|
||||
- nginx
|
||||
X-Ctxlog-Logid:
|
||||
- 1-65c0b636-7add0780529675930d3892c4
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body:
|
||||
search "WWE Smack"; fields id,name,slug,summary,total_rating,aggregated_rating,genres.name,alternative_names.name,artworks.url,cover.url,screenshots.url,franchise.name,franchises.name,collections.name,expansions.name,expansions.slug,expansions.cover.url,expanded_games.name,expanded_games.cover.url,dlcs.name,dlcs.slug,dlcs.cover.url,remakes.name,remakes.cover.url,remasters.name,remasters.cover.url,involved_companies.company.name,platforms.name,first_release_date,game_modes.name,player_perspectives.name,ports.name,similar_games.name,language_supports.language.name,external_games.uid,external_games.category;
|
||||
where platforms=[8] ; limit 200;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer ceowppsaubbqnesvgmn8bxq2bz1e93
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "645"
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/games
|
||||
response:
|
||||
body:
|
||||
string: "[]"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 850a6a78ea775a8f-VIE
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "2"
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Mon, 05 Feb 2024 10:19:35 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=nPdFOwqHSK8.4iUCLhlaW0RLKE7sXiBFWo5bapNv8ls-1707128375-1-AcopgG+rfx+1lCOkCsQcixVy6AX38T9d2mao1At8n1nrFCEuHamBbEaQf6lAvFoih7fZq0e6PlmEhTImjuBUUtQ=;
|
||||
path=/; expires=Mon, 05-Feb-24 10:49:35 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 881b12332738e10f6e80298fbdcd7e8e.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- hm6HNEMABW_ZnDuFNHPpzFNwTht8Xx3NuBKJpXRQp7TkBKOlSRoQgw==
|
||||
X-Amz-Cf-Pop:
|
||||
- VIE50-C2
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- "0"
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- SqForGNWPHcEl2w=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- "2"
|
||||
x-amzn-Remapped-Date:
|
||||
- Mon, 05 Feb 2024 10:19:35 GMT
|
||||
x-amzn-RequestId:
|
||||
- 6ea19906-7c95-44bd-a145-9455a3105a3e
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body:
|
||||
fields game.id,name; where game.platforms=[8] & (name ~ *"WWE Smack"* |
|
||||
alternative_name ~ *"WWE Smack"*); limit 200;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer ceowppsaubbqnesvgmn8bxq2bz1e93
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "117"
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/search
|
||||
response:
|
||||
body:
|
||||
string:
|
||||
"[\n {\n \"id\": 22703,\n \"game\": {\n \"id\": 6461\n },\n
|
||||
\ \"name\": \"WWE SmackDown! Shut Your Mouth\"\n },\n {\n \"id\": 23270,\n
|
||||
\ \"game\": {\n \"id\": 5298\n },\n \"name\": \"WWE SmackDown
|
||||
vs Raw 2008\"\n },\n {\n \"id\": 38521,\n \"game\": {\n \"id\":
|
||||
80852\n },\n \"name\": \"WWE Smackdown! vs Raw\"\n },\n {\n \"id\":
|
||||
42494,\n \"game\": {\n \"id\": 7252\n },\n \"name\": \"WWE SmackDown
|
||||
vs Raw 2007\"\n },\n {\n \"id\": 64889,\n \"game\": {\n \"id\":
|
||||
5300\n },\n \"name\": \"WWE SmackDown vs Raw 2010\"\n },\n {\n \"id\":
|
||||
96855,\n \"game\": {\n \"id\": 2265\n },\n \"name\": \"WWE SmackDown
|
||||
vs Raw 2011\"\n },\n {\n \"id\": 111128,\n \"game\": {\n \"id\":
|
||||
5299\n },\n \"name\": \"WWE SmackDown vs Raw 2009\"\n },\n {\n \"id\":
|
||||
114042,\n \"game\": {\n \"id\": 6442\n },\n \"name\": \"WWE
|
||||
Smackdown! Here Comes the Pain\"\n },\n {\n \"id\": 164052,\n \"game\":
|
||||
{\n \"id\": 18323\n },\n \"name\": \"WWE SmackDown! vs Raw 2006\"\n
|
||||
\ }\n]"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 850a6a7c1f99248e-ZAG
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Encoding:
|
||||
- gzip
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Mon, 05 Feb 2024 10:19:37 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=rTR9ZrqC1sN4ia5ons.JkcDv_yZgj1BMvUvphQmttjw-1707128377-1-Af9WUirirOQ6ptU0pFtmVvu8UFcO/fjQll/RS0CrwC84+lRPproAa+Mmg4QlLbWku+XN+A85uIZrbjJ74coMUco=;
|
||||
path=/; expires=Mon, 05-Feb-24 10:49:37 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
Via:
|
||||
- 1.1 4ca98b546b8d71c72caf6a3d8f75dc24.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- 1mEYrUKTKSm9ho3tcCziBkYL-GIJEuA5d-ope26ulmeddsENjM2nOw==
|
||||
X-Amz-Cf-Pop:
|
||||
- VIE50-C2
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- "9"
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- SqFo0FsaPHcEidA=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- "954"
|
||||
x-amzn-Remapped-Date:
|
||||
- Mon, 05 Feb 2024 10:19:36 GMT
|
||||
x-amzn-RequestId:
|
||||
- 749da0d8-ec39-47c1-bc8d-05ae7fc0d335
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body:
|
||||
fields id,name,slug,summary,total_rating,aggregated_rating,genres.name,alternative_names.name,artworks.url,cover.url,screenshots.url,franchise.name,franchises.name,collections.name,expansions.name,expansions.slug,expansions.cover.url,expanded_games.name,expanded_games.cover.url,dlcs.name,dlcs.slug,dlcs.cover.url,remakes.name,remakes.cover.url,remasters.name,remasters.cover.url,involved_companies.company.name,platforms.name,first_release_date,game_modes.name,player_perspectives.name,ports.name,similar_games.name,language_supports.language.name,external_games.uid,external_games.category;
|
||||
where id=6461; limit 200;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer ceowppsaubbqnesvgmn8bxq2bz1e93
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "618"
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/games
|
||||
response:
|
||||
body:
|
||||
string:
|
||||
"[\n {\n \"id\": 6461,\n \"aggregated_rating\": 80.0,\n \"alternative_names\":
|
||||
[\n {\n \"id\": 84798,\n \"name\": \"Exciting Pro Wrestling
|
||||
4\"\n }\n ],\n \"cover\": {\n \"id\": 212962,\n \"url\":
|
||||
\"//images.igdb.com/igdb/image/upload/t_thumb/co4kbm.jpg\"\n },\n \"external_games\":
|
||||
[\n {\n \"id\": 150149,\n \"category\": 3,\n \"uid\":
|
||||
\"7552\"\n },\n {\n \"id\": 1189446,\n \"category\":
|
||||
14,\n \"uid\": \"6910\"\n }\n ],\n \"first_release_date\":
|
||||
1036022400,\n \"franchise\": {\n \"id\": 255,\n \"name\": \"WWE\"\n
|
||||
\ },\n \"franchises\": [\n {\n \"id\": 255,\n \"name\":
|
||||
\"WWE\"\n }\n ],\n \"game_modes\": [\n {\n \"id\":
|
||||
1,\n \"name\": \"Single player\"\n },\n {\n \"id\":
|
||||
4,\n \"name\": \"Split screen\"\n }\n ],\n \"genres\": [\n
|
||||
\ {\n \"id\": 14,\n \"name\": \"Sport\"\n }\n ],\n
|
||||
\ \"involved_companies\": [\n {\n \"id\": 15372,\n \"company\":
|
||||
{\n \"id\": 197,\n \"name\": \"THQ\"\n }\n },\n
|
||||
\ {\n \"id\": 220218,\n \"company\": {\n \"id\":
|
||||
14321,\n \"name\": \"Yuke\\u0027s\"\n }\n }\n ],\n
|
||||
\ \"name\": \"WWE SmackDown! Shut Your Mouth\",\n \"platforms\": [\n
|
||||
\ {\n \"id\": 8,\n \"name\": \"PlayStation 2\"\n }\n
|
||||
\ ],\n \"screenshots\": [\n {\n \"id\": 681390,\n \"url\":
|
||||
\"//images.igdb.com/igdb/image/upload/t_thumb/scelri.jpg\"\n }\n ],\n
|
||||
\ \"similar_games\": [\n {\n \"id\": 2265,\n \"name\":
|
||||
\"WWE SmackDown vs. Raw 2011\"\n },\n {\n \"id\": 4573,\n
|
||||
\ \"name\": \"WWE WrestleMania X8\"\n },\n {\n \"id\":
|
||||
6442,\n \"name\": \"WWE Smackdown! Here Comes the Pain\"\n },\n
|
||||
\ {\n \"id\": 6444,\n \"name\": \"WWF SmackDown! 2: Know
|
||||
Your Role\"\n },\n {\n \"id\": 6445,\n \"name\": \"WWF
|
||||
SmackDown! Just Bring It\"\n },\n {\n \"id\": 18323,\n \"name\":
|
||||
\"WWE SmackDown! vs. Raw 2006\"\n },\n {\n \"id\": 48707,\n
|
||||
\ \"name\": \"WWF King of the Ring\"\n },\n {\n \"id\":
|
||||
102805,\n \"name\": \"WWE 2K19\"\n },\n {\n \"id\":
|
||||
114286,\n \"name\": \"Madden NFL 20\"\n },\n {\n \"id\":
|
||||
114287,\n \"name\": \"FIFA 20\"\n }\n ],\n \"slug\": \"wwe-smackdown-shut-your-mouth\",\n
|
||||
\ \"summary\": \"A WHOLE NEW SEASON OF SMACKDOWN!\\n\\n-BUILD YOUR OWN DRAMA
|
||||
WITH REAL WWF STORYLINES\\n-ALL-NEW DRAFT\\n-INTERACTIVE BACKSTAGE AREAS\\n-WHATCHA
|
||||
GONNA DO?!\",\n \"total_rating\": 79.14862332115482,\n \"collections\":
|
||||
[\n {\n \"id\": 5106,\n \"name\": \"WWE Smackdown!\"\n
|
||||
\ }\n ]\n }\n]"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 850a6a852af9247e-ZAG
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Encoding:
|
||||
- gzip
|
||||
Content-Length:
|
||||
- "877"
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Mon, 05 Feb 2024 10:19:37 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=BFQUPeuv6U_7GnopEtVoMTmmI3k9k3d4PGkruQewvoo-1707128377-1-ASM3OUndgKuFrKoGAd8UgUO4WZEDJf+xEZBsB8kb6oZvQg10rdyGchjFezM7aTl+XQFpDwxmHYK8REi35yiyY8A=;
|
||||
path=/; expires=Mon, 05-Feb-24 10:49:37 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 4ca98b546b8d71c72caf6a3d8f75dc24.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- 9xlBT46Pb1uXdOwZqdWu36iBZbvw-pZxL2qJIdq30gjn9LecOX0TNg==
|
||||
X-Amz-Cf-Pop:
|
||||
- VIE50-C2
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- "1"
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- SqFo_FddPHcEROQ=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- "877"
|
||||
x-amzn-Remapped-Date:
|
||||
- Mon, 05 Feb 2024 10:19:37 GMT
|
||||
x-amzn-RequestId:
|
||||
- 0fcc21b2-2356-4610-a746-626f094edd81
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
||||
1127
backend/handler/tests/cassettes/test_get_rom.yaml
generated
1127
backend/handler/tests/cassettes/test_get_rom.yaml
generated
File diff suppressed because it is too large
Load Diff
441
backend/handler/tests/cassettes/test_get_rom_by_id.yaml
generated
441
backend/handler/tests/cassettes/test_get_rom_by_id.yaml
generated
@@ -1,441 +0,0 @@
|
||||
interactions:
|
||||
- request:
|
||||
body:
|
||||
fields id,name,slug,summary,total_rating,aggregated_rating,genres.name,alternative_names.name,artworks.url,cover.url,screenshots.url,franchise.name,franchises.name,collections.name,expansions.name,expansions.slug,expansions.cover.url,expanded_games.name,expanded_games.cover.url,dlcs.name,dlcs.slug,dlcs.cover.url,remakes.name,remakes.cover.url,remasters.name,remasters.cover.url,involved_companies.company.name,platforms.name,first_release_date,game_modes.name,player_perspectives.name,ports.name,similar_games.name,language_supports.language.name,external_games.uid,external_games.category;
|
||||
where id=3340; limit 200;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer test_token
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "618"
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/games
|
||||
response:
|
||||
body:
|
||||
string:
|
||||
"{\n \"message\": \"Authorization Failure. Have you tried:\",\n \"Tip
|
||||
1\": \"Ensure you are sending Authorization and Client-ID as headers.\",\n
|
||||
\ \"Tip 2\": \"Ensure Authorization value starts with 'Bearer ', including
|
||||
the space\",\n \"Tip 3\": \"Ensure Authorization value ends with the App
|
||||
Access Token you generated, NOT your Client Secret.\",\n \"Docs\": \"https://api-docs.igdb.com/#authentication\",\n
|
||||
\ \"Discord\": \"https://discord.gg/FrvfwQg\"\n}\n"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 850a6a88e92b5a89-VIE
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "437"
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Mon, 05 Feb 2024 10:19:38 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=d2HnDrDz7Uw4tR25QPxztbOdLCIck.fkqPtBk8KzHK4-1707128378-1-ARYqDUoIcdtRbsXjAnQHy3VXU02r9bI7TWOKAjnDZmnFyzimVkd0O0dw1a0xGYCuWo/bzdX/1agFoJeZ/FfWoTk=;
|
||||
path=/; expires=Mon, 05-Feb-24 10:49:38 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 42c9dddb4e518a9ed3248bf50565b120.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- y4GV_3LdprxmhVe-w-sHUQY3rYMF4FGq_sV9TRcftojvt17ejFEOLw==
|
||||
X-Amz-Cf-Pop:
|
||||
- VIE50-C2
|
||||
X-Cache:
|
||||
- Error from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- SqFpIEW-PHcEn0w=
|
||||
x-amzn-ErrorType:
|
||||
- AccessDeniedException
|
||||
x-amzn-RequestId:
|
||||
- c463d4bc-d93d-42a1-bf40-6cd79c4f8541
|
||||
status:
|
||||
code: 401
|
||||
message: Unauthorized
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Accept:
|
||||
- "*/*"
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "0"
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://id.twitch.tv/oauth2/token?client_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&client_secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&grant_type=client_credentials
|
||||
response:
|
||||
body:
|
||||
string:
|
||||
'{"access_token":"ceo0skenysx8qxr7433zhovoa20ak2","expires_in":5229503,"token_type":"bearer"}
|
||||
|
||||
'
|
||||
headers:
|
||||
Access-Control-Allow-Origin:
|
||||
- "*"
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "93"
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Mon, 05 Feb 2024 10:19:39 GMT
|
||||
Server:
|
||||
- nginx
|
||||
X-Ctxlog-Logid:
|
||||
- 1-65c0b63b-48f1d33821b48a24223cf595
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body:
|
||||
fields id,name,slug,summary,total_rating,aggregated_rating,genres.name,alternative_names.name,artworks.url,cover.url,screenshots.url,franchise.name,franchises.name,collections.name,expansions.name,expansions.slug,expansions.cover.url,expanded_games.name,expanded_games.cover.url,dlcs.name,dlcs.slug,dlcs.cover.url,remakes.name,remakes.cover.url,remasters.name,remasters.cover.url,involved_companies.company.name,platforms.name,first_release_date,game_modes.name,player_perspectives.name,ports.name,similar_games.name,language_supports.language.name,external_games.uid,external_games.category;
|
||||
where id=3340; limit 200;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer ceo0skenysx8qxr7433zhovoa20ak2
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "618"
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/games
|
||||
response:
|
||||
body:
|
||||
string:
|
||||
"[\n {\n \"id\": 3340,\n \"aggregated_rating\": 90.0,\n \"alternative_names\":
|
||||
[\n {\n \"id\": 39105,\n \"name\": \"Zhi Pian Mario\"\n
|
||||
\ },\n {\n \"id\": 51791,\n \"name\": \"\u30DE\u30EA\u30AA\u30B9\u30C8\u30FC\u30EA\u30FC\"\n
|
||||
\ },\n {\n \"id\": 51792,\n \"name\": \"\u7EB8\u7247\u9A6C\u91CC\u5965\"\n
|
||||
\ },\n {\n \"id\": 78718,\n \"name\": \"Mario Story\"\n
|
||||
\ },\n {\n \"id\": 88088,\n \"name\": \"Super Mario
|
||||
RPG 2\"\n },\n {\n \"id\": 119107,\n \"name\": \"\u7EB8\u7247\u9A6C\u529B\u6B27\"\n
|
||||
\ },\n {\n \"id\": 137285,\n \"name\": \"\uD398\uC774\uD37C
|
||||
\uB9C8\uB9AC\uC624\"\n }\n ],\n \"artworks\": [\n {\n \"id\":
|
||||
73649,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/ar1ktt.jpg\"\n
|
||||
\ }\n ],\n \"cover\": {\n \"id\": 80830,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/co1qda.jpg\"\n
|
||||
\ },\n \"external_games\": [\n {\n \"id\": 138931,\n \"category\":
|
||||
3,\n \"uid\": \"19929\"\n },\n {\n \"id\": 245769,\n
|
||||
\ \"category\": 14,\n \"uid\": \"18231\"\n },\n {\n
|
||||
\ \"id\": 1931441,\n \"category\": 20,\n \"uid\": \"B01BLAWHKI\"\n
|
||||
\ },\n {\n \"id\": 1931588,\n \"category\": 20,\n \"uid\":
|
||||
\"B003ZDOH3K\"\n },\n {\n \"id\": 1933352,\n \"category\":
|
||||
20,\n \"uid\": \"B009LUDMJQ\"\n }\n ],\n \"first_release_date\":
|
||||
965952000,\n \"franchises\": [\n {\n \"id\": 845,\n \"name\":
|
||||
\"Mario\"\n }\n ],\n \"game_modes\": [\n {\n \"id\":
|
||||
1,\n \"name\": \"Single player\"\n }\n ],\n \"genres\":
|
||||
[\n {\n \"id\": 12,\n \"name\": \"Role-playing (RPG)\"\n
|
||||
\ },\n {\n \"id\": 16,\n \"name\": \"Turn-based strategy
|
||||
(TBS)\"\n },\n {\n \"id\": 31,\n \"name\": \"Adventure\"\n
|
||||
\ }\n ],\n \"involved_companies\": [\n {\n \"id\": 148214,\n
|
||||
\ \"company\": {\n \"id\": 70,\n \"name\": \"Nintendo\"\n
|
||||
\ }\n },\n {\n \"id\": 148215,\n \"company\":
|
||||
{\n \"id\": 765,\n \"name\": \"Intelligent Systems Co.,
|
||||
Ltd.\"\n }\n },\n {\n \"id\": 225578,\n \"company\":
|
||||
{\n \"id\": 5163,\n \"name\": \"iQue\"\n }\n },\n
|
||||
\ {\n \"id\": 225579,\n \"company\": {\n \"id\":
|
||||
812,\n \"name\": \"Gradiente\"\n }\n }\n ],\n \"name\":
|
||||
\"Paper Mario\",\n \"platforms\": [\n {\n \"id\": 4,\n \"name\":
|
||||
\"Nintendo 64\"\n },\n {\n \"id\": 5,\n \"name\":
|
||||
\"Wii\"\n },\n {\n \"id\": 41,\n \"name\": \"Wii U\"\n
|
||||
\ }\n ],\n \"player_perspectives\": [\n {\n \"id\":
|
||||
2,\n \"name\": \"Third person\"\n },\n {\n \"id\":
|
||||
4,\n \"name\": \"Side view\"\n }\n ],\n \"screenshots\":
|
||||
[\n {\n \"id\": 24167,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/a5r3k2lf3lgvifrycqeg.jpg\"\n
|
||||
\ },\n {\n \"id\": 24168,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/hdxgs9nruycvrzcgvseu.jpg\"\n
|
||||
\ },\n {\n \"id\": 24169,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/ig9ainu9fershqdinox1.jpg\"\n
|
||||
\ },\n {\n \"id\": 24170,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/jz66se3deczeta6hd4ys.jpg\"\n
|
||||
\ },\n {\n \"id\": 24171,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/kjnf90jnud6njmwto3th.jpg\"\n
|
||||
\ }\n ],\n \"similar_games\": [\n {\n \"id\": 358,\n
|
||||
\ \"name\": \"Super Mario Bros.\"\n },\n {\n \"id\":
|
||||
660,\n \"name\": \"Darkstone\"\n },\n {\n \"id\":
|
||||
1026,\n \"name\": \"The Legend of Zelda: A Link to the Past\"\n },\n
|
||||
\ {\n \"id\": 1035,\n \"name\": \"The Legend of Zelda: The
|
||||
Minish Cap\"\n },\n {\n \"id\": 1068,\n \"name\":
|
||||
\"Super Mario Bros. 3\"\n },\n {\n \"id\": 1280,\n \"name\":
|
||||
\"Breath of Fire IV\"\n },\n {\n \"id\": 2148,\n \"name\":
|
||||
\"Banjo-Kazooie\"\n },\n {\n \"id\": 3349,\n \"name\":
|
||||
\"Paper Mario: The Thousand-Year Door\"\n },\n {\n \"id\":
|
||||
3351,\n \"name\": \"Mario \\u0026 Luigi: Superstar Saga\"\n },\n
|
||||
\ {\n \"id\": 22387,\n \"name\": \"Legrand Legacy\"\n }\n
|
||||
\ ],\n \"slug\": \"paper-mario\",\n \"summary\": \"Paper Mario, a
|
||||
turn-based JRPG entry in the Mario franchise with a paper-based aesthetic
|
||||
and platforming elements, sees the titular character working his way through
|
||||
the Mushroom Kingdom\\u0027s diverse locales and biomes, meeting its inhabitants,
|
||||
fighthing unruly enemies and recruiting an array of companions in order to
|
||||
once again save Princess Peach from the clutches of the evil Koopa King Bowser.\",\n
|
||||
\ \"total_rating\": 88.63944908765737,\n \"language_supports\": [\n {\n
|
||||
\ \"id\": 473450,\n \"language\": {\n \"id\": 3,\n \"name\":
|
||||
\"Chinese (Traditional)\"\n }\n },\n {\n \"id\": 473451,\n
|
||||
\ \"language\": {\n \"id\": 7,\n \"name\": \"English\"\n
|
||||
\ }\n },\n {\n \"id\": 473452,\n \"language\":
|
||||
{\n \"id\": 16,\n \"name\": \"Japanese\"\n }\n },\n
|
||||
\ {\n \"id\": 492896,\n \"language\": {\n \"id\":
|
||||
12,\n \"name\": \"French\"\n }\n },\n {\n \"id\":
|
||||
492897,\n \"language\": {\n \"id\": 27,\n \"name\":
|
||||
\"German\"\n }\n },\n {\n \"id\": 492898,\n \"language\":
|
||||
{\n \"id\": 9,\n \"name\": \"Spanish (Spain)\"\n }\n
|
||||
\ }\n ],\n \"collections\": [\n {\n \"id\": 240,\n \"name\":
|
||||
\"Super Mario\"\n },\n {\n \"id\": 593,\n \"name\":
|
||||
\"Paper Mario\"\n }\n ]\n }\n]"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 850a6a953d2e248a-ZAG
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Encoding:
|
||||
- gzip
|
||||
Content-Length:
|
||||
- "1538"
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Mon, 05 Feb 2024 10:19:40 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=I3ULXMXIRc9niNoF9127GN_3tb_aWxph2N5i5_LrML8-1707128380-1-AfW1VNAvLTYI3QURGvTG83fjvlSRRa99K6dhpnpOS0pViyfEpSvsk2jxiAiKWWF+lsB8q8/savmBm7DaCBhr/34=;
|
||||
path=/; expires=Mon, 05-Feb-24 10:49:40 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 c8710a117c1dfdaea4e9dfc4d41970d2.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- ftLhsJz_oLi5B0FNeIaHkyKYD3U8DNwYykc0593NuTl0XHnCDkXVBQ==
|
||||
X-Amz-Cf-Pop:
|
||||
- VIE50-C2
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- "1"
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- SqFpZHWLvHcEEqA=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- "1538"
|
||||
x-amzn-Remapped-Date:
|
||||
- Mon, 05 Feb 2024 10:19:40 GMT
|
||||
x-amzn-RequestId:
|
||||
- 9d50d306-4874-4022-af53-561acccaebcf
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body:
|
||||
fields id,name,slug,summary,total_rating,aggregated_rating,genres.name,alternative_names.name,artworks.url,cover.url,screenshots.url,franchise.name,franchises.name,collections.name,expansions.name,expansions.slug,expansions.cover.url,expanded_games.name,expanded_games.cover.url,dlcs.name,dlcs.slug,dlcs.cover.url,remakes.name,remakes.cover.url,remasters.name,remasters.cover.url,involved_companies.company.name,platforms.name,first_release_date,game_modes.name,player_perspectives.name,ports.name,similar_games.name,language_supports.language.name,external_games.uid,external_games.category;
|
||||
where id=-1; limit 200;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer test_token
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "616"
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/games
|
||||
response:
|
||||
body:
|
||||
string:
|
||||
"{\n \"message\": \"Authorization Failure. Have you tried:\",\n \"Tip
|
||||
1\": \"Ensure you are sending Authorization and Client-ID as headers.\",\n
|
||||
\ \"Tip 2\": \"Ensure Authorization value starts with 'Bearer ', including
|
||||
the space\",\n \"Tip 3\": \"Ensure Authorization value ends with the App
|
||||
Access Token you generated, NOT your Client Secret.\",\n \"Docs\": \"https://api-docs.igdb.com/#authentication\",\n
|
||||
\ \"Discord\": \"https://discord.gg/FrvfwQg\"\n}\n"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 850a6a986dd36c85-ZAG
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "437"
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Mon, 05 Feb 2024 10:19:40 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=vWbMOoecKcFzu1pxWgKRUj2pC7f_ICwMPigG6vgpKFo-1707128380-1-AUt6CoXg6VpkhCmOf/kGjGXOHufqqUkmQpKQ83kCEhfx3Wd2GUlkYcmezfHtxdI1S5EdJvu/B2YTt6M2XxD8PnQ=;
|
||||
path=/; expires=Mon, 05-Feb-24 10:49:40 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 4ca98b546b8d71c72caf6a3d8f75dc24.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- NIVmSftyAB5e8PNtAgeLb8_rzIBpT7_JInx8oV65go9Is7xuzmpBqA==
|
||||
X-Amz-Cf-Pop:
|
||||
- VIE50-C2
|
||||
X-Cache:
|
||||
- Error from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- SqFphGNKvHcEfAg=
|
||||
x-amzn-ErrorType:
|
||||
- AccessDeniedException
|
||||
x-amzn-RequestId:
|
||||
- a44b029e-591b-4eac-bb86-c787a013b33b
|
||||
status:
|
||||
code: 401
|
||||
message: Unauthorized
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Accept:
|
||||
- "*/*"
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "0"
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://id.twitch.tv/oauth2/token?client_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&client_secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&grant_type=client_credentials
|
||||
response:
|
||||
body:
|
||||
string:
|
||||
'{"access_token":"97xbg8dxzst4sifbgrg6k4h0sy4sv2","expires_in":5647856,"token_type":"bearer"}
|
||||
|
||||
'
|
||||
headers:
|
||||
Access-Control-Allow-Origin:
|
||||
- "*"
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "93"
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Mon, 05 Feb 2024 10:19:41 GMT
|
||||
Server:
|
||||
- nginx
|
||||
X-Ctxlog-Logid:
|
||||
- 1-65c0b63d-349b7d5762fd9bdf2dae9570
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body:
|
||||
fields id,name,slug,summary,total_rating,aggregated_rating,genres.name,alternative_names.name,artworks.url,cover.url,screenshots.url,franchise.name,franchises.name,collections.name,expansions.name,expansions.slug,expansions.cover.url,expanded_games.name,expanded_games.cover.url,dlcs.name,dlcs.slug,dlcs.cover.url,remakes.name,remakes.cover.url,remasters.name,remasters.cover.url,involved_companies.company.name,platforms.name,first_release_date,game_modes.name,player_perspectives.name,ports.name,similar_games.name,language_supports.language.name,external_games.uid,external_games.category;
|
||||
where id=-1; limit 200;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer 97xbg8dxzst4sifbgrg6k4h0sy4sv2
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "616"
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/games
|
||||
response:
|
||||
body:
|
||||
string: "[]"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 850a6aa46d29248a-ZAG
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- "2"
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Mon, 05 Feb 2024 10:19:42 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=GBFFIgTMk119j.gLCnb7xhBRhJ7E3I1IwU6AhAEWVBI-1707128382-1-ARYE0aU8jHa5mcAGG1zqxoFza2uHyJTziSBFJPq4fb4PsXKUAmgCbn2HFubH4DQxWx5bDXH2nk0q+fw2lOYOAVY=;
|
||||
path=/; expires=Mon, 05-Feb-24 10:49:42 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 c8710a117c1dfdaea4e9dfc4d41970d2.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- Xb4nOz10hCXyDhxzTn-oY-Orl6J6kscPVnWX_1pwj2mDjRNa6TGfaA==
|
||||
X-Amz-Cf-Pop:
|
||||
- VIE50-C2
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- "0"
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- SqFp0HBaPHcEsDw=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- "2"
|
||||
x-amzn-Remapped-Date:
|
||||
- Mon, 05 Feb 2024 10:19:42 GMT
|
||||
x-amzn-RequestId:
|
||||
- 134a8022-0def-4111-9d61-5683fa7a89c2
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
||||
@@ -3,13 +3,14 @@ from exceptions.fs_exceptions import RomsNotFoundException
|
||||
from handler.scan_handler import ScanType, scan_platform, scan_rom
|
||||
from models.platform import Platform
|
||||
from models.rom import Rom
|
||||
from utils.context import initialize_context
|
||||
|
||||
|
||||
@pytest.mark.vcr
|
||||
def test_scan_platform():
|
||||
platform = scan_platform("n64", ["n64"])
|
||||
|
||||
assert platform.__class__ == Platform
|
||||
assert type(platform) is Platform
|
||||
assert platform.fs_slug == "n64"
|
||||
assert platform.slug == "n64"
|
||||
assert platform.name == "Nintendo 64"
|
||||
@@ -24,26 +25,24 @@ def test_scan_platform():
|
||||
@pytest.mark.vcr
|
||||
async def test_scan_rom():
|
||||
platform = Platform(fs_slug="n64", igdb_id=4)
|
||||
files = [
|
||||
{
|
||||
"file_name": "Paper Mario (USA).z64",
|
||||
"crc_hash": "9d0d1c6e",
|
||||
"md5_hash": "f1b7f9e4f4d0e0b7b9faa1b1f2f8e4e9",
|
||||
"sha1_hash": "c3c7f9f3d1d0e0b7b9faa1b1f2f8e4e9",
|
||||
}
|
||||
]
|
||||
|
||||
rom = await scan_rom(
|
||||
platform,
|
||||
{
|
||||
"file_name": "Paper Mario (USA).z64",
|
||||
"multi": False,
|
||||
"files": files,
|
||||
},
|
||||
ScanType.QUICK,
|
||||
)
|
||||
async with initialize_context():
|
||||
files = [
|
||||
{
|
||||
"file_name": "Paper Mario (USA).z64",
|
||||
"crc_hash": "9d0d1c6e",
|
||||
"md5_hash": "f1b7f9e4f4d0e0b7b9faa1b1f2f8e4e9",
|
||||
"sha1_hash": "c3c7f9f3d1d0e0b7b9faa1b1f2f8e4e9",
|
||||
}
|
||||
]
|
||||
|
||||
assert rom.__class__ == Rom
|
||||
rom = await scan_rom(
|
||||
platform,
|
||||
{"file_name": "Paper Mario (USA).z64", "multi": False, "files": files},
|
||||
ScanType.QUICK,
|
||||
)
|
||||
|
||||
assert type(rom) is Rom
|
||||
assert rom.file_name == "Paper Mario (USA).z64"
|
||||
assert rom.name == "Paper Mario"
|
||||
assert rom.igdb_id == 3340
|
||||
|
||||
@@ -4,7 +4,7 @@ from collections.abc import AsyncGenerator
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
import alembic.config
|
||||
import httpx
|
||||
import endpoints.sockets.scan # noqa
|
||||
import uvicorn
|
||||
from config import (
|
||||
DEV_HOST,
|
||||
@@ -43,12 +43,13 @@ from handler.scan_handler import ScanType
|
||||
from handler.socket_handler import socket_handler
|
||||
from starlette.middleware.authentication import AuthenticationMiddleware
|
||||
from utils import get_version
|
||||
from utils.context import ctx_httpx_client, initialize_context, set_context_middleware
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
|
||||
async with httpx.AsyncClient() as client:
|
||||
app.requests_client = client # type: ignore[attr-defined]
|
||||
async with initialize_context():
|
||||
app.state.httpx_client = ctx_httpx_client.get()
|
||||
yield
|
||||
|
||||
|
||||
@@ -83,11 +84,15 @@ app.add_middleware(
|
||||
app.add_middleware(
|
||||
SessionMiddleware,
|
||||
secret_key=ROMM_AUTH_SECRET_KEY,
|
||||
session_cookie="romm_session",
|
||||
same_site="strict",
|
||||
https_only=False,
|
||||
jwt_alg=ALGORITHM,
|
||||
)
|
||||
|
||||
# Sets context vars in request-response cycle
|
||||
app.middleware("http")(set_context_middleware)
|
||||
|
||||
app.include_router(heartbeat.router)
|
||||
app.include_router(auth.router)
|
||||
app.include_router(user.router)
|
||||
|
||||
@@ -6,7 +6,7 @@ from functools import cached_property
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from handler.metadata.base_hander import conditionally_set_cache
|
||||
from handler.redis_handler import cache
|
||||
from handler.redis_handler import sync_cache
|
||||
from models.base import BaseModel
|
||||
from sqlalchemy import BigInteger, ForeignKey, String
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
@@ -55,7 +55,7 @@ class Firmware(BaseModel):
|
||||
|
||||
@cached_property
|
||||
def is_verified(self) -> bool:
|
||||
cache_entry = cache.hget(
|
||||
cache_entry = sync_cache.hget(
|
||||
KNOWN_BIOS_KEY, f"{self.platform_slug}:{self.file_name}"
|
||||
)
|
||||
if cache_entry:
|
||||
|
||||
@@ -112,10 +112,10 @@ class Rom(BaseModel):
|
||||
|
||||
return db_rom_handler.get_sibling_roms(self)
|
||||
|
||||
def get_collections(self, user_id) -> list[Collection]:
|
||||
def get_collections(self) -> list[Collection]:
|
||||
from handler.database import db_rom_handler
|
||||
|
||||
return db_rom_handler.get_rom_collections(self, user_id)
|
||||
return db_rom_handler.get_rom_collections(self)
|
||||
|
||||
# Metadata fields
|
||||
@property
|
||||
|
||||
@@ -5,7 +5,7 @@ from config import (
|
||||
ENABLE_SCHEDULED_UPDATE_SWITCH_TITLEDB,
|
||||
SCHEDULED_UPDATE_SWITCH_TITLEDB_CRON,
|
||||
)
|
||||
from handler.redis_handler import cache
|
||||
from handler.redis_handler import async_cache
|
||||
from logger.logger import log
|
||||
from tasks.tasks import RemoteFilePullTask
|
||||
from utils.iterators import batched
|
||||
@@ -32,16 +32,19 @@ class UpdateSwitchTitleDBTask(RemoteFilePullTask):
|
||||
index_json = json.loads(content)
|
||||
relevant_data = {k: v for k, v in index_json.items() if k and v}
|
||||
|
||||
with cache.pipeline() as pipe:
|
||||
async with async_cache.pipeline() as pipe:
|
||||
for data_batch in batched(relevant_data.items(), 2000):
|
||||
titledb_map = {k: json.dumps(v) for k, v in dict(data_batch).items()}
|
||||
pipe.hset(SWITCH_TITLEDB_INDEX_KEY, mapping=titledb_map)
|
||||
await pipe.hset(SWITCH_TITLEDB_INDEX_KEY, mapping=titledb_map)
|
||||
for data_batch in batched(relevant_data.items(), 2000):
|
||||
product_map = {
|
||||
v["id"]: json.dumps(v) for v in dict(data_batch).values()
|
||||
v["id"]: json.dumps(v)
|
||||
for v in dict(data_batch).values()
|
||||
if v.get("id")
|
||||
}
|
||||
pipe.hset(SWITCH_PRODUCT_ID_KEY, mapping=product_map)
|
||||
pipe.execute()
|
||||
if product_map:
|
||||
await pipe.hset(SWITCH_PRODUCT_ID_KEY, mapping=product_map)
|
||||
await pipe.execute()
|
||||
|
||||
log.info("Scheduled switch titledb update completed!")
|
||||
|
||||
|
||||
41
backend/utils/context.py
Normal file
41
backend/utils/context.py
Normal file
@@ -0,0 +1,41 @@
|
||||
from collections.abc import AsyncGenerator, Awaitable, Callable
|
||||
from contextlib import asynccontextmanager
|
||||
from contextvars import ContextVar, Token
|
||||
from typing import TypeVar
|
||||
|
||||
import httpx
|
||||
from fastapi import Request, Response
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
ctx_httpx_client: ContextVar[httpx.AsyncClient] = ContextVar("httpx_client")
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def set_context_var(
|
||||
var: ContextVar[_T], value: _T
|
||||
) -> AsyncGenerator[Token[_T], None]:
|
||||
"""Temporarily set a context variables."""
|
||||
token = var.set(value)
|
||||
yield token
|
||||
var.reset(token)
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def initialize_context() -> AsyncGenerator[None, None]:
|
||||
"""Initialize context variables."""
|
||||
async with httpx.AsyncClient() as httpx_client:
|
||||
async with set_context_var(ctx_httpx_client, httpx_client):
|
||||
yield
|
||||
|
||||
|
||||
async def set_context_middleware(
|
||||
request: Request, call_next: Callable[[Request], Awaitable[Response]]
|
||||
) -> Response:
|
||||
"""Initialize context variables in FastAPI request-response cycle.
|
||||
|
||||
This middleware is needed because the context initialized during the lifespan
|
||||
process is not available in the request-response cycle.
|
||||
"""
|
||||
async with set_context_var(ctx_httpx_client, request.app.state.httpx_client):
|
||||
return await call_next(request)
|
||||
@@ -50,6 +50,7 @@ IGDB_SLUG_TO_MOBY_SLUG = {
|
||||
"psvita": "ps-vita",
|
||||
"sega32x": "sega-32x",
|
||||
"segacd": "sega-cd",
|
||||
"g-and-w": "dedicated-handheld",
|
||||
"gamegear": "game-gear",
|
||||
"genesis-slash-megadrive": "genesis",
|
||||
"saturn": "sega-saturn",
|
||||
|
||||
153
examples/config.batocera-retrobat.yml
Normal file
153
examples/config.batocera-retrobat.yml
Normal file
@@ -0,0 +1,153 @@
|
||||
# This config file is compatible with Batocera or Retrobat-based set-ups
|
||||
# Rename this file to `config.yml`, copy it to a `config` folder, and mount that folder as per the docker-compose.example.yml
|
||||
# Only uncomment the lines you want to use/modify, or add new ones where needed
|
||||
exclude:
|
||||
platforms: []
|
||||
roms:
|
||||
multi_file:
|
||||
names: []
|
||||
parts:
|
||||
extensions: []
|
||||
names: []
|
||||
single_file:
|
||||
extensions: []
|
||||
names: []
|
||||
filesystem: {}
|
||||
system:
|
||||
platforms:
|
||||
3do: 3do
|
||||
3ds: 3ds
|
||||
adam: colecoadam
|
||||
advision: adventure-vision
|
||||
amiga1200: amiga
|
||||
amiga4000: amiga
|
||||
amiga500: amiga
|
||||
amigacd32: amiga-cd32
|
||||
amigacdtv: amiga-cd32
|
||||
amstradcpc: acpc
|
||||
apfm1000: apf
|
||||
apple2: appleii
|
||||
apple2gs: apple2gs
|
||||
arcadia: arcadia-2001
|
||||
archimedes: acorn-archimedes
|
||||
arduboy: arduboy
|
||||
astrocade: astrocade
|
||||
atari2600: atari2600
|
||||
atari5200: atari5200
|
||||
atari7800: atari7800
|
||||
atari800: atari
|
||||
atarist: atari-st
|
||||
atom: atom
|
||||
atomiswave: arcade
|
||||
bbcmicro: bbcmicro
|
||||
c128: c128
|
||||
c20: vic-20
|
||||
c64: c64
|
||||
camplynx: camputers-lynx
|
||||
cdi: philips-cd-i
|
||||
channelf: fairchild-channel-f
|
||||
coco: trs-80-color-computer
|
||||
colecovision: colecovision
|
||||
cplus4: c-plus-4
|
||||
cps1: cps1
|
||||
cps2: cps2
|
||||
cps3: cps3
|
||||
crvision: creativision
|
||||
daphne: daphne
|
||||
dos: dos
|
||||
dreamcast: dc
|
||||
easyrpg: rpgmaker
|
||||
fbneo: arcade
|
||||
fds: fds
|
||||
fm7: fm-7
|
||||
fmtowns: fm-towns
|
||||
gamate: gamate
|
||||
gameandwatch: g-and-w
|
||||
gamecom: game-dot-com
|
||||
gamecube: ngc
|
||||
gamegear: gamegear
|
||||
gb: gb
|
||||
gb2players: gb
|
||||
gba: gba
|
||||
gba2players: gba
|
||||
gbc: gbc
|
||||
gbc2players: gbc
|
||||
gp32: gp32
|
||||
gzdoom: doom
|
||||
intellivision: intellivision
|
||||
jaguar: jaguar
|
||||
jaguarcd: atari-jaguar-cd
|
||||
lcdgames: handheld-electronic-lcd
|
||||
lynx: lynx
|
||||
mame: arcade
|
||||
mastersystem: sms
|
||||
megadrive: genesis-slash-megadrive
|
||||
megadrive-msu: genesis-slash-megadrive
|
||||
megaduck: megaduck
|
||||
model2: arcade
|
||||
model3: arcade
|
||||
msx1: msx
|
||||
msx2: msx2
|
||||
msx2+: msx2
|
||||
n64: n64
|
||||
n64dd: nintendo-64dd
|
||||
naomi: arcade
|
||||
naomi2: arcade
|
||||
nds: nds
|
||||
neogeo: neogeoaes
|
||||
neogeocd: neo-geo-cd
|
||||
nes: nes
|
||||
ngp: neo-geo-pocket
|
||||
ngpc: neo-geo-pocket-color
|
||||
oricatmos: oric
|
||||
pc88: pc-8800-series
|
||||
pc98: pc-9800-series
|
||||
pcengine: turbografx16--1
|
||||
pcenginecd: turbografx-16-slash-pc-engine-cd
|
||||
pcfx: pc-fx
|
||||
pet: cpet
|
||||
pokemini: pokemon-mini
|
||||
prboom: doom
|
||||
ps2: ps2
|
||||
ps3: ps3
|
||||
psp: psp
|
||||
psvita: psvita
|
||||
psx: ps
|
||||
pv1000: casio-pv-1000
|
||||
samcoupe: sam-coupe
|
||||
satellaview: satellaview
|
||||
saturn: saturn
|
||||
scummvm: scummvm
|
||||
scv: epoch-super-cassette-vision
|
||||
sega32x: sega-32x
|
||||
segacd: segacd
|
||||
sg1000: sg1000
|
||||
sgb: gbc
|
||||
snes: snes
|
||||
snes-msu: snes
|
||||
spectravideo: spectravideo
|
||||
supergrafx: supergrafx
|
||||
supervision: supervision
|
||||
supracan: super-acan
|
||||
switch: switch
|
||||
thomson: thomson-mo5
|
||||
ti99: ti-99
|
||||
tic80: tic
|
||||
triforce: arcade
|
||||
tutor: tomy-tutor
|
||||
vectrex: vectrex
|
||||
virtualboy: virtualboy
|
||||
vsmile: vsmile
|
||||
wii: wii
|
||||
wiiu: wiiu
|
||||
windows: win
|
||||
wswan: wonderswan
|
||||
wswanc: wonderswan-color
|
||||
x1: x1
|
||||
x68000: sharp-x68000
|
||||
xbox: xbox
|
||||
xbox360: xbox360
|
||||
zmachine: z-machine
|
||||
zx81: sinclair-zx81
|
||||
zxspectrum: zxs
|
||||
versions: {}
|
||||
@@ -130,6 +130,17 @@ function closeDialog() {
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row class="pa-2" no-gutters>
|
||||
<v-col>
|
||||
<v-switch
|
||||
v-model="collection.is_public"
|
||||
:label="collection.is_public ? 'Public (visible to everyone)' : 'Private (only visible to me)'"
|
||||
color="romm-accent-1"
|
||||
class="px-2"
|
||||
hide-details
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-row class="pa-2 justify-center" no-gutters>
|
||||
|
||||
@@ -47,7 +47,7 @@ async function updateCollection({
|
||||
formData.append("roms", JSON.stringify(collection.roms));
|
||||
if (collection.artwork) formData.append("artwork", collection.artwork);
|
||||
return api.put(`/collections/${collection.id}`, formData, {
|
||||
params: { remove_cover: removeCover },
|
||||
params: { is_public: collection.is_public, remove_cover: removeCover },
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
25
poetry.lock
generated
25
poetry.lock
generated
@@ -1,4 +1,4 @@
|
||||
# This file is automatically @generated by Poetry 1.8.0.dev0 and should not be changed by hand.
|
||||
# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand.
|
||||
|
||||
[[package]]
|
||||
name = "alembic"
|
||||
@@ -2142,19 +2142,23 @@ pytest = ">=6.2.5"
|
||||
dev = ["pre-commit", "pytest-asyncio", "tox"]
|
||||
|
||||
[[package]]
|
||||
name = "pytest-vcr"
|
||||
version = "1.0.2"
|
||||
description = "Plugin for managing VCR.py cassettes"
|
||||
name = "pytest-recording"
|
||||
version = "0.13.2"
|
||||
description = "A pytest plugin that allows you recording of network interactions via VCR.py"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "pytest-vcr-1.0.2.tar.gz", hash = "sha256:23ee51b75abbcc43d926272773aae4f39f93aceb75ed56852d0bf618f92e1896"},
|
||||
{file = "pytest_vcr-1.0.2-py2.py3-none-any.whl", hash = "sha256:2f316e0539399bea0296e8b8401145c62b6f85e9066af7e57b6151481b0d6d9c"},
|
||||
{file = "pytest_recording-0.13.2-py3-none-any.whl", hash = "sha256:3820fe5743d1ac46e807989e11d073cb776a60bdc544cf43ebca454051b22d13"},
|
||||
{file = "pytest_recording-0.13.2.tar.gz", hash = "sha256:000c3babbb466681457fd65b723427c1779a0c6c17d9e381c3142a701e124877"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
pytest = ">=3.6.0"
|
||||
vcrpy = "*"
|
||||
pytest = ">=3.5.0"
|
||||
vcrpy = ">=2.0.1"
|
||||
|
||||
[package.extras]
|
||||
dev = ["pytest-httpbin", "pytest-mock", "requests", "werkzeug (==3.0.3)"]
|
||||
tests = ["pytest-httpbin", "pytest-mock", "requests", "werkzeug (==3.0.3)"]
|
||||
|
||||
[[package]]
|
||||
name = "python-dateutil"
|
||||
@@ -2296,7 +2300,6 @@ files = [
|
||||
{file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"},
|
||||
{file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"},
|
||||
{file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"},
|
||||
{file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"},
|
||||
{file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"},
|
||||
{file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"},
|
||||
{file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"},
|
||||
@@ -3379,4 +3382,4 @@ multidict = ">=4.0"
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.11"
|
||||
content-hash = "e48e70a29cf27ae3ad922456977865c5cc04ebd47460251a41eaa587f9bfc25b"
|
||||
content-hash = "51ef80f043654bfd38a5ec986605ed5e1e329ecbe1a1c893ff05a19d0b9c5f51"
|
||||
|
||||
@@ -9,6 +9,7 @@ authors = ["Zurdi <zurdi@romm.app>", "Arcane <arcane@romm.app>"]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.11"
|
||||
anyio = "^4.4"
|
||||
requests = "^2.32.2"
|
||||
fastapi = "0.110.0"
|
||||
uvicorn = "0.29.0"
|
||||
@@ -50,9 +51,9 @@ rarfile = "^4.2"
|
||||
fakeredis = "^2.21.3"
|
||||
pytest = "^8.1.1"
|
||||
pytest-env = "^1.1.3"
|
||||
pytest-vcr = "^1.0.2"
|
||||
pytest-mock = "^3.12.0"
|
||||
pytest-asyncio = "^0.23.5"
|
||||
pytest-recording = "^0.13"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
ipdb = "^0.13.13"
|
||||
|
||||
Reference in New Issue
Block a user