mirror of
https://github.com/rommapp/romm.git
synced 2026-12-04 21:02:21 +01:00
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
||||
**/tests/cassettes/*.yaml linguist-generated
|
||||
69
.github/workflows/pytest.yml
vendored
Normal file
69
.github/workflows/pytest.yml
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
name: run pytest
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- "opened"
|
||||
- "synchronize"
|
||||
paths-ignore:
|
||||
- "docker/**"
|
||||
- "examples/*"
|
||||
- "frontend/**"
|
||||
push:
|
||||
branches:
|
||||
- "master"
|
||||
paths-ignore:
|
||||
- "docker/**"
|
||||
- "examples/*"
|
||||
- "frontend/**"
|
||||
|
||||
jobs:
|
||||
pytest:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
checks: write
|
||||
pull-requests: write
|
||||
services:
|
||||
mariadb:
|
||||
image: mariadb:10.11
|
||||
ports:
|
||||
- 3306
|
||||
env:
|
||||
MYSQL_USER: romm_test
|
||||
MYSQL_PASSWORD: passwd
|
||||
MYSQL_DATABASE: romm_test
|
||||
MYSQL_ROOT_PASSWORD: passwd
|
||||
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Install mariadb connectors
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y libmariadb3 libmariadb-dev
|
||||
- name: Install poetry
|
||||
run: pipx install poetry
|
||||
- name: Set up Python 3.10
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.10'
|
||||
cache: 'poetry'
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
poetry install --sync
|
||||
- name: Initiate database
|
||||
run: |
|
||||
mysql --host 127.0.0.1 --port ${{ job.services.mariadb.ports['3306'] }} -uroot -ppasswd -e "GRANT ALL PRIVILEGES ON romm_test.* TO 'romm_test'@'%' WITH GRANT OPTION; FLUSH PRIVILEGES;"
|
||||
- name: Run python tests
|
||||
env:
|
||||
DB_HOST: 127.0.0.1
|
||||
DB_PORT: ${{ job.services.mariadb.ports['3306'] }}
|
||||
run: |
|
||||
cd backend
|
||||
poetry run pytest -vv --maxfail=10 --junitxml=pytest-report.xml .
|
||||
- name: Publish test results
|
||||
uses: EnricoMi/publish-unit-test-result-action/composite@v2
|
||||
if: always()
|
||||
with:
|
||||
files: |
|
||||
backend/pytest-report.xml
|
||||
10
.gitignore
vendored
10
.gitignore
vendored
@@ -20,6 +20,8 @@ coverage
|
||||
# Editor directories and files
|
||||
.vscode
|
||||
!.vscode/extensions.json
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
.idea
|
||||
*.suo
|
||||
*.ntvs*
|
||||
@@ -42,3 +44,11 @@ romm_mock
|
||||
|
||||
# virtualenv
|
||||
.venv
|
||||
|
||||
# testing
|
||||
backend/romm_test/resources
|
||||
backend/romm_test/logs
|
||||
.pytest_cache
|
||||
|
||||
# service worker
|
||||
frontend/dev-dist
|
||||
|
||||
52
.vscode/tasks.json
vendored
Normal file
52
.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "npm",
|
||||
"script": "dev",
|
||||
"path": "frontend",
|
||||
"problemMatcher": [],
|
||||
"label": "Launch frontend [npm]"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"command": "source ~/.cache/pypoetry/virtualenvs/romm-TjwgbYlf-py3.11/bin/activate; cd backend; python main.py",
|
||||
"label": "Launch backend [python]",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"command": "source ~/.cache/pypoetry/virtualenvs/romm-TjwgbYlf-py3.11/bin/activate; cd backend; pytest -v",
|
||||
"label": "Execute tests [pytest]",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"command": "./docker/build_local_image.sh",
|
||||
"label": "Build docker local image [docker]",
|
||||
"problemMatcher": [],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"command": "docker compose up -d",
|
||||
"label": "Setup development environment [docker] (1)",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"command": "export $(cat .env | xargs); docker exec -i mariadb mariadb -u root -p$DB_ROOT_PASSWD < backend/romm_test/setup.sql",
|
||||
"label": "Setup development environment migrations [docker] (2)",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"command": "cd romm_mock; docker compose up -d",
|
||||
"label": "Setup testing environment [docker]",
|
||||
"problemMatcher": []
|
||||
}
|
||||
]
|
||||
}
|
||||
20
CHANGELOG.md
20
CHANGELOG.md
@@ -1,3 +1,23 @@
|
||||
# v1.10 (_xx-08-2023_)
|
||||
|
||||
## Added
|
||||
- Rom admin menu added to roms in gallery. Closes [#28](https://github.com/zurdi15/romm/issues/28)
|
||||
- Added ps2/opl naming convention support for roms scanning. Closes [#324](https://github.com/zurdi15/romm/issues/324)
|
||||
|
||||
## Fixed
|
||||
- Fixed an error caused by the service worker that sometimes intercepts download requests and returns a bad response. Fixes [#297](https://github.com/zurdi15/romm/issues/297)
|
||||
- Fixed rom count in platform selector when deleting/scanning roms. Fixes [#325](https://github.com/zurdi15/romm/issues/325)
|
||||
|
||||
## Changed
|
||||
- Improved scanning and IGDB requests logs. Fixes [#317](https://github.com/zurdi15/romm/issues/317)
|
||||
- Improved downloading process. Fixes [#332](https://github.com/zurdi15/romm/issues/332)
|
||||
|
||||
|
||||
|
||||
**_Note_**: Experimental support for redis in the backend was added for anyone that wants to test it (it's experimental so expect some bugs). It's not required yet (check docker-compose.example.yml to check how to set the needed environment variables) but it will likely be introduced in 2.0.
|
||||
|
||||
<br>
|
||||
|
||||
# v1.9.1 (_01-08-2023_)
|
||||
|
||||
## Added
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
## Create the mock structure with at least one rom
|
||||
# Environment setup
|
||||
|
||||
## Mocking RomM structure
|
||||
|
||||
### - Create the mock structure with at least one rom and empty config for manual testing
|
||||
|
||||
```sh
|
||||
mkdir -p romm_mock/library/roms/switch
|
||||
@@ -9,13 +13,13 @@ touch romm_mock/config.yml
|
||||
|
||||
## Setting up the backend
|
||||
|
||||
### Copy env.template to .env and fill the variables
|
||||
### - Copy env.template to .env and fill the variables
|
||||
|
||||
```sh
|
||||
cp env.template .env
|
||||
```
|
||||
|
||||
### Install python dependencies
|
||||
### - Install python dependencies
|
||||
|
||||
You'll need poetry installed
|
||||
|
||||
@@ -26,47 +30,73 @@ Then initialize the virtual environment and install the dependencies
|
||||
```sh
|
||||
poetry shell
|
||||
# Fix disable parallel installation stuck: $> poetry config experimental.new-installer false
|
||||
# Fix Loading macOS stuck: $> export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
|
||||
# Fix Loading macOS/linux stuck: $> export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
|
||||
# Fix mariadb install on linux: $> sudo apt install libmariadb3 libmariadb-dev
|
||||
# Fix mariadb connector/c >= 3.3.1: https://mariadb.com/docs/skysql-previous-release/connect/programming-languages/c/install/#Installation_via_Package_Repository_(Linux)
|
||||
poetry install
|
||||
```
|
||||
|
||||
### Spin up mariadb in docker
|
||||
### - Spin up mariadb in docker
|
||||
|
||||
```sh
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### Run the migrations
|
||||
### - Run the backend
|
||||
|
||||
*__*Migrations will be run automatically when running the backend.__*
|
||||
|
||||
```sh
|
||||
cd backend
|
||||
alembic upgrade head
|
||||
python main.py
|
||||
```
|
||||
|
||||
## And finally run the backend
|
||||
|
||||
### - Start a worker
|
||||
|
||||
```sh
|
||||
python main.py
|
||||
cd backend
|
||||
python worker.py
|
||||
```
|
||||
|
||||
## Setting up the frontend
|
||||
|
||||
### Install node.js dependencies
|
||||
### - Install node.js dependencies
|
||||
|
||||
```sh
|
||||
cd frontend
|
||||
# npm version >= 9 needed
|
||||
npm install
|
||||
```
|
||||
|
||||
### Create symlink to library and resources
|
||||
### - Create symlink to library and resources
|
||||
```sh
|
||||
mkdir assets/romm
|
||||
ln -s ../../../romm_mock/library assets/romm/library
|
||||
ln -s ../../../romm_mock/resources assets/romm/resources
|
||||
```
|
||||
|
||||
### Run the frontend
|
||||
### - Run the frontend
|
||||
|
||||
```sh
|
||||
npm run dev
|
||||
```
|
||||
|
||||
# Test setup
|
||||
|
||||
### - Create the test user and database with root user
|
||||
|
||||
```sh
|
||||
docker exec -i mariadb mysql -u root -p<root password> < backend/romm_test/setup.sql # for amd images
|
||||
docker exec -i mariadb mariadb -u root -p<root password> < backend/romm_test/setup.sql # for arm images
|
||||
```
|
||||
|
||||
### - Run tests
|
||||
|
||||
*__*Migrations will be run automatically when running the tests.__*
|
||||
|
||||
```sh
|
||||
cd backend
|
||||
# path or test file can be passed as argument to test only a subset
|
||||
pytest [path/file]
|
||||
```
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<h1 style="padding:20px;"><img src="romm.svg" height="220px" width="auto" alt="RomM Logo"></h1>
|
||||
<img alt="GitHub" src="https://img.shields.io/github/license/zurdi15/romm?style=flat-square">
|
||||
<img alt="GitHub release (latest SemVer)" src="https://img.shields.io/github/v/release/zurdi15/romm?style=flat-square">
|
||||
<img alt="GitHub Workflow Status (with branch)" src="https://img.shields.io/github/actions/workflow/status/zurdi15/romm/image.yml?style=flat-square&branch=master">
|
||||
<img alt="GitHub Workflow Status (with branch)" src="https://img.shields.io/github/actions/workflow/status/zurdi15/romm/build.yml?style=flat-square&branch=master">
|
||||
<br>
|
||||
<a href="https://hub.docker.com/r/zurdi15/romm">
|
||||
<img alt="Docker Pulls" src="https://img.shields.io/docker/pulls/zurdi15/romm?style=flat-square">
|
||||
@@ -67,6 +67,10 @@ Inspired by [Jellyfin](https://jellyfin.org/), allows you to manage all your gam
|
||||
</details>
|
||||
<br>
|
||||
|
||||
# The RomM community
|
||||
[Wiki](https://github.com/zurdi15/romm/wiki) <br/>
|
||||
[Discord](https://discord.gg/P5HtHnhUDH)<br/>
|
||||
|
||||
# Installation
|
||||
|
||||
## 🐳 Docker
|
||||
@@ -149,7 +153,7 @@ Check the [docker-compose.yml](https://github.com/zurdi15/romm/blob/master/examp
|
||||
<h2 id="platform-support">🎮 Platform support</h2>
|
||||
|
||||
If the RomM [folder structure](#📁-folder-structure) is followed, any kind of platform/folder-name is supported for the core features. For having extra metadata as well as cover images and platforms icons, the following table shows how to name your platforms folders.
|
||||
This will change over the time, adding games metadata for more platforms. Make sure that the platforms folder names are lowercase.
|
||||
This will change over the time, adding games metadata for more platforms.
|
||||
|
||||
<br>
|
||||
<details>
|
||||
|
||||
@@ -5,6 +5,7 @@ from sqlalchemy import create_engine
|
||||
|
||||
from config.config_loader import ConfigLoader
|
||||
from alembic import context
|
||||
from models.base import BaseModel
|
||||
|
||||
# this is the Alembic Config object, which provides
|
||||
# access to the values within the .ini file in use.
|
||||
@@ -13,14 +14,11 @@ config = context.config
|
||||
# Interpret the config file for Python logging.
|
||||
# This line sets up loggers basically.
|
||||
if config.config_file_name is not None:
|
||||
fileConfig(config.config_file_name)
|
||||
fileConfig(config.config_file_name, disable_existing_loggers=False)
|
||||
|
||||
# add your model's MetaData object here
|
||||
# for 'autogenerate' support
|
||||
sys.path.append(f"{Path(__file__).parent.parent.resolve()}")
|
||||
from models.base import BaseModel
|
||||
from models.platform import Platform
|
||||
from models.rom import Rom
|
||||
|
||||
target_metadata = BaseModel.metadata
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ from sqlalchemy.exc import OperationalError
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1.6.2'
|
||||
revision = "1.6.2"
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
@@ -20,36 +20,38 @@ depends_on = None
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
try:
|
||||
op.create_table('platforms',
|
||||
sa.Column('igdb_id', sa.String(length=10), nullable=True),
|
||||
sa.Column('sgdb_id', sa.String(length=10), nullable=True),
|
||||
sa.Column('slug', sa.String(length=50), nullable=False),
|
||||
sa.Column('name', sa.String(length=400), nullable=True),
|
||||
sa.Column('logo_path', sa.String(length=1000), nullable=True),
|
||||
sa.Column('n_roms', sa.Integer(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('slug')
|
||||
op.create_table(
|
||||
"platforms",
|
||||
sa.Column("igdb_id", sa.String(length=10), nullable=True),
|
||||
sa.Column("sgdb_id", sa.String(length=10), nullable=True),
|
||||
sa.Column("slug", sa.String(length=50), nullable=False),
|
||||
sa.Column("name", sa.String(length=400), nullable=True),
|
||||
sa.Column("logo_path", sa.String(length=1000), nullable=True),
|
||||
sa.Column("n_roms", sa.Integer(), nullable=True),
|
||||
sa.PrimaryKeyConstraint("slug"),
|
||||
)
|
||||
op.create_table('roms',
|
||||
sa.Column('r_igdb_id', sa.String(length=10), nullable=True),
|
||||
sa.Column('p_igdb_id', sa.String(length=10), nullable=True),
|
||||
sa.Column('r_sgdb_id', sa.String(length=10), nullable=True),
|
||||
sa.Column('p_sgdb_id', sa.String(length=10), nullable=True),
|
||||
sa.Column('p_slug', sa.String(length=50), nullable=False),
|
||||
sa.Column('file_name', sa.String(length=450), nullable=False),
|
||||
sa.Column('file_name_no_tags', sa.String(length=450), nullable=True),
|
||||
sa.Column('file_extension', sa.String(length=10), nullable=True),
|
||||
sa.Column('file_path', sa.String(length=1000), nullable=True),
|
||||
sa.Column('file_size', sa.Float(), nullable=True),
|
||||
sa.Column('name', sa.String(length=350), nullable=True),
|
||||
sa.Column('r_slug', sa.String(length=100), nullable=True),
|
||||
sa.Column('summary', sa.Text(), nullable=True),
|
||||
sa.Column('path_cover_s', sa.Text(), nullable=True),
|
||||
sa.Column('path_cover_l', sa.Text(), nullable=True),
|
||||
sa.Column('has_cover', sa.Boolean(), nullable=True),
|
||||
sa.Column('region', sa.String(length=20), nullable=True),
|
||||
sa.Column('revision', sa.String(length=20), nullable=True),
|
||||
sa.Column('tags', sa.JSON(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('p_slug', 'file_name')
|
||||
op.create_table(
|
||||
"roms",
|
||||
sa.Column("r_igdb_id", sa.String(length=10), nullable=True),
|
||||
sa.Column("p_igdb_id", sa.String(length=10), nullable=True),
|
||||
sa.Column("r_sgdb_id", sa.String(length=10), nullable=True),
|
||||
sa.Column("p_sgdb_id", sa.String(length=10), nullable=True),
|
||||
sa.Column("p_slug", sa.String(length=50), nullable=False),
|
||||
sa.Column("file_name", sa.String(length=450), nullable=False),
|
||||
sa.Column("file_name_no_tags", sa.String(length=450), nullable=True),
|
||||
sa.Column("file_extension", sa.String(length=10), nullable=True),
|
||||
sa.Column("file_path", sa.String(length=1000), nullable=True),
|
||||
sa.Column("file_size", sa.Float(), nullable=True),
|
||||
sa.Column("name", sa.String(length=350), nullable=True),
|
||||
sa.Column("r_slug", sa.String(length=100), nullable=True),
|
||||
sa.Column("summary", sa.Text(), nullable=True),
|
||||
sa.Column("path_cover_s", sa.Text(), nullable=True),
|
||||
sa.Column("path_cover_l", sa.Text(), nullable=True),
|
||||
sa.Column("has_cover", sa.Boolean(), nullable=True),
|
||||
sa.Column("region", sa.String(length=20), nullable=True),
|
||||
sa.Column("revision", sa.String(length=20), nullable=True),
|
||||
sa.Column("tags", sa.JSON(), nullable=True),
|
||||
sa.PrimaryKeyConstraint("p_slug", "file_name"),
|
||||
)
|
||||
except OperationalError:
|
||||
pass
|
||||
|
||||
@@ -10,8 +10,8 @@ import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1.6.3'
|
||||
down_revision = '1.6.2'
|
||||
revision = "1.6.3"
|
||||
down_revision = "1.6.2"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
@@ -19,14 +19,14 @@ depends_on = None
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("roms") as batch_op:
|
||||
batch_op.add_column(sa.Column('multi', sa.Boolean(), nullable=True))
|
||||
batch_op.add_column(sa.Column('files', sa.JSON(), nullable=True))
|
||||
batch_op.add_column(sa.Column("multi", sa.Boolean(), nullable=True))
|
||||
batch_op.add_column(sa.Column("files", sa.JSON(), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("roms") as batch_op:
|
||||
batch_op.drop_column('files')
|
||||
batch_op.drop_column('multi')
|
||||
batch_op.drop_column("files")
|
||||
batch_op.drop_column("multi")
|
||||
# ### end Alembic commands ###
|
||||
|
||||
@@ -10,8 +10,8 @@ import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1.7.1'
|
||||
down_revision = '1.6.3'
|
||||
revision = "1.7.1"
|
||||
down_revision = "1.6.3"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
@@ -19,12 +19,14 @@ depends_on = None
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("roms") as batch_op:
|
||||
batch_op.add_column(sa.Column('file_size_units', sa.String(length=10), nullable=True))
|
||||
batch_op.add_column(
|
||||
sa.Column("file_size_units", sa.String(length=10), nullable=True)
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("roms") as batch_op:
|
||||
batch_op.drop_column('file_size_units')
|
||||
batch_op.drop_column("file_size_units")
|
||||
# ### end Alembic commands ###
|
||||
|
||||
@@ -10,8 +10,8 @@ import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1.8.1'
|
||||
down_revision = '1.8'
|
||||
revision = "1.8.1"
|
||||
down_revision = "1.8"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
@@ -19,14 +19,20 @@ depends_on = None
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("roms") as batch_op:
|
||||
batch_op.add_column(sa.Column('url_screenshots', sa.JSON(), nullable=False, server_default='[]'))
|
||||
batch_op.add_column(sa.Column('path_screenshots', sa.JSON(), nullable=False, server_default='[]'))
|
||||
batch_op.add_column(
|
||||
sa.Column("url_screenshots", sa.JSON(), nullable=False, server_default="[]")
|
||||
)
|
||||
batch_op.add_column(
|
||||
sa.Column(
|
||||
"path_screenshots", sa.JSON(), nullable=False, server_default="[]"
|
||||
)
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("roms") as batch_op:
|
||||
batch_op.drop_column('url_screenshots')
|
||||
batch_op.drop_column('path_screenshots')
|
||||
batch_op.drop_column("url_screenshots")
|
||||
batch_op.drop_column("path_screenshots")
|
||||
# ### end Alembic commands ###
|
||||
|
||||
@@ -10,8 +10,8 @@ import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1.8.2'
|
||||
down_revision = '1.8.1'
|
||||
revision = "1.8.2"
|
||||
down_revision = "1.8.1"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
@@ -19,12 +19,16 @@ depends_on = None
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("roms") as batch_op:
|
||||
batch_op.alter_column('r_slug', type_=sa.String(length=400), existing_type=sa.String(length=100))
|
||||
batch_op.alter_column(
|
||||
"r_slug", type_=sa.String(length=400), existing_type=sa.String(length=100)
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("roms") as batch_op:
|
||||
batch_op.alter_column('r_slug', type_=sa.String(length=100), existing_type=sa.String(length=400))
|
||||
batch_op.alter_column(
|
||||
"r_slug", type_=sa.String(length=100), existing_type=sa.String(length=400)
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
@@ -10,8 +10,8 @@ import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1.8'
|
||||
down_revision = '1.7.1'
|
||||
revision = "1.8"
|
||||
down_revision = "1.7.1"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
@@ -20,59 +20,72 @@ def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("platforms") as batch_op:
|
||||
batch_op.execute("ALTER TABLE platforms RENAME TO old_platforms")
|
||||
op.create_table('platforms',
|
||||
sa.Column('igdb_id', sa.String(length=10), nullable=True),
|
||||
sa.Column('sgdb_id', sa.String(length=10), nullable=True),
|
||||
sa.Column('slug', sa.String(length=50), nullable=False),
|
||||
sa.Column('fs_slug', sa.String(length=50), nullable=False),
|
||||
sa.Column('name', sa.String(length=400), nullable=True),
|
||||
sa.Column('logo_path', sa.String(length=1000), nullable=True),
|
||||
sa.Column('n_roms', sa.Integer(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('fs_slug')
|
||||
op.create_table(
|
||||
"platforms",
|
||||
sa.Column("igdb_id", sa.String(length=10), nullable=True),
|
||||
sa.Column("sgdb_id", sa.String(length=10), nullable=True),
|
||||
sa.Column("slug", sa.String(length=50), nullable=False),
|
||||
sa.Column("fs_slug", sa.String(length=50), nullable=False),
|
||||
sa.Column("name", sa.String(length=400), nullable=True),
|
||||
sa.Column("logo_path", sa.String(length=1000), nullable=True),
|
||||
sa.Column("n_roms", sa.Integer(), nullable=True),
|
||||
sa.PrimaryKeyConstraint("fs_slug"),
|
||||
)
|
||||
batch_op.execute("INSERT INTO platforms(igdb_id, sgdb_id, slug, fs_slug, name, logo_path, n_roms) \
|
||||
batch_op.execute(
|
||||
"INSERT INTO platforms(igdb_id, sgdb_id, slug, fs_slug, name, logo_path, n_roms) \
|
||||
SELECT igdb_id, sgdb_id, slug, slug, name, logo_path, n_roms \
|
||||
FROM old_platforms")
|
||||
op.drop_table('old_platforms')
|
||||
|
||||
FROM old_platforms"
|
||||
)
|
||||
op.drop_table("old_platforms")
|
||||
|
||||
with op.batch_alter_table("roms") as batch_op:
|
||||
batch_op.add_column(sa.Column('p_name', sa.String(length=150), nullable=True))
|
||||
batch_op.add_column(sa.Column('url_cover', sa.Text(), nullable=True))
|
||||
batch_op.alter_column('name', new_column_name='r_name', type_=sa.String(length=150), existing_type=sa.String(length=150))
|
||||
batch_op.alter_column('p_slug', existing_type=sa.String(length=50), nullable=False)
|
||||
batch_op.alter_column('file_name', existing_type=sa.String(length=450), nullable=False)
|
||||
batch_op.add_column(sa.Column("p_name", sa.String(length=150), nullable=True))
|
||||
batch_op.add_column(sa.Column("url_cover", sa.Text(), nullable=True))
|
||||
batch_op.alter_column(
|
||||
"name",
|
||||
new_column_name="r_name",
|
||||
type_=sa.String(length=150),
|
||||
existing_type=sa.String(length=150),
|
||||
)
|
||||
batch_op.alter_column(
|
||||
"p_slug", existing_type=sa.String(length=50), nullable=False
|
||||
)
|
||||
batch_op.alter_column(
|
||||
"file_name", existing_type=sa.String(length=450), nullable=False
|
||||
)
|
||||
with op.batch_alter_table("roms") as batch_op:
|
||||
batch_op.execute("ALTER TABLE roms RENAME TO old_roms")
|
||||
op.create_table('roms',
|
||||
sa.Column('id', sa.Integer(), autoincrement=True),
|
||||
sa.Column('r_igdb_id', sa.String(length=10), nullable=True),
|
||||
sa.Column('p_igdb_id', sa.String(length=10), nullable=True),
|
||||
sa.Column('r_sgdb_id', sa.String(length=10), nullable=True),
|
||||
sa.Column('p_sgdb_id', sa.String(length=10), nullable=True),
|
||||
sa.Column('p_slug', sa.String(length=50), nullable=False),
|
||||
sa.Column('p_name', sa.String(length=150), nullable=True),
|
||||
sa.Column('file_name', sa.String(length=450), nullable=False),
|
||||
sa.Column('file_name_no_tags', sa.String(length=450), nullable=False),
|
||||
sa.Column('file_extension', sa.String(length=10), nullable=True),
|
||||
sa.Column('file_path', sa.String(length=1000), nullable=True),
|
||||
sa.Column('file_size', sa.Float(), nullable=True),
|
||||
sa.Column('file_size_units', sa.String(length=10), nullable=True),
|
||||
sa.Column('r_name', sa.String(length=350), nullable=True),
|
||||
sa.Column('r_slug', sa.String(length=100), nullable=True),
|
||||
sa.Column('summary', sa.Text(), nullable=True),
|
||||
sa.Column('path_cover_s', sa.Text(), nullable=True),
|
||||
sa.Column('path_cover_l', sa.Text(), nullable=True),
|
||||
sa.Column('has_cover', sa.Boolean(), nullable=True),
|
||||
sa.Column('region', sa.String(length=20), nullable=True),
|
||||
sa.Column('revision', sa.String(length=20), nullable=True),
|
||||
sa.Column('tags', sa.JSON(), nullable=True),
|
||||
sa.Column('multi', sa.Boolean(), nullable=True),
|
||||
sa.Column('files', sa.JSON(), nullable=True),
|
||||
sa.Column('url_cover', sa.Text(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
op.create_table(
|
||||
"roms",
|
||||
sa.Column("id", sa.Integer(), autoincrement=True),
|
||||
sa.Column("r_igdb_id", sa.String(length=10), nullable=True),
|
||||
sa.Column("p_igdb_id", sa.String(length=10), nullable=True),
|
||||
sa.Column("r_sgdb_id", sa.String(length=10), nullable=True),
|
||||
sa.Column("p_sgdb_id", sa.String(length=10), nullable=True),
|
||||
sa.Column("p_slug", sa.String(length=50), nullable=False),
|
||||
sa.Column("p_name", sa.String(length=150), nullable=True),
|
||||
sa.Column("file_name", sa.String(length=450), nullable=False),
|
||||
sa.Column("file_name_no_tags", sa.String(length=450), nullable=False),
|
||||
sa.Column("file_extension", sa.String(length=10), nullable=True),
|
||||
sa.Column("file_path", sa.String(length=1000), nullable=True),
|
||||
sa.Column("file_size", sa.Float(), nullable=True),
|
||||
sa.Column("file_size_units", sa.String(length=10), nullable=True),
|
||||
sa.Column("r_name", sa.String(length=350), nullable=True),
|
||||
sa.Column("r_slug", sa.String(length=100), nullable=True),
|
||||
sa.Column("summary", sa.Text(), nullable=True),
|
||||
sa.Column("path_cover_s", sa.Text(), nullable=True),
|
||||
sa.Column("path_cover_l", sa.Text(), nullable=True),
|
||||
sa.Column("has_cover", sa.Boolean(), nullable=True),
|
||||
sa.Column("region", sa.String(length=20), nullable=True),
|
||||
sa.Column("revision", sa.String(length=20), nullable=True),
|
||||
sa.Column("tags", sa.JSON(), nullable=True),
|
||||
sa.Column("multi", sa.Boolean(), nullable=True),
|
||||
sa.Column("files", sa.JSON(), nullable=True),
|
||||
sa.Column("url_cover", sa.Text(), nullable=True),
|
||||
sa.PrimaryKeyConstraint("id"),
|
||||
)
|
||||
batch_op.execute("INSERT INTO roms(\
|
||||
batch_op.execute(
|
||||
"INSERT INTO roms(\
|
||||
r_igdb_id, p_igdb_id, r_sgdb_id, p_sgdb_id, p_slug, p_name, \
|
||||
file_name, file_name_no_tags, file_extension, file_path, file_size, \
|
||||
file_size_units, r_name, r_slug, summary, path_cover_s, path_cover_l, has_cover, \
|
||||
@@ -82,21 +95,31 @@ def upgrade() -> None:
|
||||
file_name, file_name_no_tags, file_extension, file_path, file_size, \
|
||||
file_size_units, r_name, r_slug, summary, path_cover_s, path_cover_l, has_cover, \
|
||||
region, revision, tags, multi, files, url_cover \
|
||||
FROM old_roms")
|
||||
op.drop_table('old_roms')
|
||||
FROM old_roms"
|
||||
)
|
||||
op.drop_table("old_roms")
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("platforms") as batch_op:
|
||||
batch_op.drop_column('fs_slug')
|
||||
batch_op.drop_column("fs_slug")
|
||||
with op.batch_alter_table("roms") as batch_op:
|
||||
batch_op.drop_constraint('PRIMARY', type_="primary")
|
||||
batch_op.drop_column('id')
|
||||
batch_op.drop_column('p_name')
|
||||
batch_op.drop_column('url_cover')
|
||||
batch_op.alter_column('r_name', new_column_name='name', type_=sa.String(length=150), existing_type=sa.String(length=150))
|
||||
batch_op.alter_column('p_slug', existing_type=sa.String(length=50), nullable=False)
|
||||
batch_op.alter_column('file_name', existing_type=sa.String(length=450), nullable=False)
|
||||
batch_op.drop_constraint("PRIMARY", type_="primary")
|
||||
batch_op.drop_column("id")
|
||||
batch_op.drop_column("p_name")
|
||||
batch_op.drop_column("url_cover")
|
||||
batch_op.alter_column(
|
||||
"r_name",
|
||||
new_column_name="name",
|
||||
type_=sa.String(length=150),
|
||||
existing_type=sa.String(length=150),
|
||||
)
|
||||
batch_op.alter_column(
|
||||
"p_slug", existing_type=sa.String(length=50), nullable=False
|
||||
)
|
||||
batch_op.alter_column(
|
||||
"file_name", existing_type=sa.String(length=450), nullable=False
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
@@ -27,12 +27,23 @@ DEFAULT_URL_COVER_S: str = (
|
||||
)
|
||||
DEFAULT_PATH_COVER_S: str = "default/default/cover/small.png"
|
||||
|
||||
# MARIADB
|
||||
DB_HOST = os.environ.get("DB_HOST", "127.0.0.1")
|
||||
DB_PORT: int = int(os.environ.get("DB_PORT", 3306))
|
||||
DB_USER = os.environ.get("DB_USER")
|
||||
DB_PASSWD = os.environ.get("DB_PASSWD")
|
||||
DB_NAME = os.environ.get("DB_NAME", "romm")
|
||||
|
||||
# REDIS
|
||||
REDIS_HOST = os.environ.get('REDIS_HOST', 'localhost')
|
||||
REDIS_PORT = os.environ.get('REDIS_PORT', '6379')
|
||||
|
||||
# IGDB
|
||||
CLIENT_ID: str = os.environ.get("CLIENT_ID")
|
||||
CLIENT_SECRET: str = os.environ.get("CLIENT_SECRET")
|
||||
CLIENT_ID = os.environ.get("CLIENT_ID", "")
|
||||
CLIENT_SECRET = os.environ.get("CLIENT_SECRET", "")
|
||||
|
||||
# STEAMGRIDDB
|
||||
STEAMGRIDDB_API_KEY: str = os.environ.get("STEAMGRIDDB_API_KEY")
|
||||
STEAMGRIDDB_API_KEY = os.environ.get("STEAMGRIDDB_API_KEY", "")
|
||||
|
||||
# DB DRIVERS
|
||||
SUPPORTED_DB_DRIVERS: list = ["sqlite", "mariadb"]
|
||||
ROMM_DB_DRIVER: str = os.environ.get("ROMM_DB_DRIVER", "sqlite")
|
||||
ROMM_DB_DRIVER = os.environ.get("ROMM_DB_DRIVER", "sqlite")
|
||||
|
||||
@@ -1,109 +1,78 @@
|
||||
import os
|
||||
import sys
|
||||
import yaml
|
||||
import pydash
|
||||
from yaml.loader import SafeLoader
|
||||
from urllib.parse import quote_plus
|
||||
|
||||
from config import (
|
||||
ROMM_DB_DRIVER,
|
||||
SUPPORTED_DB_DRIVERS,
|
||||
SQLITE_DB_BASE_PATH,
|
||||
ROMM_USER_CONFIG_PATH,
|
||||
DB_HOST,
|
||||
DB_PORT,
|
||||
DB_USER,
|
||||
DB_PASSWD,
|
||||
DB_NAME,
|
||||
)
|
||||
from logger.logger import log
|
||||
|
||||
|
||||
class ConfigLoader:
|
||||
def __init__(self):
|
||||
# Tests require custom config path
|
||||
def __init__(self, config_path: str = ROMM_USER_CONFIG_PATH):
|
||||
try:
|
||||
with open(ROMM_USER_CONFIG_PATH) as config_file:
|
||||
self.config: dict = yaml.load(config_file, Loader=SafeLoader) or {}
|
||||
with open(config_path) as config_file:
|
||||
self.config = yaml.load(config_file, Loader=SafeLoader) or {}
|
||||
except FileNotFoundError:
|
||||
self.config: dict = {}
|
||||
self._parse_config()
|
||||
self.config = {}
|
||||
finally:
|
||||
self._parse_config()
|
||||
|
||||
@staticmethod
|
||||
def get_db_engine():
|
||||
if ROMM_DB_DRIVER in SUPPORTED_DB_DRIVERS:
|
||||
if ROMM_DB_DRIVER == "mariadb":
|
||||
DB_HOST: str = os.environ.get("DB_HOST")
|
||||
try:
|
||||
DB_PORT: int = int(os.environ.get("DB_PORT"))
|
||||
except TypeError:
|
||||
log.critical("DB_PORT variable not set properly")
|
||||
sys.exit(3)
|
||||
DB_USER: str = os.environ.get("DB_USER")
|
||||
DB_PASSWD: str = os.environ.get("DB_PASSWD")
|
||||
DB_NAME: str = os.environ.get("DB_NAME", "romm")
|
||||
|
||||
return (
|
||||
f"mariadb+mariadbconnector://{DB_USER}:%s@{DB_HOST}:{DB_PORT}/{DB_NAME}"
|
||||
% quote_plus(DB_PASSWD)
|
||||
def get_db_engine() -> str:
|
||||
if ROMM_DB_DRIVER == "mariadb":
|
||||
if not DB_USER or not DB_PASSWD:
|
||||
log.critical(
|
||||
"Missing database credentials. Please check your configuration file"
|
||||
)
|
||||
sys.exit(3)
|
||||
|
||||
elif ROMM_DB_DRIVER == "sqlite":
|
||||
if not os.path.exists(SQLITE_DB_BASE_PATH):
|
||||
os.makedirs(SQLITE_DB_BASE_PATH)
|
||||
return f"sqlite:////{SQLITE_DB_BASE_PATH}/romm.db"
|
||||
return (
|
||||
f"mariadb+mariadbconnector://{DB_USER}:%s@{DB_HOST}:{DB_PORT}/{DB_NAME}"
|
||||
% quote_plus(DB_PASSWD)
|
||||
)
|
||||
|
||||
else:
|
||||
log.critical(f"{ROMM_DB_DRIVER} database not supported")
|
||||
sys.exit(3)
|
||||
if ROMM_DB_DRIVER == "sqlite":
|
||||
if not os.path.exists(SQLITE_DB_BASE_PATH):
|
||||
os.makedirs(SQLITE_DB_BASE_PATH)
|
||||
return f"sqlite:////{SQLITE_DB_BASE_PATH}/romm.db"
|
||||
|
||||
def _parse_config(self) -> dict:
|
||||
try:
|
||||
self.config["EXCLUDED_PLATFORMS"] = (
|
||||
self.config["exclude"]["platforms"]
|
||||
if self.config["exclude"]["platforms"]
|
||||
else []
|
||||
)
|
||||
except (KeyError, TypeError):
|
||||
self.config["EXCLUDED_PLATFORMS"] = []
|
||||
try:
|
||||
self.config["EXCLUDED_SINGLE_EXT"] = (
|
||||
self.config["exclude"]["roms"]["single_file"]["extensions"]
|
||||
if self.config["exclude"]["roms"]["single_file"]["extensions"]
|
||||
else []
|
||||
)
|
||||
except (KeyError, TypeError):
|
||||
self.config["EXCLUDED_SINGLE_EXT"] = []
|
||||
try:
|
||||
self.config["EXCLUDED_SINGLE_FILES"] = (
|
||||
self.config["exclude"]["roms"]["single_file"]["names"]
|
||||
if self.config["exclude"]["roms"]["single_file"]["names"]
|
||||
else []
|
||||
)
|
||||
except (KeyError, TypeError):
|
||||
self.config["EXCLUDED_SINGLE_FILES"] = []
|
||||
try:
|
||||
self.config["EXCLUDED_MULTI_FILES"] = (
|
||||
self.config["exclude"]["roms"]["multi_file"]["names"]
|
||||
if self.config["exclude"]["roms"]["multi_file"]["names"]
|
||||
else []
|
||||
)
|
||||
except (KeyError, TypeError):
|
||||
self.config["EXCLUDED_MULTI_FILES"] = []
|
||||
try:
|
||||
self.config["EXCLUDED_MULTI_PARTS_EXT"] = (
|
||||
self.config["exclude"]["roms"]["multi_file"]["parts"]["extensions"]
|
||||
if self.config["exclude"]["roms"]["multi_file"]["parts"]["extensions"]
|
||||
else []
|
||||
)
|
||||
except (KeyError, TypeError):
|
||||
self.config["EXCLUDED_MULTI_PARTS_EXT"] = []
|
||||
try:
|
||||
self.config["EXCLUDED_MULTI_PARTS_FILES"] = (
|
||||
self.config["exclude"]["roms"]["multi_file"]["parts"]["names"]
|
||||
if self.config["exclude"]["roms"]["multi_file"]["parts"]["names"]
|
||||
else []
|
||||
)
|
||||
except (KeyError, TypeError):
|
||||
self.config["EXCLUDED_MULTI_PARTS_FILES"] = []
|
||||
try:
|
||||
self.config["PLATFORMS_BINDING"] = (
|
||||
self.config["system"]["platforms"]
|
||||
if self.config["system"]["platforms"]
|
||||
else {}
|
||||
)
|
||||
except (KeyError, TypeError):
|
||||
self.config["PLATFORMS_BINDING"] = {}
|
||||
log.critical(f"{ROMM_DB_DRIVER} database not supported")
|
||||
sys.exit(3)
|
||||
|
||||
def _parse_config(self):
|
||||
self.config["EXCLUDED_PLATFORMS"] = pydash.get(
|
||||
self.config, "exclude.platforms", []
|
||||
)
|
||||
self.config["EXCLUDED_SINGLE_EXT"] = pydash.get(
|
||||
self.config, "exclude.roms.single_file.extensions", []
|
||||
)
|
||||
self.config["EXCLUDED_SINGLE_FILES"] = pydash.get(
|
||||
self.config, "exclude.roms.single_file.names", []
|
||||
)
|
||||
self.config["EXCLUDED_MULTI_FILES"] = pydash.get(
|
||||
self.config, "exclude.roms.multi_file.names", []
|
||||
)
|
||||
self.config["EXCLUDED_MULTI_PARTS_EXT"] = pydash.get(
|
||||
self.config, "exclude.roms.multi_file.parts.extensions", []
|
||||
)
|
||||
self.config["EXCLUDED_MULTI_PARTS_FILES"] = pydash.get(
|
||||
self.config, "exclude.roms.multi_file.parts.names", []
|
||||
)
|
||||
self.config["PLATFORMS_BINDING"] = pydash.get(
|
||||
self.config, "system.platforms", {}
|
||||
)
|
||||
|
||||
|
||||
config = ConfigLoader().config
|
||||
|
||||
0
backend/config/tests/__init__.py
Normal file
0
backend/config/tests/__init__.py
Normal file
25
backend/config/tests/fixtures/config.yml
vendored
Normal file
25
backend/config/tests/fixtures/config.yml
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
# Example config file used only for testing
|
||||
# Refer to examples/config.example.yml for a more detailed config file
|
||||
|
||||
exclude:
|
||||
platforms:
|
||||
- 'romm'
|
||||
roms:
|
||||
single_file:
|
||||
names:
|
||||
- 'info.txt'
|
||||
extensions:
|
||||
- 'xml'
|
||||
|
||||
multi_file:
|
||||
names:
|
||||
- 'my_multi_file_game'
|
||||
- 'DLC'
|
||||
parts:
|
||||
names:
|
||||
- 'data.xml'
|
||||
extensions:
|
||||
- 'txt'
|
||||
system:
|
||||
platforms:
|
||||
gc: 'ngc'
|
||||
30
backend/config/tests/test_config_loader.py
Normal file
30
backend/config/tests/test_config_loader.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from config.config_loader import ConfigLoader
|
||||
|
||||
|
||||
def test_config_loader():
|
||||
loader = ConfigLoader(
|
||||
os.path.join(Path(__file__).resolve().parent, "fixtures", "config.yml")
|
||||
)
|
||||
|
||||
assert loader.config["EXCLUDED_PLATFORMS"] == ["romm"]
|
||||
assert loader.config["EXCLUDED_SINGLE_EXT"] == ["xml"]
|
||||
assert loader.config["EXCLUDED_SINGLE_FILES"] == ["info.txt"]
|
||||
assert loader.config["EXCLUDED_MULTI_FILES"] == ["my_multi_file_game", "DLC"]
|
||||
assert loader.config["EXCLUDED_MULTI_PARTS_EXT"] == ["txt"]
|
||||
assert loader.config["EXCLUDED_MULTI_PARTS_FILES"] == ["data.xml"]
|
||||
assert loader.config["PLATFORMS_BINDING"] == {"gc": "ngc"}
|
||||
|
||||
|
||||
def test_empty_config_loader():
|
||||
loader = ConfigLoader("")
|
||||
|
||||
assert loader.config.get("EXCLUDED_PLATFORMS") == []
|
||||
assert loader.config.get("EXCLUDED_SINGLE_EXT") == []
|
||||
assert loader.config.get("EXCLUDED_SINGLE_FILES") == []
|
||||
assert loader.config.get("EXCLUDED_MULTI_FILES") == []
|
||||
assert loader.config.get("EXCLUDED_MULTI_PARTS_EXT") == []
|
||||
assert loader.config.get("EXCLUDED_MULTI_PARTS_FILES") == []
|
||||
assert loader.config.get("PLATFORMS_BINDING") == {}
|
||||
0
backend/endpoints/__init__.py
Normal file
0
backend/endpoints/__init__.py
Normal file
@@ -1,12 +1,28 @@
|
||||
from fastapi import APIRouter
|
||||
from pydantic import BaseModel, BaseConfig
|
||||
|
||||
from handler import dbh
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/platforms", status_code=200)
|
||||
def platforms():
|
||||
"""Returns platforms data"""
|
||||
class PlatformSchema(BaseModel):
|
||||
igdb_id: str
|
||||
sgdb_id: str
|
||||
|
||||
slug: str
|
||||
name: str
|
||||
|
||||
logo_path: str
|
||||
fs_slug: str
|
||||
|
||||
n_roms: int
|
||||
|
||||
class Config(BaseConfig):
|
||||
orm_mode = True
|
||||
|
||||
|
||||
@router.get("/platforms", status_code=200)
|
||||
def platforms() -> list[PlatformSchema]:
|
||||
"""Returns platforms data"""
|
||||
return dbh.get_platforms()
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import io
|
||||
import tempfile
|
||||
import zipfile
|
||||
from datetime import datetime
|
||||
from fastapi import APIRouter, Request, status, HTTPException
|
||||
from fastapi_pagination.ext.sqlalchemy import paginate
|
||||
from fastapi_pagination.cursor import CursorPage, CursorParams
|
||||
from fastapi.responses import FileResponse
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, BaseConfig
|
||||
|
||||
from stat import S_IFREG
|
||||
from stream_zip import ZIP_64, stream_zip
|
||||
|
||||
from logger.logger import log
|
||||
from handler import dbh
|
||||
@@ -15,6 +16,8 @@ from models.rom import Rom
|
||||
from models.platform import Platform
|
||||
from config import LIBRARY_BASE_PATH
|
||||
|
||||
from .utils import CustomStreamingResponse
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@@ -59,7 +62,7 @@ class RomSchema(BaseModel):
|
||||
full_path: str
|
||||
download_path: str
|
||||
|
||||
class Config(BaseModel.Config):
|
||||
class Config(BaseConfig):
|
||||
orm_mode = True
|
||||
|
||||
|
||||
@@ -76,31 +79,29 @@ def download_rom(id: int, files: str):
|
||||
rom_path = f"{LIBRARY_BASE_PATH}/{rom.full_path}"
|
||||
|
||||
if not rom.multi:
|
||||
return FileResponse(
|
||||
path=rom_path,
|
||||
filename=rom.file_name,
|
||||
media_type="application/octet-stream",
|
||||
)
|
||||
return FileResponse(path=rom_path, filename=rom.file_name)
|
||||
|
||||
mf = io.BytesIO()
|
||||
with zipfile.ZipFile(mf, mode="w", compression=zipfile.ZIP_DEFLATED) as zf:
|
||||
try:
|
||||
for file_name in files.split(","):
|
||||
zf.write(f"{rom_path}/{file_name}", file_name)
|
||||
except FileNotFoundError as e:
|
||||
log.error(str(e))
|
||||
finally:
|
||||
zf.close()
|
||||
# Builds a generator of tuples for each member file
|
||||
def local_files():
|
||||
def contents(file_name):
|
||||
with open(f"{rom_path}/{file_name}", "rb") as f:
|
||||
while chunk := f.read(65536):
|
||||
yield chunk
|
||||
|
||||
tmp = tempfile.NamedTemporaryFile(delete=False)
|
||||
with open(tmp.name, "wb") as f:
|
||||
f.write(mf.getvalue())
|
||||
return [
|
||||
(file_name, datetime.now(), S_IFREG | 0o600, ZIP_64, contents(file_name))
|
||||
for file_name in files.split(",")
|
||||
]
|
||||
|
||||
return FileResponse(
|
||||
path=tmp.name,
|
||||
filename=f"{rom.r_name}.zip",
|
||||
media_type="application/octet-stream",
|
||||
)
|
||||
zipped_chunks = stream_zip(local_files())
|
||||
|
||||
# Streams the zip file to the client
|
||||
return CustomStreamingResponse(
|
||||
zipped_chunks,
|
||||
media_type="application/zip",
|
||||
headers={"Content-Disposition": f"attachment; filename={rom.r_name}.zip"},
|
||||
emit_body={"id": rom.id},
|
||||
)
|
||||
|
||||
|
||||
@router.get("/platforms/{p_slug}/roms", status_code=200)
|
||||
@@ -143,9 +144,20 @@ async def updateRom(req: Request, p_slug: str, id: int) -> dict:
|
||||
)
|
||||
|
||||
updated_rom["file_name_no_tags"] = get_file_name_with_no_tags(file_name)
|
||||
updated_rom.update(fs.get_cover(True, p_slug, file_name, updated_rom["url_cover"]))
|
||||
updated_rom.update(
|
||||
fs.get_screenshots(p_slug, file_name, updated_rom["url_screenshots"]),
|
||||
fs.get_cover(
|
||||
overwrite=True,
|
||||
p_slug=platform.slug,
|
||||
r_name=updated_rom["file_name_no_tags"],
|
||||
url_cover=updated_rom["url_cover"],
|
||||
)
|
||||
)
|
||||
updated_rom.update(
|
||||
fs.get_screenshots(
|
||||
p_slug=platform.slug,
|
||||
r_name=updated_rom["file_name_no_tags"],
|
||||
url_screenshots=updated_rom["url_screenshots"],
|
||||
),
|
||||
)
|
||||
dbh.update_rom(id, updated_rom)
|
||||
|
||||
@@ -162,6 +174,7 @@ def delete_rom(p_slug: str, id: int, filesystem: bool = False) -> dict:
|
||||
rom: Rom = dbh.get_rom(id)
|
||||
log.info(f"Deleting {rom.file_name} from database")
|
||||
dbh.delete_rom(id)
|
||||
dbh.update_n_roms(p_slug)
|
||||
|
||||
if filesystem:
|
||||
log.info(f"Deleting {rom.file_name} from filesystem")
|
||||
|
||||
@@ -1,66 +1,88 @@
|
||||
import json
|
||||
import emoji
|
||||
import socketio # type: ignore
|
||||
from rq import Queue
|
||||
|
||||
from logger.logger import log
|
||||
from utils import fs, fastapi
|
||||
from utils.exceptions import PlatformsNotFoundException, RomsNotFoundException
|
||||
from handler import dbh
|
||||
from models.platform import Platform
|
||||
from models.rom import Rom
|
||||
from utils.socket import socket_server
|
||||
from utils.cache import redis_client, redis_url, redis_connectable
|
||||
|
||||
scan_queue = Queue(connection=redis_client)
|
||||
|
||||
|
||||
async def scan(_sid: str, platforms: str, complete_rescan: bool = True, sm = None):
|
||||
"""Scan platforms and roms and write them in database."""
|
||||
async def scan_platforms(paltforms: str, complete_rescan: bool):
|
||||
# Connect to external socketio server
|
||||
sm = (
|
||||
socketio.AsyncRedisManager(redis_url, write_only=True)
|
||||
if redis_connectable
|
||||
else socket_server
|
||||
)
|
||||
|
||||
log.info(emoji.emojize(":magnifying_glass_tilted_right: Scanning "))
|
||||
fs.store_default_resources()
|
||||
|
||||
try: # Scanning platforms
|
||||
# Scanning file system
|
||||
try:
|
||||
fs_platforms: list[str] = fs.get_platforms()
|
||||
except PlatformsNotFoundException as e:
|
||||
log.error(e)
|
||||
await sm.emit("scan:done_ko", e.message)
|
||||
return
|
||||
|
||||
platforms: list[str] = (
|
||||
json.loads(platforms) if len(json.loads(platforms)) > 0 else fs_platforms
|
||||
)
|
||||
log.info(f"Platforms to be scanned: {', '.join(platforms)}")
|
||||
for platform in platforms:
|
||||
log.info(emoji.emojize(f":video_game: {platform}"))
|
||||
platform_list = paltforms.split(",") if paltforms else fs_platforms
|
||||
for p_slug in platform_list:
|
||||
try:
|
||||
scanned_platform: Platform = fastapi.scan_platform(platform)
|
||||
# Verify that platform exists
|
||||
scanned_platform = fastapi.scan_platform(p_slug)
|
||||
except RomsNotFoundException as e:
|
||||
log.error(e)
|
||||
continue
|
||||
|
||||
await sm.emit(
|
||||
"scan:scanning_platform", [scanned_platform.name, scanned_platform.slug]
|
||||
"scan:scanning_platform",
|
||||
{"p_name": scanned_platform.name, "p_slug": scanned_platform.slug},
|
||||
)
|
||||
await sm.emit("") # Workaround to emit in real-time
|
||||
if platform != str(scanned_platform):
|
||||
log.info(
|
||||
f"Identified as {scanned_platform}"
|
||||
)
|
||||
|
||||
dbh.add_platform(scanned_platform)
|
||||
|
||||
# Scanning roms
|
||||
fs_roms: list[str] = fs.get_roms(scanned_platform.fs_slug)
|
||||
fs_roms = fs.get_roms(scanned_platform.fs_slug)
|
||||
for rom in fs_roms:
|
||||
rom_id: int = dbh.rom_exists(scanned_platform.slug, rom["file_name"])
|
||||
rom_id = dbh.rom_exists(scanned_platform.slug, rom["file_name"])
|
||||
if rom_id and not complete_rescan:
|
||||
continue
|
||||
await sm.emit("scan:scanning_rom", rom["file_name"])
|
||||
await sm.emit("") # Workaround to emit in real-time
|
||||
log.info(f"\t - {rom['file_name']}")
|
||||
if rom["multi"]:
|
||||
[
|
||||
log.info(f"\t\t · {file}")
|
||||
for file in rom["files"]
|
||||
]
|
||||
scanned_rom: Rom = fastapi.scan_rom(scanned_platform, rom)
|
||||
|
||||
scanned_rom = fastapi.scan_rom(scanned_platform, rom)
|
||||
await sm.emit(
|
||||
"scan:scanning_rom",
|
||||
{
|
||||
"p_slug": scanned_platform.slug,
|
||||
"p_name": scanned_platform.name,
|
||||
"file_name": scanned_rom.file_name,
|
||||
"r_name": scanned_rom.r_name,
|
||||
"r_igdb_id": scanned_rom.r_igdb_id,
|
||||
},
|
||||
)
|
||||
|
||||
if rom_id:
|
||||
scanned_rom.id = rom_id
|
||||
|
||||
dbh.add_rom(scanned_rom)
|
||||
dbh.purge_roms(scanned_platform.slug, [rom["file_name"] for rom in fs_roms])
|
||||
dbh.update_n_roms(scanned_platform.slug)
|
||||
dbh.purge_platforms(fs_platforms)
|
||||
await sm.emit("scan:done")
|
||||
|
||||
await sm.emit("scan:done", {})
|
||||
|
||||
|
||||
@socket_server.on("scan")
|
||||
async def scan_handler(_sid: str, platforms: str, complete_rescan: bool = True):
|
||||
"""Scan platforms and roms and write them in database."""
|
||||
|
||||
log.info(emoji.emojize(":magnifying_glass_tilted_right: Scanning "))
|
||||
fs.store_default_resources()
|
||||
|
||||
# Run in worker if redis is available
|
||||
if redis_connectable:
|
||||
return scan_queue.enqueue(scan_platforms, platforms, complete_rescan)
|
||||
else:
|
||||
await scan_platforms(platforms, complete_rescan)
|
||||
|
||||
@@ -18,27 +18,15 @@ async def search_rom_igdb(
|
||||
log.info(emoji.emojize(":magnifying_glass_tilted_right: IGDB Searching"))
|
||||
matched_roms: list = []
|
||||
|
||||
if search_term:
|
||||
log.info(f"Searching by {search_by}: {search_term}")
|
||||
if search_by.lower() == "id":
|
||||
matched_roms = igdbh.get_matched_rom_by_id(search_term)
|
||||
elif search_by.lower() == "name":
|
||||
matched_roms = igdbh.get_matched_roms_by_name(search_term, rom["p_igdb_id"])
|
||||
else:
|
||||
log.info(
|
||||
emoji.emojize(
|
||||
f":video_game: {rom['p_slug']}: {rom['file_name']}"
|
||||
)
|
||||
)
|
||||
matched_roms = igdbh.get_matched_roms(
|
||||
rom["file_name"], rom["p_igdb_id"], rom["p_slug"]
|
||||
)
|
||||
log.info(f"Searching by {search_by}: {search_term}")
|
||||
log.info(emoji.emojize(f":video_game: {rom['p_slug']}: {rom['file_name']}"))
|
||||
if search_by.lower() == "id":
|
||||
matched_roms = igdbh.get_matched_roms_by_id(int(search_term))
|
||||
elif search_by.lower() == "name":
|
||||
matched_roms = igdbh.get_matched_roms_by_name(search_term, rom["p_igdb_id"])
|
||||
|
||||
log.info("Results:")
|
||||
|
||||
[
|
||||
for rom in matched_roms:
|
||||
log.info(f"\t - {rom['r_name']}")
|
||||
for rom in matched_roms
|
||||
]
|
||||
|
||||
return {"roms": matched_roms, "msg": "success"}
|
||||
|
||||
13
backend/endpoints/utils.py
Normal file
13
backend/endpoints/utils.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from fastapi.responses import StreamingResponse
|
||||
|
||||
from utils.socket import socket_server
|
||||
|
||||
|
||||
class CustomStreamingResponse(StreamingResponse):
|
||||
def __init__(self, *args, **kwargs) -> None:
|
||||
self.emit_body = kwargs.pop("emit_body", None)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
async def stream_response(self, *args, **kwargs) -> None:
|
||||
await super().stream_response(*args, **kwargs)
|
||||
await socket_server.emit("download:complete", self.emit_body)
|
||||
@@ -1,8 +1,7 @@
|
||||
from handler.db_handler import DBHandler
|
||||
from handler.igdb_handler import IGDBHandler
|
||||
from handler.sgdb_handler import SGDBHandler
|
||||
from config.config_loader import ConfigLoader
|
||||
|
||||
igdbh: IGDBHandler = IGDBHandler()
|
||||
sgdbh: SGDBHandler = SGDBHandler()
|
||||
dbh: DBHandler = DBHandler(ConfigLoader())
|
||||
dbh: DBHandler = DBHandler()
|
||||
|
||||
@@ -12,11 +12,12 @@ from models.rom import Rom
|
||||
|
||||
|
||||
class DBHandler:
|
||||
def __init__(self, cl: ConfigLoader) -> None:
|
||||
self.engine = create_engine(cl.get_db_engine(), pool_pre_ping=True)
|
||||
def __init__(self) -> None:
|
||||
self.engine = create_engine(ConfigLoader.get_db_engine(), pool_pre_ping=True)
|
||||
self.session = sessionmaker(bind=self.engine, expire_on_commit=False)
|
||||
|
||||
def retry(func) -> tuple:
|
||||
@staticmethod
|
||||
def retry(func):
|
||||
@functools.wraps(func)
|
||||
def wrapper(*args):
|
||||
return func(*args)
|
||||
@@ -24,21 +25,21 @@ class DBHandler:
|
||||
return wrapper
|
||||
|
||||
@staticmethod
|
||||
def raise_error(e: Exception) -> None:
|
||||
def raise_error(e: Exception):
|
||||
log.critical(str(e))
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=str(e)
|
||||
)
|
||||
|
||||
# ========= Platforms =========
|
||||
def add_platform(self, Platform: Platform) -> None:
|
||||
def add_platform(self, platform: Platform):
|
||||
try:
|
||||
with self.session.begin() as session:
|
||||
session.merge(Platform)
|
||||
session.merge(platform)
|
||||
except ProgrammingError as e:
|
||||
self.raise_error(e)
|
||||
|
||||
def get_platforms(self) -> list[Platform]:
|
||||
def get_platforms(self):
|
||||
try:
|
||||
with self.session.begin() as session:
|
||||
return session.scalars(
|
||||
@@ -47,14 +48,14 @@ class DBHandler:
|
||||
except ProgrammingError as e:
|
||||
self.raise_error(e)
|
||||
|
||||
def get_platform(self, slug: str) -> Platform:
|
||||
def get_platform(self, slug: str):
|
||||
try:
|
||||
with self.session.begin() as session:
|
||||
return session.scalars(select(Platform).filter_by(slug=slug)).first()
|
||||
except ProgrammingError as e:
|
||||
self.raise_error(e)
|
||||
|
||||
def purge_platforms(self, platforms: list[str]) -> None:
|
||||
def purge_platforms(self, platforms: list[str]):
|
||||
try:
|
||||
with self.session.begin() as session:
|
||||
session.query(Platform).filter(
|
||||
@@ -64,27 +65,27 @@ class DBHandler:
|
||||
self.raise_error(e)
|
||||
|
||||
# ========= Roms =========
|
||||
def add_rom(self, rom: Rom) -> None:
|
||||
def add_rom(self, rom: Rom):
|
||||
try:
|
||||
with self.session.begin() as session:
|
||||
session.merge(rom)
|
||||
except ProgrammingError as e:
|
||||
self.raise_error(e)
|
||||
|
||||
def get_roms(self, p_slug: str) -> list[Rom]:
|
||||
def get_roms(self, p_slug: str):
|
||||
try:
|
||||
return select(Rom).filter_by(p_slug=p_slug).order_by(Rom.file_name.asc())
|
||||
except ProgrammingError as e:
|
||||
self.raise_error(e)
|
||||
|
||||
def get_rom(self, id) -> Rom:
|
||||
def get_rom(self, id):
|
||||
try:
|
||||
with self.session.begin() as session:
|
||||
return session.query(Rom).get(id)
|
||||
return session.get(Rom, id)
|
||||
except ProgrammingError as e:
|
||||
self.raise_error(e)
|
||||
|
||||
def update_rom(self, id: int, data: dict) -> None:
|
||||
def update_rom(self, id: int, data: dict):
|
||||
try:
|
||||
with self.session.begin() as session:
|
||||
session.query(Rom).filter(Rom.id == id).update(
|
||||
@@ -93,7 +94,7 @@ class DBHandler:
|
||||
except ProgrammingError as e:
|
||||
self.raise_error(e)
|
||||
|
||||
def delete_rom(self, id: int) -> None:
|
||||
def delete_rom(self, id: int):
|
||||
try:
|
||||
with self.session.begin() as session:
|
||||
session.query(Rom).filter(Rom.id == id).delete(
|
||||
@@ -102,7 +103,7 @@ class DBHandler:
|
||||
except ProgrammingError as e:
|
||||
self.raise_error(e)
|
||||
|
||||
def purge_roms(self, p_slug: str, roms: list[str]) -> None:
|
||||
def purge_roms(self, p_slug: str, roms: list[list[str]]):
|
||||
try:
|
||||
with self.session.begin() as session:
|
||||
session.query(Rom).filter(
|
||||
@@ -111,13 +112,27 @@ class DBHandler:
|
||||
except ProgrammingError as e:
|
||||
self.raise_error(e)
|
||||
|
||||
def update_n_roms(self, p_slug: str):
|
||||
try:
|
||||
with self.session.begin() as session:
|
||||
session.query(Platform).filter_by(slug=p_slug).update(
|
||||
{
|
||||
Platform.n_roms: len(
|
||||
session.query(Rom).filter_by(p_slug=p_slug).all()
|
||||
)
|
||||
},
|
||||
synchronize_session="evaluate",
|
||||
)
|
||||
except ProgrammingError as e:
|
||||
self.raise_error(e)
|
||||
|
||||
# ==== Utils ======
|
||||
def rom_exists(self, platform: str, file_name: str) -> int:
|
||||
def rom_exists(self, p_slug: str, file_name: str):
|
||||
try:
|
||||
with self.session.begin() as session:
|
||||
rom = session.scalar(
|
||||
select(Rom).filter_by(p_slug=platform, file_name=file_name)
|
||||
select(Rom).filter_by(p_slug=p_slug, file_name=file_name)
|
||||
)
|
||||
return rom.id if rom else None
|
||||
return rom.id if rom else 0
|
||||
except ProgrammingError as e:
|
||||
self.raise_error(e)
|
||||
|
||||
@@ -1,212 +1,247 @@
|
||||
import sys
|
||||
import functools
|
||||
from time import time
|
||||
from unidecode import unidecode as uc
|
||||
|
||||
import pydash
|
||||
import requests
|
||||
import re
|
||||
import time
|
||||
from unidecode import unidecode as uc
|
||||
from requests.exceptions import HTTPError, Timeout
|
||||
from typing import Optional
|
||||
|
||||
from config import CLIENT_ID, CLIENT_SECRET
|
||||
from utils import get_file_name_with_no_tags as get_search_term
|
||||
from logger.logger import log
|
||||
from utils.cache import cache
|
||||
from .ps2_opl_index import opl_index
|
||||
|
||||
MAIN_GAME_CATEGORY = 0
|
||||
EXPANDED_GAME_CATEGORY = 10
|
||||
|
||||
N_SCREENSHOTS = 5
|
||||
|
||||
ps2_opl_regex = r"^([A-Z]{4}_\d{3}\.\d{2})\..*$"
|
||||
PS2_IGDB_ID = 8
|
||||
|
||||
|
||||
class IGDBHandler():
|
||||
|
||||
class IGDBHandler:
|
||||
def __init__(self) -> None:
|
||||
base_url: str = 'https://api.igdb.com/v4'
|
||||
self.platform_url: str = f'{base_url}/platforms/'
|
||||
self.games_url: str = f'{base_url}/games/'
|
||||
self.covers_url: str = f'{base_url}/covers/'
|
||||
self.screenshots_url: str = f'{base_url}/screenshots/'
|
||||
self.twitch_auth: TwitchAuth = TwitchAuth()
|
||||
self.platform_url = "https://api.igdb.com/v4/platforms/"
|
||||
self.games_url = "https://api.igdb.com/v4/games/"
|
||||
self.covers_url = "https://api.igdb.com/v4/covers/"
|
||||
self.screenshots_url = "https://api.igdb.com/v4/screenshots/"
|
||||
self.twitch_auth = TwitchAuth()
|
||||
self.headers = {
|
||||
'Client-ID': self.twitch_auth.client_id,
|
||||
'Authorization': f'Bearer {self.twitch_auth.get_oauth_token()}',
|
||||
'Accept': 'application/json'
|
||||
"Client-ID": CLIENT_ID,
|
||||
"Authorization": f"Bearer {self.twitch_auth.get_oauth_token()}",
|
||||
"Accept": "application/json",
|
||||
}
|
||||
|
||||
|
||||
def check_twitch_token(func) -> tuple:
|
||||
@staticmethod
|
||||
def check_twitch_token(func):
|
||||
@functools.wraps(func)
|
||||
def wrapper(*args):
|
||||
args[0].headers['Authorization'] = f'Bearer {args[0].twitch_auth.get_oauth_token()}'
|
||||
args[0].headers[
|
||||
"Authorization"
|
||||
] = f"Bearer {args[0].twitch_auth.get_oauth_token()}"
|
||||
return func(*args)
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
def _search_rom(self, search_term: str, p_igdb_id: int, category: int = None) -> dict:
|
||||
category_filter: str = f"& category={category}" if category else ""
|
||||
def _request(self, url: str, data: str, timeout: int = 120) -> list:
|
||||
try:
|
||||
return requests.post(self.games_url,
|
||||
headers=self.headers,
|
||||
data=f"""search \"{search_term}\";
|
||||
fields id, slug, name, summary, screenshots;
|
||||
where platforms=[{p_igdb_id}] {category_filter};""",
|
||||
timeout=120).json()[0]
|
||||
except IndexError:
|
||||
return {}
|
||||
res = requests.post(url, data, headers=self.headers, timeout=timeout)
|
||||
res.raise_for_status()
|
||||
except (HTTPError, Timeout) as err:
|
||||
log.error(err)
|
||||
# All requests to the IGDB API return a list
|
||||
return []
|
||||
|
||||
return res.json()
|
||||
|
||||
def _search_rom(self, search_term: str, p_igdb_id: int, category: int = 0) -> dict:
|
||||
category_filter: str = f"& category={category}" if category else ""
|
||||
roms = self._request(
|
||||
self.games_url,
|
||||
data=f"""
|
||||
search "{search_term}";
|
||||
fields id, slug, name, summary, screenshots;
|
||||
where platforms=[{p_igdb_id}] {category_filter};
|
||||
""",
|
||||
)
|
||||
|
||||
return pydash.get(roms, "[0]", {})
|
||||
|
||||
@staticmethod
|
||||
def _normalize_cover_url(url: str) -> str:
|
||||
return f"https:{url.replace('https:', '')}"
|
||||
|
||||
def _search_cover(self, rom_id: int) -> str:
|
||||
covers = self._request(
|
||||
self.covers_url,
|
||||
data=f"fields url; where game={rom_id};",
|
||||
)
|
||||
|
||||
def _search_cover(self, rom_id: str) -> str:
|
||||
try:
|
||||
res: dict = requests.post(self.covers_url,
|
||||
headers=self.headers,
|
||||
data=f"fields url; where game={rom_id};",
|
||||
timeout=120).json()[0]
|
||||
except IndexError:
|
||||
return ""
|
||||
cover = pydash.get(covers, "[0]", None)
|
||||
return "" if not cover else self._normalize_cover_url(cover["url"])
|
||||
|
||||
return self._normalize_cover_url(res['url']) if 'url' in res.keys() else ""
|
||||
|
||||
|
||||
def _search_screenshots(self, rom_id: str) -> list:
|
||||
res: dict = requests.post(self.screenshots_url,
|
||||
headers=self.headers,
|
||||
data=f"fields url; where game={rom_id}; limit 5;",
|
||||
timeout=120).json()
|
||||
return [self._normalize_cover_url(r['url']).replace('t_thumb', 't_original')
|
||||
for r in res if 'url' in r.keys()]
|
||||
def _search_screenshots(self, rom_id: int) -> list:
|
||||
screenshots = self._request(
|
||||
self.screenshots_url,
|
||||
data=f"fields url; where game={rom_id}; limit {N_SCREENSHOTS};",
|
||||
)
|
||||
|
||||
return [
|
||||
self._normalize_cover_url(r["url"]).replace("t_thumb", "t_original")
|
||||
for r in screenshots
|
||||
if "url" in r.keys()
|
||||
]
|
||||
|
||||
@check_twitch_token
|
||||
def get_platform(self, slug: str) -> dict:
|
||||
igdb_id: str = ""
|
||||
name: str = slug
|
||||
try:
|
||||
res: dict = requests.post(self.platform_url,
|
||||
headers=self.headers,
|
||||
data=f"fields id, name; where slug=\"{slug.lower()}\";",
|
||||
timeout=120).json()[0]
|
||||
igdb_id = res['id']
|
||||
name = res['name']
|
||||
except IndexError:
|
||||
log.warning(f"{slug} not found in IGDB")
|
||||
return {'igdb_id': igdb_id, 'name': name, 'slug': slug, 'logo_path': ''}
|
||||
def get_platform(self, p_slug: str):
|
||||
paltforms = self._request(
|
||||
self.platform_url,
|
||||
data=f'fields id, name; where slug="{p_slug.lower()}";',
|
||||
)
|
||||
|
||||
platform = pydash.get(paltforms, "[0]", None)
|
||||
if not platform:
|
||||
return {
|
||||
"igdb_id": "",
|
||||
"name": p_slug,
|
||||
"slug": p_slug,
|
||||
}
|
||||
|
||||
return {
|
||||
"igdb_id": platform["id"],
|
||||
"name": platform["name"],
|
||||
"slug": p_slug,
|
||||
}
|
||||
|
||||
@check_twitch_token
|
||||
def get_rom(self, file_name: str, p_igdb_id: int) -> dict:
|
||||
search_term: str = uc(get_search_term(file_name))
|
||||
res = (self._search_rom(search_term, p_igdb_id, 0) or
|
||||
self._search_rom(search_term, p_igdb_id, 10) or
|
||||
self._search_rom(search_term, p_igdb_id))
|
||||
def get_rom(self, file_name: str, p_igdb_id: int):
|
||||
search_term = get_search_term(file_name)
|
||||
|
||||
r_igdb_id = res['id'] if 'id' in res.keys() else ""
|
||||
r_slug = res['slug'] if 'slug' in res.keys() else ""
|
||||
r_name = res['name'] if 'name' in res.keys() else search_term
|
||||
summary = res['summary'] if 'summary' in res.keys() else ""
|
||||
# Patch support for PS2 OPL filename format
|
||||
match = re.match(ps2_opl_regex, search_term)
|
||||
if p_igdb_id == PS2_IGDB_ID and match:
|
||||
serial_code = match.group(1)
|
||||
index_entry = opl_index.get(serial_code, None)
|
||||
if index_entry:
|
||||
search_term = index_entry["Name"] # type: ignore
|
||||
|
||||
if not r_igdb_id:
|
||||
log.warning(f"{r_name} not found in IGDB")
|
||||
res = (
|
||||
self._search_rom(uc(search_term), p_igdb_id, MAIN_GAME_CATEGORY)
|
||||
or self._search_rom(uc(search_term), p_igdb_id, EXPANDED_GAME_CATEGORY)
|
||||
or self._search_rom(uc(search_term), p_igdb_id)
|
||||
)
|
||||
|
||||
return {'r_igdb_id': r_igdb_id, 'r_slug': r_slug, 'r_name': r_name, 'summary': summary,
|
||||
'url_cover': self._search_cover(r_igdb_id),
|
||||
'url_screenshots': self._search_screenshots(r_igdb_id)}
|
||||
r_igdb_id = res.get("id", 0)
|
||||
r_slug = res.get("slug", "")
|
||||
r_name = res.get("name", search_term)
|
||||
summary = res.get("summary", "")
|
||||
|
||||
return {
|
||||
"r_igdb_id": r_igdb_id,
|
||||
"r_slug": r_slug,
|
||||
"r_name": r_name,
|
||||
"summary": summary,
|
||||
"url_cover": self._search_cover(r_igdb_id),
|
||||
"url_screenshots": self._search_screenshots(r_igdb_id),
|
||||
}
|
||||
|
||||
@check_twitch_token
|
||||
def get_rom_by_id(self, r_igdb_id: str) -> list:
|
||||
res = requests.post(self.games_url,
|
||||
headers=self.headers,
|
||||
data=f"fields slug, name, summary; where id={r_igdb_id};",
|
||||
timeout=120)
|
||||
if res.status_code == 200:
|
||||
rom: dict = res.json()[0]
|
||||
r_slug = rom['slug'] if 'slug' in rom.keys() else ""
|
||||
r_name = rom['name'] if 'name' in rom.keys() else ""
|
||||
summary = rom['summary'] if 'summary' in rom.keys() else ""
|
||||
return [{'r_igdb_id': r_igdb_id, 'r_slug': r_slug, 'r_name': r_name, 'summary': summary,
|
||||
'url_cover': self._search_cover(r_igdb_id),
|
||||
'url_screenshots': self._search_screenshots(r_igdb_id)}]
|
||||
return []
|
||||
def get_rom_by_id(self, r_igdb_id: int):
|
||||
roms = self._request(
|
||||
self.games_url,
|
||||
f"fields slug, name, summary; where id={r_igdb_id};",
|
||||
)
|
||||
rom = pydash.get(roms, "[0]", {})
|
||||
|
||||
return {
|
||||
"r_igdb_id": r_igdb_id,
|
||||
"r_slug": rom.get("slug", ""),
|
||||
"r_name": rom.get("name", ""),
|
||||
"summary": rom.get("summary", ""),
|
||||
"url_cover": self._search_cover(r_igdb_id),
|
||||
"url_screenshots": self._search_screenshots(r_igdb_id),
|
||||
}
|
||||
|
||||
@check_twitch_token
|
||||
def get_matched_rom_by_id(self, igdb_id: str) -> list:
|
||||
matched_roms: list = self.get_rom_by_id(igdb_id)
|
||||
for rom in matched_roms:
|
||||
rom['url_cover'] = rom['url_cover'].replace('t_thumb', 't_cover_big')
|
||||
rom['url_screenshots'] = self._search_screenshots(igdb_id)
|
||||
return matched_roms
|
||||
|
||||
def get_matched_roms_by_id(self, r_igdb_id: int):
|
||||
matched_rom = self.get_rom_by_id(r_igdb_id)
|
||||
matched_rom.update(
|
||||
url_cover=matched_rom["url_cover"].replace("t_thumb", "t_cover_big"),
|
||||
)
|
||||
return [matched_rom]
|
||||
|
||||
@check_twitch_token
|
||||
def get_matched_roms_by_name(self, search_term: str, p_igdb_id: int) -> list:
|
||||
matched_roms: list = requests.post(self.games_url, headers=self.headers,
|
||||
data=f"""search \"{uc(search_term)}\";
|
||||
fields id, slug, name, summary;
|
||||
where platforms=[{p_igdb_id}];""",
|
||||
timeout=120).json()
|
||||
for rom in matched_roms:
|
||||
rom['url_cover'] = self._search_cover(rom['id']).replace('t_thumb', 't_cover_big')
|
||||
rom['url_screenshots'] = self._search_screenshots(rom['id'])
|
||||
rom['r_igdb_id'] = rom.pop('id')
|
||||
rom['r_slug'] = rom.pop('slug')
|
||||
rom['r_name'] = rom.pop('name')
|
||||
return matched_roms
|
||||
def get_matched_roms_by_name(self, search_term: str, p_igdb_id: int):
|
||||
if not p_igdb_id:
|
||||
return []
|
||||
|
||||
matched_roms = self._request(
|
||||
self.games_url,
|
||||
data=f"""
|
||||
search "{uc(search_term)}";
|
||||
fields id, slug, name, summary;
|
||||
where platforms=[{p_igdb_id}];
|
||||
""",
|
||||
)
|
||||
|
||||
return [
|
||||
dict(
|
||||
rom,
|
||||
url_cover=self._search_cover(rom["id"]).replace(
|
||||
"t_thumb", "t_cover_big"
|
||||
),
|
||||
url_screenshots=self._search_screenshots(rom["id"]),
|
||||
r_igdb_id=rom.pop("id"),
|
||||
r_slug=rom.pop("slug"),
|
||||
r_name=rom.pop("name"),
|
||||
)
|
||||
for rom in matched_roms
|
||||
]
|
||||
|
||||
|
||||
@check_twitch_token
|
||||
def get_matched_roms(self, file_name: str, p_igdb_id: int, p_slug: str) -> list:
|
||||
if p_igdb_id:
|
||||
matched_roms: list = requests.post(self.games_url, headers=self.headers,
|
||||
data=f"""search \"{uc(get_search_term(file_name))}\";
|
||||
fields id, slug, name, summary;
|
||||
where platforms=[{p_igdb_id}];""",
|
||||
timeout=120).json()
|
||||
for rom in matched_roms:
|
||||
rom['url_cover'] = self._search_cover(rom['id']).replace('t_thumb', 't_cover_big')
|
||||
rom['url_screenshots'] = self._search_screenshots(rom['id'])
|
||||
rom['r_igdb_id'] = rom.pop('id')
|
||||
rom['r_slug'] = rom.pop('slug')
|
||||
rom['r_name'] = rom.pop('name')
|
||||
else:
|
||||
matched_roms: list[dict] = []
|
||||
log.warning(f"{p_slug} is not supported!")
|
||||
return matched_roms
|
||||
class TwitchAuth:
|
||||
def _update_twitch_token(self) -> str:
|
||||
res = requests.post(
|
||||
url="https://id.twitch.tv/oauth2/token",
|
||||
params={
|
||||
"client_id": CLIENT_ID,
|
||||
"client_secret": CLIENT_SECRET,
|
||||
"grant_type": "client_credentials",
|
||||
},
|
||||
timeout=30,
|
||||
).json()
|
||||
|
||||
|
||||
|
||||
class TwitchAuth():
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.base_url: str = 'https://id.twitch.tv/oauth2/token'
|
||||
self.token: str = ""
|
||||
self.token_checkout: int = int(time())
|
||||
self.secure_seconds_offset: int = 10 # seconds offset to avoid invalid token
|
||||
self.token_valid_seconds: int = 0
|
||||
self.client_id: str = CLIENT_ID
|
||||
self.client_secret: str = CLIENT_SECRET
|
||||
|
||||
|
||||
def _is_token_valid(self) -> bool:
|
||||
return True if int(time()) + self.secure_seconds_offset - self.token_checkout < self.token_valid_seconds else False
|
||||
|
||||
|
||||
def _update_twitch_token(self) -> None:
|
||||
res = requests.post(url=self.base_url,
|
||||
params={
|
||||
'client_id': self.client_id,
|
||||
'client_secret': self.client_secret,
|
||||
'grant_type': 'client_credentials'},
|
||||
timeout=30
|
||||
).json()
|
||||
self.token_checkout = int(time())
|
||||
try:
|
||||
self.token_valid_seconds = res['expires_in']
|
||||
self.token = res['access_token']
|
||||
log.info("Twitch token fetched!")
|
||||
except KeyError:
|
||||
log.error("Could not get twitch auth token: check client_id and client_secret")
|
||||
token = res.get("access_token", "")
|
||||
expires_in = res.get("expires_in", 0)
|
||||
if not token or expires_in == 0:
|
||||
log.error(
|
||||
"Could not get twitch auth token: check client_id and client_secret"
|
||||
)
|
||||
sys.exit(2)
|
||||
|
||||
# Set token in redis to expire in <expires_in> seconds
|
||||
cache.set("twitch_token", token, ex=expires_in - 10) # type: ignore
|
||||
cache.set("twitch_token_expires_at", time.time() + expires_in - 10) # type: ignore
|
||||
|
||||
log.info("Twitch token fetched!")
|
||||
|
||||
return token
|
||||
|
||||
def get_oauth_token(self) -> str:
|
||||
if not self._is_token_valid():
|
||||
log.warning("Twitch token invalid: fetching a new one")
|
||||
self._update_twitch_token()
|
||||
return self.token
|
||||
# Use a fake token when running tests
|
||||
if "pytest" in sys.modules:
|
||||
return "test_token"
|
||||
|
||||
# Fetch the token cache
|
||||
token = cache.get("twitch_token") # type: ignore
|
||||
token_expires_at = cache.get("twitch_token_expires_at") # type: ignore
|
||||
|
||||
if not token or time.time() > float(token_expires_at or 0):
|
||||
log.warning("Twitch token invalid: fetching a new one...")
|
||||
return self._update_twitch_token()
|
||||
|
||||
return token
|
||||
|
||||
41593
backend/handler/ps2_opl_index.py
Normal file
41593
backend/handler/ps2_opl_index.py
Normal file
File diff suppressed because it is too large
Load Diff
@@ -6,33 +6,33 @@ from logger.logger import log
|
||||
|
||||
class SGDBHandler:
|
||||
def __init__(self) -> None:
|
||||
self.headers: dict = {
|
||||
self.headers = {
|
||||
"Authorization": f"Bearer {STEAMGRIDDB_API_KEY}",
|
||||
"Accept": "*/*",
|
||||
}
|
||||
self.BASE_URL: str = "https://www.steamgriddb.com/api/v2"
|
||||
self.DEFAULT_IMAGE_URL: str = (
|
||||
"https://www.steamgriddb.com/static/img/logo-512.png"
|
||||
)
|
||||
self.BASE_URL = "https://www.steamgriddb.com/api/v2"
|
||||
self.DEFAULT_IMAGE_URL = "https://www.steamgriddb.com/static/img/logo-512.png"
|
||||
|
||||
def get_details(self, term) -> tuple:
|
||||
id: int = ""
|
||||
name: str = ""
|
||||
url_logo: str = ""
|
||||
try:
|
||||
res: dict = requests.get(
|
||||
f"{self.BASE_URL}/search/autocomplete/{term}", headers=self.headers
|
||||
).json()["data"][0]
|
||||
id: int = res["id"]
|
||||
name: str = res["name"]
|
||||
except IndexError:
|
||||
log.warning(f"{term} not found in steamgriddb")
|
||||
else:
|
||||
try:
|
||||
res = requests.get(
|
||||
f"{self.BASE_URL}/grid/game/{id}", headers=self.headers
|
||||
)
|
||||
url_logo: str = res.json()["data"][0]["url"]
|
||||
except IndexError:
|
||||
log.warning(f"{term} logo not found in steamgriddb")
|
||||
return (id, name, url_logo)
|
||||
def get_details(self, term):
|
||||
search_response = requests.get(
|
||||
f"{self.BASE_URL}/search/autocomplete/{term}", headers=self.headers
|
||||
).json()
|
||||
|
||||
if len(search_response["data"]) == 0:
|
||||
log.info(f"Could not find {term} on SteamGridDB")
|
||||
return ("", "", self.DEFAULT_IMAGE_URL)
|
||||
|
||||
game_id = search_response["data"][0]["id"]
|
||||
game_name = search_response["data"][0]["name"]
|
||||
|
||||
game_response = requests.get(
|
||||
f"{self.BASE_URL}/grid/game/{game_id}", headers=self.headers
|
||||
).json()
|
||||
|
||||
if len(game_response["data"]) == 0:
|
||||
log.info(f"Could not find {game_name} image on SteamGridDB")
|
||||
return (game_id, game_name, self.DEFAULT_IMAGE_URL)
|
||||
|
||||
game_image_url = game_response["data"][0]["url"]
|
||||
|
||||
return (game_id, game_name, game_image_url)
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
import socketio
|
||||
|
||||
|
||||
class SocketManager(object):
|
||||
def __new__(cls):
|
||||
if not hasattr(cls, "instance"):
|
||||
cls.instance = super(SocketManager, cls).__new__(cls)
|
||||
return cls.instance
|
||||
|
||||
def __init__(self):
|
||||
self.server = socketio.AsyncServer(
|
||||
cors_allowed_origins="*",
|
||||
async_mode="asgi",
|
||||
logger=False,
|
||||
engineio_logger=False,
|
||||
)
|
||||
self.app = socketio.ASGIApp(self.server)
|
||||
|
||||
@property
|
||||
def on(self):
|
||||
return self.server.on
|
||||
|
||||
@property
|
||||
def send(self):
|
||||
return self.server.send
|
||||
|
||||
@property
|
||||
def emit(self):
|
||||
return self.server.emit
|
||||
|
||||
def mount_to(self, path: str, app):
|
||||
app.mount(path, self.app)
|
||||
0
backend/handler/tests/__init__.py
Normal file
0
backend/handler/tests/__init__.py
Normal file
224
backend/handler/tests/cassettes/test_get_matched_roms_by_id.yaml
generated
Normal file
224
backend/handler/tests/cassettes/test_get_matched_roms_by_id.yaml
generated
Normal file
@@ -0,0 +1,224 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: fields slug, name, summary; where id=3340;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '42'
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/games/
|
||||
response:
|
||||
body:
|
||||
string: "[\n {\n \"id\": 3340,\n \"name\": \"Paper Mario\",\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 }\n]"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 7f126a05af63a217-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Encoding:
|
||||
- gzip
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 03 Aug 2023 23:41:55 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=wDiKbcKQ3m_tAXcetju4HJcp6OPAiMOfUGDv.Qxc9_4-1691106115-0-AR8tebmXr3vUeWSXKfHtRC7jKovYN4NoETfB3B/4U3W30Wy0fVrf8F1zztBw78LNQkPf5x0J9qS+mgWJZ7t3bws=;
|
||||
path=/; expires=Fri, 04-Aug-23 00:11:55 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
Via:
|
||||
- 1.1 4eb35caa679bb95c591a03f41b151b8c.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- Q_1fypvitK-OJqC_QYY4ErPjAkJL_3gYmO81HOazZ60lVg_1ANrX3Q==
|
||||
X-Amz-Cf-Pop:
|
||||
- YTO50-P1
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '1'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JG4ymEiEPHcF9MQ=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '500'
|
||||
x-amzn-Remapped-Date:
|
||||
- Thu, 03 Aug 2023 23:41:55 GMT
|
||||
x-amzn-RequestId:
|
||||
- c32482b9-7f14-4042-85df-19320fb5c3a4
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: fields url; where game=3340;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '28'
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/covers/
|
||||
response:
|
||||
body:
|
||||
string: "[\n {\n \"id\": 80830,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/co1qda.jpg\"\n
|
||||
\ }\n]"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 7f126a06de1336b2-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Encoding:
|
||||
- gzip
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 03 Aug 2023 23:41:55 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=cQ_y_kOrw7pQVRj28XC3lPa2OCXVG0rSpcShckzp7p4-1691106115-0-AUjpVxmkEx0lJb7fc+CujKHS29w61WEhRm76yLebdCdDDHwCcp7cZI/jF3OIMs76nYBjR/sZ5zSrISlBVYBR6jU=;
|
||||
path=/; expires=Fri, 04-Aug-23 00:11:55 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
Via:
|
||||
- 1.1 412b0215b557780a6efcc1651037dc90.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- YkMddi8ILsXiEJiU7JrHfsCznI7b2570ZCX1NhS7hrWTn0EGPVVlvg==
|
||||
X-Amz-Cf-Pop:
|
||||
- YTO50-P1
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '1'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JG4yoHFLPHcFxww=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '96'
|
||||
x-amzn-Remapped-Date:
|
||||
- Thu, 03 Aug 2023 23:41:55 GMT
|
||||
x-amzn-RequestId:
|
||||
- 7eb9b5fb-ff48-4250-b7b7-647549a4a5ca
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: fields url; where game=3340; limit 5;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '37'
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/screenshots/
|
||||
response:
|
||||
body:
|
||||
string: "[\n {\n \"id\": 24169,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/ig9ainu9fershqdinox1.jpg\"\n
|
||||
\ },\n {\n \"id\": 24168,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/hdxgs9nruycvrzcgvseu.jpg\"\n
|
||||
\ },\n {\n \"id\": 24167,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/a5r3k2lf3lgvifrycqeg.jpg\"\n
|
||||
\ },\n {\n \"id\": 24171,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/kjnf90jnud6njmwto3th.jpg\"\n
|
||||
\ },\n {\n \"id\": 24170,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/jz66se3deczeta6hd4ys.jpg\"\n
|
||||
\ }\n]"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 7f126a092e9339fd-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Encoding:
|
||||
- gzip
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 03 Aug 2023 23:41:56 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=sJV2ROMH3Fq5hOrD12tZoGjjnHrqFJHYmSdMGiNu8EM-1691106116-0-AYpioWmuBfiwlRSk6VVzhKBjMxbqv1bTNaPKkKO/Knr/XHRCvwFfSWmFpycuk/foP08saw07yKTZBpuSBgTtpsY=;
|
||||
path=/; expires=Fri, 04-Aug-23 00:11:56 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
Via:
|
||||
- 1.1 1093497011694314ff008667ee2636c0.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- r5B_vbMuEjRhNugI0GFE7TnuFSipGSMcwX3VtaltcUfEzdx2XUOeHA==
|
||||
X-Amz-Cf-Pop:
|
||||
- YTO50-P1
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '5'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JG4yrHhCPHcF4Pg=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '542'
|
||||
x-amzn-Remapped-Date:
|
||||
- Thu, 03 Aug 2023 23:41:56 GMT
|
||||
x-amzn-RequestId:
|
||||
- 54fc6e46-b065-4460-958d-c02ee77c002c
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
||||
1645
backend/handler/tests/cassettes/test_get_matched_roms_by_name.yaml
generated
Normal file
1645
backend/handler/tests/cassettes/test_get_matched_roms_by_name.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
140
backend/handler/tests/cassettes/test_get_platform.yaml
generated
Normal file
140
backend/handler/tests/cassettes/test_get_platform.yaml
generated
Normal file
@@ -0,0 +1,140 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: fields id, name; where slug="n64";
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '34'
|
||||
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:
|
||||
- 7f126a00ff5536ff-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Encoding:
|
||||
- gzip
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 03 Aug 2023 23:41:55 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=YSU1kOOYgk2sBN2rEWxDlKrslGRW1UpK8RnA6l.zKh4-1691106115-0-AaN052HbCUAYRaiWZZWlUTi/7cT0S9NbwQ7OwjzwmE/heOVqTfhFSJlTsFv6KbnQWd7RDcWEQI1EyCpeYesnUG4=;
|
||||
path=/; expires=Fri, 04-Aug-23 00:11:55 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
Via:
|
||||
- 1.1 9b4f2014232c90b3056e1fb1e00215fc.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- xhnv8ARLgZZoWZOYNyOKw2R9eORp9S7ZCmmvwShks2vAttJzZ_5eLA==
|
||||
X-Amz-Cf-Pop:
|
||||
- YUL62-C2
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '1'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JG4yfEnzPHcF9xQ=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '50'
|
||||
x-amzn-Remapped-Date:
|
||||
- Thu, 03 Aug 2023 23:41:54 GMT
|
||||
x-amzn-RequestId:
|
||||
- 86e7521f-07de-4725-93ae-5945991b2f80
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: fields id, name; where slug="not_real";
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '39'
|
||||
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:
|
||||
- 7f126a033dfe36d6-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '2'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 03 Aug 2023 23:41:55 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=C15lGKF9M7qAs3MgWG1Rdg1BBgoNTkXUtiHaTYm2.No-1691106115-0-AcXlYwi9KvmsVhZSGfPc+8QFPyJ8l75AmoGU1uIc08UsxgCqA0ebf/joGzEFDgKANOycFOVnm4SD0FBPe79QJIA=;
|
||||
path=/; expires=Fri, 04-Aug-23 00:11:55 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 b17b94cbc6db5cb82e8f8d6e55e1e85a.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- lssR6fbnPthIZ3KymDK4XGpoy79m63sp3YG3feOCNlerg3MlqgSjMw==
|
||||
X-Amz-Cf-Pop:
|
||||
- YTO50-P1
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '0'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JG4yiHcZPHcFydQ=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '2'
|
||||
x-amzn-Remapped-Date:
|
||||
- Thu, 03 Aug 2023 23:41:55 GMT
|
||||
x-amzn-RequestId:
|
||||
- c4d171c7-91fb-4587-a7d4-2417fab3f265
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
||||
642
backend/handler/tests/cassettes/test_get_ps2_opl_rom.yaml
generated
Normal file
642
backend/handler/tests/cassettes/test_get_ps2_opl_rom.yaml
generated
Normal file
@@ -0,0 +1,642 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: "\n search \"WWE Smack\";\n fields id, slug,
|
||||
name, summary, screenshots;\n where platforms=[8] ;\n "
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '148'
|
||||
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:
|
||||
- 7f3aed54583736cc-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '2'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Tue, 08 Aug 2023 21:42:04 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=2FZ8yXd6kJCZczwShE3trToMz6isxk3pRUdc56wkEYI-1691530924-0-AaqEUxKzxOgi0q16HWpEhnxkee2iScFmFmmwLDzJ7V8+Lm65RvQWP9+x+2SsA08kOrB4y76l/LHK/K17sx8OwhQ=;
|
||||
path=/; expires=Tue, 08-Aug-23 22:12:04 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 0cf68108b8820db4a096a661da0108ba.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- yWhkDdhd8nwU3D_xJgnuyJJT0ZozkSB-Fzb_Kv24Iy3_KAqMa81ATw==
|
||||
X-Amz-Cf-Pop:
|
||||
- YUL62-C2
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '0'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JXF69GAEvHcFSFw=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '2'
|
||||
x-amzn-Remapped-Date:
|
||||
- Tue, 08 Aug 2023 21:42:04 GMT
|
||||
x-amzn-RequestId:
|
||||
- f89b0a7e-0132-468a-9765-e860db9af0e5
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: "\n search \"WWE Smack\";\n fields id, slug,
|
||||
name, summary, screenshots;\n where platforms=[8] & category=10;\n
|
||||
\ "
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '161'
|
||||
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:
|
||||
- 7f3aed55b93fa1e4-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '2'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Tue, 08 Aug 2023 21:42:04 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=Puva_j5o1yiq.tnKDbNcV9pRuJbwrDYniBPvgoCQRXY-1691530924-0-ARyofbQZWmGWeXv8t7ZyqA9cLRh4bt44QD551g2b/4ovRPGCxYEce8NyjxvhPQoeZwdzuWtPOX4XhuRF0cj0dFc=;
|
||||
path=/; expires=Tue, 08-Aug-23 22:12:04 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 17eb4ce9c34597b3328325a19f8138fe.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- LlXMW-vJq3MPlx4V-D3RBkS_BeLRWZP6EnqmwClehjo-DKCuMEYqBQ==
|
||||
X-Amz-Cf-Pop:
|
||||
- JFK50-P6
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '0'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JXF6_HRsPHcFfQg=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '2'
|
||||
x-amzn-Remapped-Date:
|
||||
- Tue, 08 Aug 2023 21:42:04 GMT
|
||||
x-amzn-RequestId:
|
||||
- 738c513a-5c6d-4b7c-b10d-0eb712ade4e5
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: "\n search \"WWE Smack\";\n fields id, slug,
|
||||
name, summary, screenshots;\n where platforms=[8] ;\n "
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '148'
|
||||
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:
|
||||
- 7f3aed575c81a226-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '2'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Tue, 08 Aug 2023 21:42:04 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=jlhBpkzNgFQ60YxJyjPoZQeFRys3Boz2kkiA0GzSM4E-1691530924-0-ARN2bowq/YOIbetCAuqjH8574ysfCvbCuUSI3sSC9HBViMCrAeK+BQMkCe6DAParzXuxnB8omL4Dkonp5Q+j1q0=;
|
||||
path=/; expires=Tue, 08-Aug-23 22:12:04 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 6e810acc9d798bdf126180508d1b511e.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- UeAJtI52TSI8rQ7RlwlHc6jftX4OvgNz3Gw2IfioYp_ZNqV14aku7Q==
|
||||
X-Amz-Cf-Pop:
|
||||
- JFK50-P6
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '0'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JXF7DFU_vHcFQJQ=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '2'
|
||||
x-amzn-Remapped-Date:
|
||||
- Tue, 08 Aug 2023 21:42:04 GMT
|
||||
x-amzn-RequestId:
|
||||
- 0f819ab1-564f-422e-925d-5cd09471dfb6
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: fields url; where game=0;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '25'
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/covers/
|
||||
response:
|
||||
body:
|
||||
string: '[]'
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 7f3aed59ddaea250-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '2'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Tue, 08 Aug 2023 21:42:05 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=5hfxta3kbDkpYYMbi4pWqTE4TCxYZTOLNpZZFnLi3BY-1691530925-0-AXngRGKN3b+A560jM6xfcJC8ybSeSrB84RN5cVumXhBcW7x4aeWkFMsvETU9eL0uuUqRx8EHCa+f2Imgohg76+o=;
|
||||
path=/; expires=Tue, 08-Aug-23 22:12:05 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 0252b483f7b420504a413a83f987b080.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- lFMJmVctmUi1nCqdc39Ou5-RXXPbx-OlBzhX8HZzWZSYVbOv6GMTOA==
|
||||
X-Amz-Cf-Pop:
|
||||
- JFK50-P6
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '0'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JXF7GGvlPHcFkfg=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '2'
|
||||
x-amzn-Remapped-Date:
|
||||
- Tue, 08 Aug 2023 21:42:05 GMT
|
||||
x-amzn-RequestId:
|
||||
- 2d66b17c-39e7-48c4-ad47-471ad90fecc4
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: fields url; where game=0; limit 5;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '34'
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/screenshots/
|
||||
response:
|
||||
body:
|
||||
string: '[]'
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 7f3aed5b3f3439e7-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '2'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Tue, 08 Aug 2023 21:42:05 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=xQhaAjFgeVf91imq1V7u_fKbBT.2iuPS0fOuXwyjaY0-1691530925-0-AYwl6RE7yyGBd7ZHNqOtw8YOSkuqle6edPWbN2C/FPRjSMLARxkSSGyajCWulxpJYGkoC33IvmlvXhE/Dux7KFk=;
|
||||
path=/; expires=Tue, 08-Aug-23 22:12:05 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 0cf68108b8820db4a096a661da0108ba.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- oCOyIQwsjsGRFEH-VmwCpuhNE_QdXBNxeyPcz1uWsBE52WoKHmUyKg==
|
||||
X-Amz-Cf-Pop:
|
||||
- YUL62-C2
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '0'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JXF7JHGPvHcFjyw=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '2'
|
||||
x-amzn-Remapped-Date:
|
||||
- Tue, 08 Aug 2023 21:42:05 GMT
|
||||
x-amzn-RequestId:
|
||||
- 9b979995-d6e6-46d8-afb8-e93c06120852
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: "\n search \"WWE SmackDown! vs. RAW\";\n fields
|
||||
id, slug, name, summary, screenshots;\n where platforms=[8] ;\n
|
||||
\ "
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '161'
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/games/
|
||||
response:
|
||||
body:
|
||||
string: "[\n {\n \"id\": 80852,\n \"name\": \"WWE Smackdown! vs. Raw\",\n
|
||||
\ \"screenshots\": [\n 337102,\n 337103,\n 337104,\n 337105,\n
|
||||
\ 337106,\n 337107,\n 337108\n ],\n \"slug\": \"wwe-smackdown-vs-raw\",\n
|
||||
\ \"summary\": \"WWE SmackDown! vs. Raw brings two of wrestling\\u0027s
|
||||
most popular game series together on the PS2. The game re-creates WWE programming
|
||||
with voice-overs and commentary throughout the season mode. During matches,
|
||||
you can learn a host of new gameplay moves, such as stare-downs, chop battles,
|
||||
and submission reversals. You can also try out situational challenges or create
|
||||
your own championship. Play as your favorite wrestler, including legends and
|
||||
Divas, and prove to the world that you have what it takes to be the WWE champion.\"\n
|
||||
\ },\n {\n \"id\": 2265,\n \"name\": \"WWE SmackDown vs. Raw 2011\",\n
|
||||
\ \"screenshots\": [\n 25356,\n 25357,\n 25358,\n 25359,\n
|
||||
\ 25360\n ],\n \"slug\": \"wwe-smackdown-vs-raw-2011\",\n \"summary\":
|
||||
\"WWE SmackDown vs. Raw 2011 will empower players more than ever to define
|
||||
their destiny and gameplay experiences in a dynamic and ever-changing WWE.
|
||||
Along the way, your decisions will decide gameplay scenarios, allowing for
|
||||
more spontaneous WWE action in and out of the ring. Enjoy a greater level
|
||||
of interactivity that allows you to customize your WWE experience and control
|
||||
your destinies in all-new Road to WrestleMania story-driven campaigns.\\n\\nYou\\u0027ve
|
||||
seen the Superstars\\u0027 greatest moments on WWE programming. You\u2019ve
|
||||
shared them and lived through them on television, on the web, and at the arenas.
|
||||
Now, it\\u0027s time for you to define your ultimate WWE moment, in the most
|
||||
interactive experience in the WWE Universe. This is your moment.\"\n },\n
|
||||
\ {\n \"id\": 5300,\n \"name\": \"WWE SmackDown vs. Raw 2010\",\n \"screenshots\":
|
||||
[\n 27682\n ],\n \"slug\": \"wwe-smackdown-vs-raw-2010\",\n \"summary\":
|
||||
\"The best-selling fighting videogame franchise returns to the virtual ring
|
||||
with the most authentic, entertaining and compelling simulation of WWE programming
|
||||
to date. Featuring unparalleled creation tools, a robust Superstar roster,
|
||||
key franchise improvements and a few surprises, WWE SmackDown vs. Raw 2010
|
||||
delivers the empowering freedom to create, customize and share gameplay experiences.
|
||||
It\\u0027s your world now.\"\n },\n {\n \"id\": 5299,\n \"name\":
|
||||
\"WWE SmackDown vs. Raw 2009\",\n \"screenshots\": [\n 27080\n ],\n
|
||||
\ \"slug\": \"wwe-smackdown-vs-raw-2009\",\n \"summary\": \"WWE SmackDown
|
||||
vs. Raw 2009 for the Wii builds upon its inaugural offering by significantly
|
||||
expanding its match type options, giving players more ways to enjoy the platform\\u0027s
|
||||
unique pick-up-and-play experience. The game also takes full combat sports
|
||||
entertainment to the next level by giving players more superstar control with
|
||||
interactive entrances and victory scenes.\"\n },\n {\n \"id\": 18323,\n
|
||||
\ \"name\": \"WWE SmackDown! vs. Raw 2006\",\n \"screenshots\": [\n 337109,\n
|
||||
\ 337110,\n 337111,\n 337112\n ],\n \"slug\": \"wwe-smackdown-vs-raw-2006\",\n
|
||||
\ \"summary\": \"The debut PlayStation Portable offering of THQ and Yuke\\u0027s
|
||||
long-running 3D wrestling series. WWE SmackDown! vs. RAW 2006 expands on THQ\\u0027s
|
||||
popular multi-million unit-selling franchise with a number of key new features.
|
||||
The Buried Alive Casket match, two new wrestler attributes (Stamina and Hardcore),
|
||||
and a realistic momentum system all combine to turn the series away from its
|
||||
arcade roots and towards that of a simulation. The PSP version follows closely
|
||||
on the heels of its PS2 tag-teammate in terms of features and wrestler rosters,
|
||||
with exclusive extras including additional characters and other features for
|
||||
the PSP version, plus USB system link to connect the two versions together.\"\n
|
||||
\ },\n {\n \"id\": 7252,\n \"name\": \"WWE SmackDown vs. Raw 2007\",\n
|
||||
\ \"screenshots\": [\n 27298\n ],\n \"slug\": \"wwe-smackdown-vs-raw-2007\",\n
|
||||
\ \"summary\": \"A brand new Analog Control System makes fighting more realistic
|
||||
than ever with intuitive movement and new elements of control. An enhanced
|
||||
Season Mode provides multiple branching storylines and unprecedented levels
|
||||
of player choice. In and out of the ring, dozens of user-controlled environmental
|
||||
hotspots let players take advantage of anything at their disposal to inflict
|
||||
damage on opponents in new and unique ways. Additionally, new high impact
|
||||
combination moves let players take the power of WWE Superstars into their
|
||||
own hands. Experience the intensity of WWE fans in a brand new, fully loaded
|
||||
interactive fighting area. Players can take advantage of multiple weapons,
|
||||
environmental damage and grabbing signs and weapons from the crowd. WWE SmackDown
|
||||
vs. RAW 2007 offers multiple enhancements, including incredible high definition
|
||||
graphics, updated rosters for both RAW and SmackDown, an expanded General
|
||||
Manager Mode, online multiplayer game play with voice chat support and more.\"\n
|
||||
\ },\n {\n \"id\": 5298,\n \"name\": \"WWE SmackDown vs. Raw 2008\",\n
|
||||
\ \"screenshots\": [\n 26973,\n 178914,\n 178915,\n 178916,\n
|
||||
\ 178917,\n 178918,\n 178919,\n 178920,\n 178921,\n
|
||||
\ 178922,\n 178923,\n 178924\n ],\n \"slug\": \"wwe-smackdown-vs-raw-2008\",\n
|
||||
\ \"summary\": \"The 2008 edition in the Smackdown vs. Raw series holds
|
||||
new features to the WWE game franchise. This is the first in the series to
|
||||
include the extremists of ECW, including The Sandman, Marcus Cor Von and CM
|
||||
Punk.\\n\\nThe game also features a new struggle submission system, new weapon
|
||||
choices including guitars, and eight superstar fighting styles, including
|
||||
Showman, Powerhouse, High-Flyer and more. Each player can now choose a primary
|
||||
and a secondary fighting style. It continues the legend trend and new arenas,
|
||||
such as Wrestlemania 23, Unforgiven and Summerslam as well as the classic
|
||||
superstars like Undertaker, Shawn Michaels and Ric Flair. The roster largely
|
||||
depends on the platform, and some versions include wrestlers not available
|
||||
in the other ones.\"\n }\n]"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 7f3aed5dd96ba216-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Encoding:
|
||||
- gzip
|
||||
Content-Length:
|
||||
- '2424'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Tue, 08 Aug 2023 21:42:05 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=lFnWxIux8YDNP5ICYrRJNZN30Jxkv2T1QzKICAHLqOM-1691530925-0-AZHMsgCTbsWbvEU3UIsf90t5Ef/i7SGyz4Z4TwsBDzvH2+0mANJkeHp53rWNzYfkN4Mz1wJAgFz8tfKtoydRRow=;
|
||||
path=/; expires=Tue, 08-Aug-23 22:12:05 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 0252b483f7b420504a413a83f987b080.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- qMI0thyxNG4YqxaWxxTBgXkpeDOXi8Bs0zUkoQsOxxTo_XrbvaVCyg==
|
||||
X-Amz-Cf-Pop:
|
||||
- JFK50-P6
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '7'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JXF7MF6bPHcFZ_w=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '2424'
|
||||
x-amzn-Remapped-Date:
|
||||
- Tue, 08 Aug 2023 21:42:05 GMT
|
||||
x-amzn-RequestId:
|
||||
- 401f41a8-2a6b-4964-920b-eb774319cfda
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: fields url; where game=80852;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '29'
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/covers/
|
||||
response:
|
||||
body:
|
||||
string: "[\n {\n \"id\": 209154,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/co4hdu.jpg\"\n
|
||||
\ }\n]"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 7f3aed5f2ddd36bf-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Encoding:
|
||||
- gzip
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Tue, 08 Aug 2023 21:42:06 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=NBzU8tnnDPzzbIAUPFzzHf10sB1qjmrChgr4Ut46Ox4-1691530926-0-AdGbP+m+iP2Llc9wZ0uUxmpsDceQbzmnbkQ4M7VXQz85LhsD6qkxyqkdlu6iWeq+0Yir4PaVw3gfSMjnzHcT0X0=;
|
||||
path=/; expires=Tue, 08-Aug-23 22:12:06 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
Via:
|
||||
- 1.1 0cf68108b8820db4a096a661da0108ba.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- o_MYoqRnT-DeRtef1fxWHzCYrIqFijaFAWrmcj15zvdCq0rXCY4UNw==
|
||||
X-Amz-Cf-Pop:
|
||||
- YUL62-C2
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '1'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JXF7QHazPHcFcww=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '97'
|
||||
x-amzn-Remapped-Date:
|
||||
- Tue, 08 Aug 2023 21:42:06 GMT
|
||||
x-amzn-RequestId:
|
||||
- a71761ba-563f-47a0-8a38-2154eec2f4ce
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: fields url; where game=80852; limit 5;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '38'
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/screenshots/
|
||||
response:
|
||||
body:
|
||||
string: "[\n {\n \"id\": 337103,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/sc783z.jpg\"\n
|
||||
\ },\n {\n \"id\": 337104,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/sc7840.jpg\"\n
|
||||
\ },\n {\n \"id\": 337105,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/sc7841.jpg\"\n
|
||||
\ },\n {\n \"id\": 337102,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/sc783y.jpg\"\n
|
||||
\ },\n {\n \"id\": 337107,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/sc7843.jpg\"\n
|
||||
\ }\n]"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 7f3aed623f323703-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Encoding:
|
||||
- gzip
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Tue, 08 Aug 2023 21:42:06 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=zB0ETxnaV0kJzmyVyhhM2ZwIFSuA0eNxJ2FvRuPgG9s-1691530926-0-AQLXHBSsCwuXuiOXkg86hSIKr1UR1ihHIGDIrlfZ+zv0MVziB/rpH6H+EknfKKjcJMyFjIjACi8tggV87C83JS0=;
|
||||
path=/; expires=Tue, 08-Aug-23 22:12:06 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
Via:
|
||||
- 1.1 fe2c65104051140806cad998f531e478.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- QfT8ouLqo-_tJw0mOCqRGudg1z4R5KlILNRHYGG4ehbuHDse4k4OWQ==
|
||||
X-Amz-Cf-Pop:
|
||||
- YUL62-C2
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '7'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JXF7VFzivHcFS_w=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '477'
|
||||
x-amzn-Remapped-Date:
|
||||
- Tue, 08 Aug 2023 21:42:06 GMT
|
||||
x-amzn-RequestId:
|
||||
- 54fb9c00-2b9c-4a62-9efd-89e44f768f66
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
||||
621
backend/handler/tests/cassettes/test_get_rom.yaml
generated
Normal file
621
backend/handler/tests/cassettes/test_get_rom.yaml
generated
Normal file
@@ -0,0 +1,621 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: "\n search \"Paper Mario\";\n fields id, slug,
|
||||
name, summary, screenshots;\n where platforms=[4] ;\n "
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '150'
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/games/
|
||||
response:
|
||||
body:
|
||||
string: "[\n {\n \"id\": 3340,\n \"name\": \"Paper Mario\",\n \"screenshots\":
|
||||
[\n 24167,\n 24168,\n 24169,\n 24170,\n 24171\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 },\n
|
||||
\ {\n \"id\": 257636,\n \"name\": \"Paper Mario TTYD64\",\n \"screenshots\":
|
||||
[\n 1093074,\n 1093075\n ],\n \"slug\": \"paper-mario-ttyd64\",\n
|
||||
\ \"summary\": \"TTYD64 is a PM64 romhack that adds TTYD\\u0027s gameplay
|
||||
into the original Paper Mario plus all new items, badges, and recipes from
|
||||
that game, and a lot of new areas to explore plus other additions.\"\n },\n
|
||||
\ {\n \"id\": 159343,\n \"name\": \"Paper Mario: Black Pit\",\n \"screenshots\":
|
||||
[\n 552543,\n 552544\n ],\n \"slug\": \"paper-mario-black-pit\",\n
|
||||
\ \"summary\": \"Paper Mario: Black Pit is a ROM hack/mod of Paper Mario
|
||||
64, developed by elDexter. It adds a new level layout to the game, based on
|
||||
roguelike mechanics.\"\n },\n {\n \"id\": 187873,\n \"name\": \"Paper
|
||||
Mario: Master Quest\",\n \"screenshots\": [\n 714703,\n 714704\n
|
||||
\ ],\n \"slug\": \"paper-mario-master-quest\",\n \"summary\": \"Paper
|
||||
Mario: Master Quest is a mod made for \\\"Paper Mario\\\" on the N64. It was
|
||||
created by Emperor_Thamz, Rainchus, JaThePlayer, and Brotenko. It revamps
|
||||
old content and adds plenty of new as well.\\nOften considered \\\"The Dark
|
||||
Souls of Paper Mario\\\", the mod is incredibly difficult.\"\n },\n {\n
|
||||
\ \"id\": 159325,\n \"name\": \"Paper Mario Multiplayer\",\n \"screenshots\":
|
||||
[\n 552513,\n 552514\n ],\n \"slug\": \"paper-mario-multiplayer\",\n
|
||||
\ \"summary\": \"Paper Mario Multiplayer is a ROM hack/mod of Paper Mario
|
||||
(Nintendo 64) developed by SKELUX which adds support for multiplayer, with
|
||||
the second player controlling Mario\\u0027s partner.\"\n },\n {\n \"id\":
|
||||
248349,\n \"name\": \"Paper Mario: Master Quest + Jr.\",\n \"screenshots\":
|
||||
[\n 1044412,\n 1044413,\n 1044414,\n 1044415\n ],\n
|
||||
\ \"slug\": \"paper-mario-master-quest-plus-jr\",\n \"summary\": \"Paper
|
||||
Mario: Master Quest is a mod made for \u201CPaper Mario\u201D on the N64.
|
||||
It revamps old content and adds plenty of new as well. Often considered \u201CThe
|
||||
Dark Souls of Paper Mario\u201D, the mod is incredibly difficult. It was designed
|
||||
with elite challenge runners in mind, and unless you have extensive knowledge
|
||||
of Paper Mario, you may struggle with much of the content.\\n\\nFor those
|
||||
players there is Paper Mario: Master Quest Jr. which has all of the content
|
||||
the original has, with a much more reasonable difficulty curve. If you want
|
||||
to stream the mod, starting with Jr. is recommended.\"\n },\n {\n \"id\":
|
||||
186399,\n \"name\": \"The Paper Mario Christmas Special\",\n \"screenshots\":
|
||||
[\n 705997,\n 705998\n ],\n \"slug\": \"the-paper-mario-christmas-special\",\n
|
||||
\ \"summary\": \"Paper Mario Christmas Special is a ROM Hack of Paper Mario.
|
||||
It was developed by Rain, Alex, Fish, Fewffwa, and Den of the Paper Mario
|
||||
Modding Discord.\"\n },\n {\n \"id\": 245039,\n \"name\": \"Paper
|
||||
Mario Eggstraordinary Egg Hunt\",\n \"screenshots\": [\n 1030891\n
|
||||
\ ],\n \"slug\": \"paper-mario-eggstraordinary-egg-hunt\",\n \"summary\":
|
||||
\"Join Mario \\u0026 Luigi for the annual Easter Egg Hunt in Toad Town and
|
||||
close regions like Koopa Village and Shooting Star Summit!\\n\\nA Paper Mario
|
||||
Mod made by BOSS05 / Miigle and Den / DenNya as a easter present for the Paper
|
||||
Mario Modding Community.\"\n },\n {\n \"id\": 155012,\n \"name\":
|
||||
\"Bowser\\u0027s Dark Story\",\n \"screenshots\": [\n 689665\n ],\n
|
||||
\ \"slug\": \"bowsers-dark-story\",\n \"summary\": \"Bowser\\u0027s Dark
|
||||
Story is a ROM hack/mod of Paper Mario. The game is an alternative take on
|
||||
the story, from the perspective that tells how it would be if Bowser won against
|
||||
Mario and conquered the Mushroom Kingdom. The player controls the villain,
|
||||
Bowser, through an adventure, finding allies and battling enemies.\"\n }\n]"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 7f126d5f6b293987-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Encoding:
|
||||
- gzip
|
||||
Content-Length:
|
||||
- '1595'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 03 Aug 2023 23:44:12 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=bLLcuaIASi0bZmVFhPmsX64QEIxShbJgYdDg4.c2ovU-1691106252-0-Af/kCgNlQvV1rE830NQoa11FwK9tKYYqJIhdq9Ne70yNfd+9N6roout2ppRMV3hZf2tDUlIkk7VPLq96Jl680lA=;
|
||||
path=/; expires=Fri, 04-Aug-23 00:14:12 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 60c77d7f2a0954d991174a909a828016.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- 8vOBHPI5YpN5BjvXTfZybpQmbmz3-vVi1eqgJu7rgJwJXgxxVmB-9Q==
|
||||
X-Amz-Cf-Pop:
|
||||
- YTO50-P1
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '9'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JG5ICGJyPHcFr6g=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '1595'
|
||||
x-amzn-Remapped-Date:
|
||||
- Thu, 03 Aug 2023 23:44:12 GMT
|
||||
x-amzn-RequestId:
|
||||
- 0e5f62e6-d558-484f-93c3-13f9ddaf5c01
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: fields url; where game=3340;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '28'
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/covers/
|
||||
response:
|
||||
body:
|
||||
string: "[\n {\n \"id\": 80830,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/co1qda.jpg\"\n
|
||||
\ }\n]"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 7f126d622f3236bd-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Encoding:
|
||||
- gzip
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 03 Aug 2023 23:44:13 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=RYYy_LYLPL6J1D0C7dMjF3mdj5vb2BcSNfg5ziPlan0-1691106253-0-AdxlU0S8rRHZvUuYozrUZBqmjNEixJEUWLANTttjOerusnkJG+fHNNMOB2V7TmHwSzfojdfk/IXmHvJ8NPthlVA=;
|
||||
path=/; expires=Fri, 04-Aug-23 00:14:13 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
Via:
|
||||
- 1.1 ea419f8269940bd7231c70acd36c430c.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- 0fticAwqoch2VCjBD18G9UZ-0fuL55bDm4DbU-tT295PetwxbQdHlQ==
|
||||
X-Amz-Cf-Pop:
|
||||
- YUL62-C2
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '1'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JG5IGGpaPHcF4gA=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '96'
|
||||
x-amzn-Remapped-Date:
|
||||
- Thu, 03 Aug 2023 23:44:13 GMT
|
||||
x-amzn-RequestId:
|
||||
- 4f89ffc9-fac0-4330-92de-818292867e7b
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: fields url; where game=3340; limit 5;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '37'
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/screenshots/
|
||||
response:
|
||||
body:
|
||||
string: "[\n {\n \"id\": 24169,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/ig9ainu9fershqdinox1.jpg\"\n
|
||||
\ },\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\": 24171,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/kjnf90jnud6njmwto3th.jpg\"\n
|
||||
\ },\n {\n \"id\": 24170,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/jz66se3deczeta6hd4ys.jpg\"\n
|
||||
\ }\n]"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 7f126d64abf3369c-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Encoding:
|
||||
- gzip
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 03 Aug 2023 23:44:13 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=s4Ce14Sy3VrVUWlPy9dJolmqHh4AdrCbjVqVzyabHi4-1691106253-0-AVXeoHwfSXLWaN5JdVMNdDPv3McFYvMJBnD5X5JtFzQ79/ttXibX8gDdeps0pbUgbt2fB75ZMKR2ASCESOqS8U4=;
|
||||
path=/; expires=Fri, 04-Aug-23 00:14:13 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
Via:
|
||||
- 1.1 412b0215b557780a6efcc1651037dc90.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- 6GbnvP9WqZDoHIjyYWSWYHS1D1PD9E-93l1wkEcx6f-Q9m4-U5YV_Q==
|
||||
X-Amz-Cf-Pop:
|
||||
- YTO50-P1
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '5'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JG5IKELtvHcFxxQ=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '542'
|
||||
x-amzn-Remapped-Date:
|
||||
- Thu, 03 Aug 2023 23:44:13 GMT
|
||||
x-amzn-RequestId:
|
||||
- 7814ec9e-fa3c-4235-8f34-70b6be623622
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: "\n search \"Not a real game title\";\n fields
|
||||
id, slug, name, summary, screenshots;\n where platforms=[4] ;\n
|
||||
\ "
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '160'
|
||||
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:
|
||||
- 7f126d674fde38e3-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '2'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 03 Aug 2023 23:44:14 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=WTnyz18eCRd0SfvcLc1.HL_GB8_5XtEqwHLupWyo1Dg-1691106254-0-ASe88xYd/xOCRifJo9ibTwxWgMzt+uhs6kXhoZLXnyeeVnKXTUvDvfII11sR7Zajf1MwAGY2KFa+yInFOpOonC8=;
|
||||
path=/; expires=Fri, 04-Aug-23 00:14:14 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 8422f3871db2552d4ad0cc9f31e22c2e.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- NN1HJEq_rY56WFe0PbI_jWbXq6ZqcZAvmSEMBXtoEAzZnft8lUsmDw==
|
||||
X-Amz-Cf-Pop:
|
||||
- YUL62-C2
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '0'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JG5IPEUBvHcFwbw=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '2'
|
||||
x-amzn-Remapped-Date:
|
||||
- Thu, 03 Aug 2023 23:44:14 GMT
|
||||
x-amzn-RequestId:
|
||||
- bf6f91b7-25e1-40d7-a740-b428e853bf35
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: "\n search \"Not a real game title\";\n fields
|
||||
id, slug, name, summary, screenshots;\n where platforms=[4] &
|
||||
category=10;\n "
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '173'
|
||||
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:
|
||||
- 7f126d6a7e22a222-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '2'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 03 Aug 2023 23:44:14 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=ZEpgW84if5CBp_nuRPeBszoRejGEuzDMoTTukpl9aGU-1691106254-0-ATQMHD+4OraybHGTUEaQ1WPKsSolum+hEuf2bWGAlNp0QsvyLzkp/ZfeHsIol8op89rWh9p+6q/dE/pA+EAdOL0=;
|
||||
path=/; expires=Fri, 04-Aug-23 00:14:14 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 412b0215b557780a6efcc1651037dc90.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- nQj1vjB38m0Jxw89M0oo3I0iBd84uzouIJn25TaRsmHqd13Auqz5cg==
|
||||
X-Amz-Cf-Pop:
|
||||
- YTO50-P1
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '0'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JG5IVEZRPHcFkfQ=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '2'
|
||||
x-amzn-Remapped-Date:
|
||||
- Thu, 03 Aug 2023 23:44:14 GMT
|
||||
x-amzn-RequestId:
|
||||
- 213d4393-5519-4c42-907c-95b4e45336ab
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: "\n search \"Not a real game title\";\n fields
|
||||
id, slug, name, summary, screenshots;\n where platforms=[4] ;\n
|
||||
\ "
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '160'
|
||||
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:
|
||||
- 7f126d6d0fb6a247-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '2'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 03 Aug 2023 23:44:15 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=EIGZAzE7UTkwHk6Cy4cHYMXe6eCeYp7lRcxqNQKqWTE-1691106255-0-AeryOBWmbTOcAZmG+pm/kc1X6+g6zO/vi6h7g1wfgv9khTpHAybk4gwR1WlF4jxKEQ32GWzW/MBI8HBDbvJjO/Q=;
|
||||
path=/; expires=Fri, 04-Aug-23 00:14:15 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 9a6f07a84b60a85466bb31603767843c.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- 1seMwudjh6edOHPTjFDA_8sl6LfjJ9AgxwsztlbmygsXuFSzBiD8cg==
|
||||
X-Amz-Cf-Pop:
|
||||
- YUL62-C2
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '0'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JG5IYHasPHcFnLQ=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '2'
|
||||
x-amzn-Remapped-Date:
|
||||
- Thu, 03 Aug 2023 23:44:15 GMT
|
||||
x-amzn-RequestId:
|
||||
- 6bc197a6-5b2e-4c0c-b926-9f8d9bb2ac99
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: fields url; where game=0;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '25'
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/covers/
|
||||
response:
|
||||
body:
|
||||
string: '[]'
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 7f126d6eab87369f-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '2'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 03 Aug 2023 23:44:15 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=tqA0IF6yWEomy4yV9QiwUwE7.4Kxsxr7TeOmF7saxGU-1691106255-0-AZUVJ/r/9E0qbSxr7pYly6Kp+tI3wluyRdlleI871f+WGkwmIdx8YBIE5DyCJgZ5uC99izspK/cDBsl4g0PX8ss=;
|
||||
path=/; expires=Fri, 04-Aug-23 00:14:15 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 9b2dd59575ce5b546a63dbe37a7ae2de.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- iJ_jvuAeqLXjh4hHIEcWfvv17ywpd4ZHBRXsvheiBcHE-Ay5WI9_-A==
|
||||
X-Amz-Cf-Pop:
|
||||
- YTO50-P1
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '0'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JG5IaGsUPHcFzjg=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '2'
|
||||
x-amzn-Remapped-Date:
|
||||
- Thu, 03 Aug 2023 23:44:15 GMT
|
||||
x-amzn-RequestId:
|
||||
- be9ad64d-2bfc-4678-8469-66e1df44ff1d
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: fields url; where game=0; limit 5;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '34'
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/screenshots/
|
||||
response:
|
||||
body:
|
||||
string: '[]'
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 7f126d70eb7d3987-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '2'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 03 Aug 2023 23:44:16 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=Trl8yAz8GxOWXz9JKbgLrhg8c0hxPPnl9cDU5AqEpds-1691106256-0-ATDgj0RSkUa8kxzr+rHLdVTYCTqNT346OCChaC1XS/bJ1EJGEpp7zlXUpDR6dr4iY/0t7uVO1VWp2MllwfxCfe8=;
|
||||
path=/; expires=Fri, 04-Aug-23 00:14:16 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 ea419f8269940bd7231c70acd36c430c.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- f8_2TZSuaneVVFachgZ1rnafKeqO72WMjDtyyT-bRUPfQBwtQeRoGQ==
|
||||
X-Amz-Cf-Pop:
|
||||
- YUL62-C2
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '0'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JG5IfFhIPHcFSwA=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '2'
|
||||
x-amzn-Remapped-Date:
|
||||
- Thu, 03 Aug 2023 23:44:15 GMT
|
||||
x-amzn-RequestId:
|
||||
- 688c2d14-6d90-4ae5-8132-dcefd35c64ad
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
||||
428
backend/handler/tests/cassettes/test_get_rom_by_id.yaml
generated
Normal file
428
backend/handler/tests/cassettes/test_get_rom_by_id.yaml
generated
Normal file
@@ -0,0 +1,428 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: fields slug, name, summary; where id=3340;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '42'
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/games/
|
||||
response:
|
||||
body:
|
||||
string: "[\n {\n \"id\": 3340,\n \"name\": \"Paper Mario\",\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 }\n]"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 7f1269a8fcd7a247-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Encoding:
|
||||
- gzip
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 03 Aug 2023 23:41:40 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=6wzIMGNL1E0nC8FEHiAaWtMRKU6EIrbq2Ntv2efJZfE-1691106100-0-AZZ/vrJrRHIqQWl/fytfaIwcqEoedL5R5fQgG/C2c+nx4VK5qWWzGBJOkFmxor5QNrv6K5xruYTouCBBkdWdgjY=;
|
||||
path=/; expires=Fri, 04-Aug-23 00:11:40 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
Via:
|
||||
- 1.1 81f76a57a3b40a803013e33a76a4e06e.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- G_7eipAXaxm2iJo1sotArdRN4qN2Wtrqp8DYw7pYZNyTJcYNORgBhQ==
|
||||
X-Amz-Cf-Pop:
|
||||
- YTO50-P1
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '1'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JG4wSGUQvHcFYrA=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '500'
|
||||
x-amzn-Remapped-Date:
|
||||
- Thu, 03 Aug 2023 23:41:40 GMT
|
||||
x-amzn-RequestId:
|
||||
- 6963a67f-2b24-4bc0-8081-09a90f6569a2
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: fields url; where game=3340;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '28'
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/covers/
|
||||
response:
|
||||
body:
|
||||
string: "[\n {\n \"id\": 80830,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/co1qda.jpg\"\n
|
||||
\ }\n]"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 7f1269ab983053e9-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Encoding:
|
||||
- gzip
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 03 Aug 2023 23:41:41 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=rdcKYHcKq26Q2vdhqVF5COrJY4h_YTSx_p8njGrHqLY-1691106101-0-ASjK+08Wese/yd21+LpAUCe22Fut1gTH5QazUGBWoHkxptAOyaURuo7qa+m2d3EAnSqTDFw8d/xj94qUNoLdSfE=;
|
||||
path=/; expires=Fri, 04-Aug-23 00:11:41 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
Via:
|
||||
- 1.1 4eb35caa679bb95c591a03f41b151b8c.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- OySucqxNocLndzmwnA0RXzP7HnMXfSWUqkj9d0Q90FksRHJbrNwKVQ==
|
||||
X-Amz-Cf-Pop:
|
||||
- YTO50-P1
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '1'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JG4wWEESvHcFakw=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '96'
|
||||
x-amzn-Remapped-Date:
|
||||
- Thu, 03 Aug 2023 23:41:41 GMT
|
||||
x-amzn-RequestId:
|
||||
- db3f045b-761f-469a-b719-57b88738d4a1
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: fields url; where game=3340; limit 5;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '37'
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/screenshots/
|
||||
response:
|
||||
body:
|
||||
string: "[\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\": 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\": 24171,\n \"url\": \"//images.igdb.com/igdb/image/upload/t_thumb/kjnf90jnud6njmwto3th.jpg\"\n
|
||||
\ }\n]"
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 7f1269ad3ae936b6-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Encoding:
|
||||
- gzip
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 03 Aug 2023 23:41:41 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=V2EzboOlys1qC_1rCvMGuAYqWHg6exbnLFTAwk18HNc-1691106101-0-AUVfW9ylQmKuU8FSost3PCJ69VmAzKWlv2gFNGXKZN5Ecfjh+JxJ6ncnJo7yTLpHIyxN80u8YCtVa+nFj4ZH1zM=;
|
||||
path=/; expires=Fri, 04-Aug-23 00:11:41 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
Via:
|
||||
- 1.1 412b0215b557780a6efcc1651037dc90.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- lDjjOfPXojmh1N0JA7iCjtolLfhzGzgQFZTcYzM3097xveFgRm3s5g==
|
||||
X-Amz-Cf-Pop:
|
||||
- YTO50-P1
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '5'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JG4wYHyxvHcFdBw=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '542'
|
||||
x-amzn-Remapped-Date:
|
||||
- Thu, 03 Aug 2023 23:41:41 GMT
|
||||
x-amzn-RequestId:
|
||||
- 6ced9a9b-e270-4864-a67b-b58a72128b6a
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: fields slug, name, summary; where id=-1;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '40'
|
||||
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:
|
||||
- 7f1269af6c115419-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '2'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 03 Aug 2023 23:41:41 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=.IuBT64Zl0P9HFHRbmzYUvn0LxUFVVWEeB51pclhMbc-1691106101-0-Aes8qFtfvaTYIHRim5g5UsyYlLlbeLb0RYKs6dH1k+UQhpzcPnu+4kyh0+XGGwsVsmY+F+bfiVhMwAIzJ4b4wxo=;
|
||||
path=/; expires=Fri, 04-Aug-23 00:11:41 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 81f76a57a3b40a803013e33a76a4e06e.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- QwTCMhbMD62JN1DNzxMmMmioV-kL4ehctEnL9rplhxI3R0OwLBDjew==
|
||||
X-Amz-Cf-Pop:
|
||||
- YTO50-P1
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '0'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JG4wcGp_vHcFxbQ=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '2'
|
||||
x-amzn-Remapped-Date:
|
||||
- Thu, 03 Aug 2023 23:41:41 GMT
|
||||
x-amzn-RequestId:
|
||||
- 51479284-06f1-44cd-8591-16dbd0c22888
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: fields url; where game=-1;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '26'
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/covers/
|
||||
response:
|
||||
body:
|
||||
string: '[]'
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 7f1269b0bdb539f4-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '2'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 03 Aug 2023 23:41:42 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=UzK344EOvvk79GVWYJSEnZJNFP6uBXUckwRde6tIpTI-1691106102-0-AUaO+wV9SzoahyOktV0gi9B7YPac/QEIeXoe/iXwQSuk/Yj4m4kK/Hj42opNj48Ydd8C6pId/2eQZMSTPKbxyKI=;
|
||||
path=/; expires=Fri, 04-Aug-23 00:11:42 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 9b4f2014232c90b3056e1fb1e00215fc.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- kZSnPkBGV0WgbprGevxrFf0xsOf6b2l4bBpDVnJJ7S5aSHzfkcYAGw==
|
||||
X-Amz-Cf-Pop:
|
||||
- YUL62-C2
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '0'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JG4wfFWcPHcFwZA=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '2'
|
||||
x-amzn-Remapped-Date:
|
||||
- Thu, 03 Aug 2023 23:41:42 GMT
|
||||
x-amzn-RequestId:
|
||||
- fc08ed9f-b8c5-4d13-9d6c-628b9c011b1d
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: fields url; where game=-1; limit 5;
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '35'
|
||||
User-Agent:
|
||||
- python-requests/2.31.0
|
||||
method: POST
|
||||
uri: https://api.igdb.com/v4/screenshots/
|
||||
response:
|
||||
body:
|
||||
string: '[]'
|
||||
headers:
|
||||
CF-Cache-Status:
|
||||
- DYNAMIC
|
||||
CF-RAY:
|
||||
- 7f1269b409525437-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '2'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Thu, 03 Aug 2023 23:41:42 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=axZm.mr0lB8JkBdGcKtnpHkHi6nJ.oEP0moNoMlEY2w-1691106102-0-AXRGMueuDxqLV9bNscRE5iLrYVOwr/bndxIFcIUy880ClWajI1VDz14VdRGdemsHLzG45UqeOQr+pyUiYfN49qg=;
|
||||
path=/; expires=Fri, 04-Aug-23 00:11:42 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 81f76a57a3b40a803013e33a76a4e06e.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- _js5d9WGvne3WLyLbCwxCKKDsxju3sK33vHdMvyrQnniikMLI4JH7w==
|
||||
X-Amz-Cf-Pop:
|
||||
- YTO50-P1
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '0'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- JG4wjFClPHcFXrg=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '2'
|
||||
x-amzn-Remapped-Date:
|
||||
- Thu, 03 Aug 2023 23:41:42 GMT
|
||||
x-amzn-RequestId:
|
||||
- bc54f6c1-18b5-4e6a-861b-6837c69a2f50
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
||||
49
backend/handler/tests/conftest.py
Normal file
49
backend/handler/tests/conftest.py
Normal file
@@ -0,0 +1,49 @@
|
||||
import pytest
|
||||
import alembic.config
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
from config.config_loader import ConfigLoader
|
||||
from models.platform import Platform
|
||||
from models.rom import Rom
|
||||
|
||||
engine = create_engine(ConfigLoader.get_db_engine(), pool_pre_ping=True)
|
||||
session = sessionmaker(bind=engine, expire_on_commit=False)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def setup_database():
|
||||
alembic.config.main(argv=["upgrade", "head"])
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def clear_database():
|
||||
with session.begin() as s:
|
||||
s.query(Platform).delete(synchronize_session="evaluate")
|
||||
s.query(Rom).delete(synchronize_session="evaluate")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def platform():
|
||||
platform = Platform(
|
||||
name="test_platform", slug="test_platform_slug", fs_slug="test_platform"
|
||||
)
|
||||
with session.begin() as s:
|
||||
s.merge(platform)
|
||||
return platform
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def rom(platform):
|
||||
rom = Rom(
|
||||
r_name="test_rom",
|
||||
r_slug="test_rom_slug",
|
||||
p_name="test_platform",
|
||||
p_slug="test_platform_slug",
|
||||
file_name="test_rom",
|
||||
file_name_no_tags="test_rom",
|
||||
file_path="test_platform_slug/roms",
|
||||
)
|
||||
with session.begin() as s:
|
||||
s.merge(rom)
|
||||
return rom
|
||||
64
backend/handler/tests/test_db_handler.py
Normal file
64
backend/handler/tests/test_db_handler.py
Normal file
@@ -0,0 +1,64 @@
|
||||
from handler.db_handler import DBHandler
|
||||
from models.platform import Platform
|
||||
from models.rom import Rom
|
||||
|
||||
dbh = DBHandler()
|
||||
|
||||
|
||||
def test_platforms():
|
||||
platform = Platform(
|
||||
name="test_platform", slug="test_platform_slug", fs_slug="test_platform"
|
||||
)
|
||||
dbh.add_platform(platform)
|
||||
|
||||
platforms = dbh.get_platforms()
|
||||
assert len(platforms) == 1
|
||||
|
||||
platform = dbh.get_platform("test_platform_slug")
|
||||
assert platform.name == "test_platform"
|
||||
|
||||
dbh.purge_platforms(["test_platform_slug"])
|
||||
platforms = dbh.get_platforms()
|
||||
assert len(platforms) == 0
|
||||
|
||||
|
||||
def test_roms(rom):
|
||||
dbh.add_rom(
|
||||
Rom(
|
||||
r_name="test_rom_2",
|
||||
r_slug="test_rom_slug_2",
|
||||
p_name="test_platform",
|
||||
p_slug="test_platform_slug",
|
||||
file_name="test_rom_2",
|
||||
file_name_no_tags="test_rom_2",
|
||||
)
|
||||
)
|
||||
|
||||
with dbh.session.begin() as session:
|
||||
roms = session.scalars(dbh.get_roms("test_platform_slug")).all()
|
||||
assert len(roms) == 2
|
||||
|
||||
rom = dbh.get_rom(roms[0].id)
|
||||
assert rom.file_name == "test_rom"
|
||||
|
||||
dbh.update_rom(roms[1].id, {"file_name": "test_rom_2_updated"})
|
||||
rom_2 = dbh.get_rom(roms[1].id)
|
||||
assert rom_2.file_name == "test_rom_2_updated"
|
||||
|
||||
dbh.delete_rom(rom.id)
|
||||
|
||||
with dbh.session.begin() as session:
|
||||
roms = session.scalars(dbh.get_roms(rom.p_slug)).all()
|
||||
assert len(roms) == 1
|
||||
|
||||
dbh.purge_roms(rom_2.p_slug, [rom_2.r_slug])
|
||||
|
||||
with dbh.session.begin() as session:
|
||||
roms = session.scalars(dbh.get_roms("test_platform_slug")).all()
|
||||
assert len(roms) == 0
|
||||
|
||||
|
||||
def test_utils(rom):
|
||||
with dbh.session.begin() as session:
|
||||
roms = session.scalars(dbh.get_roms("test_platform_slug")).all()
|
||||
assert dbh.rom_exists("test_platform_slug", "test_rom") == roms[0].id
|
||||
97
backend/handler/tests/test_igdb_handler.py
Normal file
97
backend/handler/tests/test_igdb_handler.py
Normal file
@@ -0,0 +1,97 @@
|
||||
import pytest
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from handler.igdb_handler import IGDBHandler
|
||||
|
||||
igdbh = IGDBHandler()
|
||||
|
||||
|
||||
@pytest.mark.vcr()
|
||||
def test_get_platform():
|
||||
platform = igdbh.get_platform("n64")
|
||||
assert platform["igdb_id"] == 4
|
||||
assert platform["name"] == "Nintendo 64"
|
||||
assert platform["slug"] == "n64"
|
||||
|
||||
platform = igdbh.get_platform("not_real")
|
||||
assert platform == {"igdb_id": "", "name": "not_real", "slug": "not_real"}
|
||||
|
||||
|
||||
@pytest.mark.vcr()
|
||||
def test_get_rom():
|
||||
rom = igdbh.get_rom("Paper Mario (USA).n64", 4)
|
||||
assert rom["r_igdb_id"] == 3340
|
||||
assert rom["r_slug"] == "paper-mario"
|
||||
assert rom["r_name"] == "Paper Mario"
|
||||
assert rom["summary"]
|
||||
assert urlparse(rom["url_cover"]).hostname == "images.igdb.com"
|
||||
assert urlparse(rom["url_screenshots"][0]).hostname == "images.igdb.com"
|
||||
|
||||
rom = igdbh.get_rom("Not a real game title", 4)
|
||||
assert rom["r_igdb_id"] == 0
|
||||
assert rom["r_slug"] == ""
|
||||
assert rom["r_name"] == "Not a real game title"
|
||||
assert not rom["summary"]
|
||||
assert rom["url_cover"] == ""
|
||||
assert not rom["url_screenshots"]
|
||||
|
||||
|
||||
@pytest.mark.vcr()
|
||||
def test_get_ps2_opl_rom():
|
||||
rom = igdbh.get_rom("WWE Smack.iso", 8)
|
||||
assert rom["r_igdb_id"] == 0
|
||||
assert rom["r_slug"] == ""
|
||||
assert rom["r_name"] == "WWE Smack"
|
||||
assert not rom["summary"]
|
||||
assert rom["url_cover"] == ""
|
||||
assert not rom["url_screenshots"]
|
||||
|
||||
rom = igdbh.get_rom("SLUS_210.60.WWE Smack.iso", 8)
|
||||
assert rom["r_igdb_id"] == 80852
|
||||
assert rom["r_slug"] == "wwe-smackdown-vs-raw"
|
||||
assert rom["r_name"] == "WWE Smackdown! vs. Raw"
|
||||
assert rom["summary"]
|
||||
assert urlparse(rom["url_cover"]).hostname == "images.igdb.com"
|
||||
assert urlparse(rom["url_screenshots"][0]).hostname == "images.igdb.com"
|
||||
|
||||
|
||||
@pytest.mark.vcr()
|
||||
def test_get_rom_by_id():
|
||||
rom = igdbh.get_rom_by_id(3340)
|
||||
assert rom["r_igdb_id"] == 3340
|
||||
assert rom["r_slug"] == "paper-mario"
|
||||
assert rom["r_name"] == "Paper Mario"
|
||||
assert rom["summary"]
|
||||
assert urlparse(rom["url_cover"]).hostname == "images.igdb.com"
|
||||
assert urlparse(rom["url_screenshots"][0]).hostname == "images.igdb.com"
|
||||
|
||||
rom = igdbh.get_rom_by_id(-1)
|
||||
assert rom["r_igdb_id"] == -1
|
||||
assert not rom["r_name"]
|
||||
|
||||
|
||||
@pytest.mark.vcr()
|
||||
def test_get_matched_roms_by_id():
|
||||
roms = igdbh.get_matched_roms_by_id(3340)
|
||||
assert len(roms) == 1
|
||||
|
||||
assert roms[0]["r_igdb_id"] == 3340
|
||||
assert roms[0]["r_slug"] == "paper-mario"
|
||||
assert "t_cover_big" in roms[0]["url_cover"]
|
||||
|
||||
|
||||
@pytest.mark.vcr()
|
||||
def test_get_matched_roms_by_name():
|
||||
roms = igdbh.get_matched_roms_by_name("Mario", 4)
|
||||
assert len(roms) == 10
|
||||
|
||||
assert roms[0]["r_igdb_id"] == 132642
|
||||
assert roms[0]["r_slug"] == "super-mario-64-shindou-pak-taiou-version"
|
||||
assert roms[0]["r_name"] == "Super Mario 64: Shindou Pak Taiou Version"
|
||||
|
||||
assert roms[1]["r_igdb_id"] == 3475
|
||||
assert roms[1]["r_slug"] == "dr-mario-64"
|
||||
assert roms[1]["r_name"] == "Dr. Mario 64"
|
||||
|
||||
roms = igdbh.get_matched_roms_by_name("Notarealgametitle", 4)
|
||||
assert roms == []
|
||||
@@ -8,4 +8,4 @@ COLORS: dict = {
|
||||
'red': '\033[91m',
|
||||
'bold_red': '\033[1;91m',
|
||||
'reset': '\033[0m',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import logging
|
||||
|
||||
class FileFormatter(logging.Formatter):
|
||||
|
||||
class FileFormatter(logging.Formatter):
|
||||
level: str = "%(levelname)s"
|
||||
dots: str = ":"
|
||||
identifier: str = "\t [RomM]"
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
@@ -25,4 +24,4 @@ log.addHandler(stdout_handler)
|
||||
# Define file handler
|
||||
file_handler = logging.FileHandler(logs_file)
|
||||
file_handler.setFormatter(FileFormatter())
|
||||
log.addHandler(file_handler)
|
||||
log.addHandler(file_handler)
|
||||
|
||||
@@ -3,7 +3,6 @@ import logging
|
||||
from logger import COLORS
|
||||
|
||||
class StdoutFormatter(logging.Formatter):
|
||||
|
||||
level: str = "%(levelname)s"
|
||||
dots: str = ":"
|
||||
identifier: str = "\t [RomM]"
|
||||
@@ -22,4 +21,4 @@ class StdoutFormatter(logging.Formatter):
|
||||
def format(self, record):
|
||||
log_fmt = self.FORMATS.get(record.levelno)
|
||||
formatter = logging.Formatter(fmt=log_fmt, datefmt='%Y-%m-%d %H:%M:%S')
|
||||
return formatter.format(record)
|
||||
return formatter.format(record)
|
||||
|
||||
0
backend/logger/tests/__init__.py
Normal file
0
backend/logger/tests/__init__.py
Normal file
18
backend/logger/tests/test_logger.py
Normal file
18
backend/logger/tests/test_logger.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from logger.logger import log
|
||||
|
||||
|
||||
def test_logger(caplog):
|
||||
log.debug("Testing debug message")
|
||||
assert "debug message" in caplog.text
|
||||
|
||||
log.info("Testing info message")
|
||||
assert "info message" in caplog.text
|
||||
|
||||
log.warning("Testing warning message")
|
||||
assert "warning message" in caplog.text
|
||||
|
||||
log.error("Testing error message")
|
||||
assert "error message" in caplog.text
|
||||
|
||||
log.critical("Testing critical message")
|
||||
assert "critical message" in caplog.text
|
||||
@@ -1,11 +1,12 @@
|
||||
import uvicorn
|
||||
import alembic.config
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi_pagination import add_pagination
|
||||
|
||||
from config import DEV_PORT, DEV_HOST
|
||||
from handler.socket_manager import SocketManager
|
||||
from endpoints import scan, search, platform, rom
|
||||
from endpoints import search, platform, rom, scan # noqa
|
||||
from utils.socket import socket_app
|
||||
|
||||
app = FastAPI()
|
||||
app.add_middleware(
|
||||
@@ -20,16 +21,7 @@ app.include_router(platform.router)
|
||||
app.include_router(rom.router)
|
||||
|
||||
add_pagination(app)
|
||||
|
||||
sm = SocketManager()
|
||||
sm.mount_to("/ws", app)
|
||||
|
||||
|
||||
async def scan_handler(*args):
|
||||
await scan.scan(*args, sm)
|
||||
|
||||
|
||||
sm.on("scan", handler=scan_handler)
|
||||
app.mount("/ws", socket_app)
|
||||
|
||||
|
||||
@app.on_event("startup")
|
||||
@@ -39,5 +31,8 @@ def startup() -> None:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Run migrations
|
||||
alembic.config.main(argv=["upgrade", "head"])
|
||||
|
||||
# Run application
|
||||
uvicorn.run("main:app", host=DEV_HOST, port=DEV_PORT, reload=True)
|
||||
# uvicorn.run("main:app", host=DEV_HOST, port=DEV_PORT, reload=False, workers=2)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import declarative_base
|
||||
|
||||
BaseModel = declarative_base()
|
||||
|
||||
@@ -5,18 +5,18 @@ from models.base import BaseModel
|
||||
|
||||
|
||||
class Platform(BaseModel):
|
||||
__tablename__ = 'platforms'
|
||||
igdb_id = Column(String(length=10), default="")
|
||||
sgdb_id = Column(String(length=10), default="")
|
||||
__tablename__ = "platforms"
|
||||
igdb_id: str = Column(String(length=10), default="")
|
||||
sgdb_id: str = Column(String(length=10), default="")
|
||||
|
||||
slug = Column(String(length=50), default="")
|
||||
name = Column(String(length=400), default="")
|
||||
slug: str = Column(String(length=50), default="")
|
||||
name: str = Column(String(length=400), default="")
|
||||
|
||||
logo_path = Column(String(length=1000), default=DEFAULT_PATH_COVER_S)
|
||||
|
||||
n_roms = Column(Integer, default=0)
|
||||
logo_path: str = Column(String(length=1000), default=DEFAULT_PATH_COVER_S)
|
||||
|
||||
fs_slug = Column(String(length=50), primary_key=True)
|
||||
n_roms: int = Column(Integer, default=0)
|
||||
|
||||
fs_slug: str = Column(String(length=50), primary_key=True)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return self.name
|
||||
|
||||
@@ -3,45 +3,44 @@ from sqlalchemy import Integer, Column, String, Text, Boolean, Float, JSON
|
||||
from config import DEFAULT_PATH_COVER_S, DEFAULT_PATH_COVER_L, FRONT_LIBRARY_PATH
|
||||
from models.base import BaseModel
|
||||
|
||||
|
||||
class Rom(BaseModel):
|
||||
__tablename__ = "roms"
|
||||
id = Column(Integer(), primary_key=True, autoincrement=True)
|
||||
|
||||
r_igdb_id = Column(String(length=10), default="")
|
||||
p_igdb_id = Column(String(length=10), default="")
|
||||
r_sgdb_id = Column(String(length=10), default="")
|
||||
p_sgdb_id = Column(String(length=10), default="")
|
||||
r_igdb_id: str = Column(String(length=10), default="")
|
||||
p_igdb_id: str = Column(String(length=10), default="")
|
||||
r_sgdb_id: str = Column(String(length=10), default="")
|
||||
p_sgdb_id: str = Column(String(length=10), default="")
|
||||
|
||||
p_slug = Column(String(length=50))
|
||||
p_name = Column(String(length=150), default="")
|
||||
p_slug: str = Column(String(length=50))
|
||||
p_name: str = Column(String(length=150), default="")
|
||||
|
||||
file_name = Column(String(length=450), nullable=False)
|
||||
file_name_no_tags = Column(String(length=450))
|
||||
file_extension = Column(String(length=10), default="")
|
||||
file_path = Column(String(length=1000), default="")
|
||||
file_name: str = Column(String(length=450), nullable=False)
|
||||
file_name_no_tags: str = Column(String(length=450))
|
||||
file_extension: str = Column(String(length=10), default="")
|
||||
file_path: str = Column(String(length=1000), default="")
|
||||
file_size = Column(Float, default=0.0)
|
||||
file_size_units = Column(String(length=10), default="")
|
||||
file_size_units: str = Column(String(length=10), default="")
|
||||
|
||||
r_name = Column(String(length=350), default="")
|
||||
r_slug = Column(String(length=400), default="")
|
||||
r_name: str = Column(String(length=350), default="")
|
||||
r_slug: str = Column(String(length=400), default="")
|
||||
|
||||
summary = Column(Text, default="")
|
||||
summary: str = Column(Text, default="")
|
||||
|
||||
path_cover_s = Column(Text, default=DEFAULT_PATH_COVER_S)
|
||||
path_cover_l = Column(Text, default=DEFAULT_PATH_COVER_L)
|
||||
has_cover = Column(Boolean, default=False)
|
||||
url_cover = Column(Text, default=DEFAULT_PATH_COVER_L)
|
||||
path_cover_s: str = Column(Text, default=DEFAULT_PATH_COVER_S)
|
||||
path_cover_l: str = Column(Text, default=DEFAULT_PATH_COVER_L)
|
||||
has_cover: bool = Column(Boolean, default=False)
|
||||
url_cover: str = Column(Text, default=DEFAULT_PATH_COVER_L)
|
||||
|
||||
region = Column(String(20), default="")
|
||||
revision = Column(String(20), default="")
|
||||
tags = Column(JSON, default=[])
|
||||
region: str = Column(String(20), default="")
|
||||
revision: str = Column(String(20), default="")
|
||||
tags: JSON = Column(JSON, default=[])
|
||||
|
||||
multi = Column(Boolean, default=False)
|
||||
files = Column(JSON, default=[])
|
||||
multi: bool = Column(Boolean, default=False)
|
||||
files: JSON = Column(JSON, default=[])
|
||||
|
||||
url_screenshots = Column(JSON, default=[])
|
||||
path_screenshots = Column(JSON, default=[])
|
||||
url_screenshots: JSON = Column(JSON, default=[])
|
||||
path_screenshots: JSON = Column(JSON, default=[])
|
||||
|
||||
@property
|
||||
def full_path(self) -> str:
|
||||
|
||||
0
backend/models/tests/__init__.py
Normal file
0
backend/models/tests/__init__.py
Normal file
1
backend/models/tests/conftest.py
Normal file
1
backend/models/tests/conftest.py
Normal file
@@ -0,0 +1 @@
|
||||
from handler.tests.conftest import rom, platform
|
||||
5
backend/models/tests/test_rom.py
Normal file
5
backend/models/tests/test_rom.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from models.rom import Rom
|
||||
|
||||
def test_rom(rom):
|
||||
assert rom.file_path == "test_platform_slug/roms"
|
||||
assert rom.full_path == "test_platform_slug/roms/test_rom"
|
||||
BIN
backend/romm_test/library/n64/roms/Paper Mario (USA).z64
Normal file
BIN
backend/romm_test/library/n64/roms/Paper Mario (USA).z64
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
backend/romm_test/library/psx/roms/PaRappa the Rapper.zip
Normal file
BIN
backend/romm_test/library/psx/roms/PaRappa the Rapper.zip
Normal file
Binary file not shown.
4
backend/romm_test/setup.sql
Normal file
4
backend/romm_test/setup.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
CREATE DATABASE IF NOT EXISTS romm_test;
|
||||
CREATE USER IF NOT EXISTS 'romm_test'@'%' IDENTIFIED BY 'passwd';
|
||||
GRANT ALL PRIVILEGES ON romm_test.* TO 'romm_test'@'%' WITH GRANT OPTION;
|
||||
FLUSH PRIVILEGES;
|
||||
@@ -63,7 +63,7 @@ def parse_tags(file_name: str) -> tuple:
|
||||
reg = ""
|
||||
rev = ""
|
||||
other_tags = []
|
||||
tags = re.findall("\(([^)]+)", file_name)
|
||||
tags = re.findall(r"\(([^)]+)", file_name)
|
||||
|
||||
for tag in tags:
|
||||
if tag.lower() in REGIONS_BY_SHORTCODE.keys():
|
||||
@@ -75,7 +75,7 @@ def parse_tags(file_name: str) -> tuple:
|
||||
continue
|
||||
|
||||
if "reg" in tag.lower():
|
||||
match = re.match("^reg[\s|-](.*)$", tag, re.IGNORECASE)
|
||||
match = re.match(r"^reg[\s|-](.*)$", tag, re.IGNORECASE)
|
||||
if match:
|
||||
reg = (
|
||||
REGIONS_BY_SHORTCODE[match.group(1).lower()]
|
||||
@@ -85,7 +85,7 @@ def parse_tags(file_name: str) -> tuple:
|
||||
continue
|
||||
|
||||
if "rev" in tag.lower():
|
||||
match = re.match("^rev[\s|-](.*)$", tag, re.IGNORECASE)
|
||||
match = re.match(r"^rev[\s|-](.*)$", tag, re.IGNORECASE)
|
||||
if match:
|
||||
rev = match.group(1)
|
||||
continue
|
||||
@@ -96,7 +96,7 @@ def parse_tags(file_name: str) -> tuple:
|
||||
|
||||
def get_file_name_with_no_tags(file_name: str) -> str:
|
||||
# Use .rsplit to remove only the file extension
|
||||
return re.sub("[\(\[].*?[\)\]]", "", file_name.rsplit(".", 1)[0])
|
||||
return re.sub(r"[\(\[].*?[\)\]]", "", file_name.rsplit(".", 1)[0]).strip()
|
||||
|
||||
|
||||
def get_file_extension(rom: dict) -> str:
|
||||
|
||||
45
backend/utils/cache.py
Normal file
45
backend/utils/cache.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from redis import Redis, ConnectionError
|
||||
|
||||
from config import REDIS_HOST, REDIS_PORT
|
||||
|
||||
redis_client = Redis(host=REDIS_HOST, port=int(REDIS_PORT), db=0)
|
||||
redis_url = f"redis://{REDIS_HOST}:{REDIS_PORT}"
|
||||
|
||||
try:
|
||||
redis_connectable = redis_client.ping()
|
||||
except ConnectionError:
|
||||
redis_connectable = False
|
||||
|
||||
|
||||
class FallbackCache:
|
||||
def __init__(self) -> None:
|
||||
self.fallback: dict = {}
|
||||
|
||||
def get(self, key: str, *args, **kwargs) -> str:
|
||||
return self.fallback.get(key, "")
|
||||
|
||||
def set(self, key: str, value: str, *args, **kwargs) -> None:
|
||||
self.fallback[key] = value
|
||||
|
||||
def delete(self, key: str, *args, **kwargs) -> None:
|
||||
self.fallback.pop(key, None)
|
||||
|
||||
def exists(self, key: str, *args, **kwargs) -> bool:
|
||||
return key in self.fallback
|
||||
|
||||
def flushall(self) -> None:
|
||||
self.fallback = {}
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<FallbackCache {self.fallback}>"
|
||||
|
||||
def __str__(self) -> str:
|
||||
return repr(self)
|
||||
|
||||
|
||||
# A seperate client that auto-decodes responses is needed
|
||||
_cache_client = Redis(
|
||||
host=REDIS_HOST, port=int(REDIS_PORT), db=0, decode_responses=True
|
||||
)
|
||||
_fallback_cache = FallbackCache()
|
||||
cache = _cache_client if redis_connectable else _fallback_cache
|
||||
@@ -1,6 +1,9 @@
|
||||
folder_struct_msg = "Check RomM folder structure here: https://github.com/zurdi15/romm#-folder-structure"
|
||||
|
||||
|
||||
class PlatformsNotFoundException(Exception):
|
||||
def __init__(self):
|
||||
self.message = f"Platforms not found. Check RomM folder structure here: https://github.com/zurdi15/romm#-folder-structure"
|
||||
self.message = f"Platforms not found. {folder_struct_msg}"
|
||||
super().__init__(self.message)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
@@ -9,10 +12,10 @@ class PlatformsNotFoundException(Exception):
|
||||
|
||||
class RomsNotFoundException(Exception):
|
||||
def __init__(self, platform: str):
|
||||
self.message = f"Roms not found for platform {platform}. Check RomM folder structure here: https://github.com/zurdi15/romm#-folder-structure"
|
||||
self.message = f"Roms not found for platform {platform}. {folder_struct_msg}"
|
||||
super().__init__(self.message)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
def __repr__(self):
|
||||
return self.message
|
||||
|
||||
|
||||
@@ -21,7 +24,7 @@ class RomNotFoundError(Exception):
|
||||
self.message = f"Rom {rom} not found for platform {platform}"
|
||||
super().__init__(self.message)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
def __repr__(self):
|
||||
return self.message
|
||||
|
||||
|
||||
@@ -30,5 +33,5 @@ class RomAlreadyExistsException(Exception):
|
||||
self.message = f"Can't rename: {rom_name} already exists"
|
||||
super().__init__(self.message)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
def __repr__(self):
|
||||
return self.message
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
from fastapi import status, HTTPException
|
||||
import emoji
|
||||
from typing import Any
|
||||
|
||||
from handler import igdbh
|
||||
from utils import fs, parse_tags, get_file_extension, get_file_name_with_no_tags
|
||||
from config.config_loader import ConfigLoader
|
||||
cl = ConfigLoader()
|
||||
from utils.exceptions import RomsNotFoundException
|
||||
from logger.logger import log
|
||||
from config.config_loader import config
|
||||
from models.platform import Platform
|
||||
from models.rom import Rom
|
||||
from logger.logger import log
|
||||
|
||||
|
||||
def scan_platform(fs_slug: str) -> Platform:
|
||||
@@ -19,35 +18,104 @@ def scan_platform(fs_slug: str) -> Platform:
|
||||
Platform object
|
||||
"""
|
||||
|
||||
platform_attrs: dict = {}
|
||||
platform_attrs['fs_slug'] = fs_slug
|
||||
log.info(f"· {fs_slug}")
|
||||
|
||||
platform_attrs: dict[str, Any] = {}
|
||||
platform_attrs["fs_slug"] = fs_slug
|
||||
|
||||
try:
|
||||
if fs_slug in cl.config['PLATFORMS_BINDING'].keys():
|
||||
platform_attrs['slug'] = cl.config['PLATFORMS_BINDING'][fs_slug]
|
||||
if fs_slug in config["PLATFORMS_BINDING"].keys():
|
||||
platform_attrs["slug"] = config["PLATFORMS_BINDING"][fs_slug]
|
||||
else:
|
||||
platform_attrs['slug'] = fs_slug
|
||||
platform_attrs["slug"] = fs_slug
|
||||
except (KeyError, TypeError, AttributeError):
|
||||
platform_attrs['slug'] = fs_slug
|
||||
platform_attrs.update(igdbh.get_platform(platform_attrs['slug']))
|
||||
platform_attrs['n_roms'] = len(fs.get_roms(platform_attrs['fs_slug']))
|
||||
platform = Platform(**platform_attrs)
|
||||
return platform
|
||||
platform_attrs["slug"] = fs_slug
|
||||
platform = igdbh.get_platform(platform_attrs["slug"])
|
||||
|
||||
if platform["igdb_id"]:
|
||||
log.info(emoji.emojize(f" Identified as {platform['name']} :video_game:"))
|
||||
else:
|
||||
log.warning(f" {fs_slug} not found in IGDB")
|
||||
|
||||
platform_attrs.update(platform)
|
||||
|
||||
return Platform(**platform_attrs)
|
||||
|
||||
|
||||
def scan_rom(platform: Platform, rom_attrs: dict, r_igbd_id_search: str = '', overwrite: bool = False) -> Rom:
|
||||
p_slug: str = platform.fs_slug if platform.fs_slug else platform.slug
|
||||
roms_path: str = fs.get_roms_structure(p_slug)
|
||||
if r_igbd_id_search: rom_attrs.update(igdbh.get_rom_by_id(r_igbd_id_search))
|
||||
else: rom_attrs.update(igdbh.get_rom(rom_attrs['file_name'], platform.igdb_id))
|
||||
rom_attrs.update(fs.get_cover(overwrite, platform.slug, rom_attrs['file_name'], rom_attrs['url_cover']))
|
||||
rom_attrs.update(fs.get_screenshots(platform.slug, rom_attrs['file_name'], rom_attrs['url_screenshots']))
|
||||
file_size, file_size_units = fs.get_rom_size(rom_attrs['multi'], rom_attrs['file_name'], rom_attrs['files'], roms_path)
|
||||
reg, rev, other_tags = parse_tags(rom_attrs['file_name'])
|
||||
rom_attrs.update({'file_path': roms_path, 'file_name': rom_attrs['file_name'], 'file_name_no_tags': get_file_name_with_no_tags(rom_attrs['file_name']),
|
||||
'file_extension': get_file_extension(rom_attrs), 'file_size': file_size, 'file_size_units': file_size_units,
|
||||
'multi': rom_attrs['multi'], 'region': reg, 'revision': rev, 'tags': other_tags})
|
||||
rom_attrs['p_igdb_id'] = platform.igdb_id
|
||||
rom_attrs['p_slug'] = platform.slug
|
||||
rom_attrs['p_name'] = platform.name
|
||||
rom = Rom(**rom_attrs)
|
||||
return rom
|
||||
def scan_rom(
|
||||
platform: Platform,
|
||||
rom_attrs: dict,
|
||||
r_igbd_id_search: str = "",
|
||||
overwrite: bool = False,
|
||||
) -> Rom:
|
||||
p_slug = platform.fs_slug or platform.slug or ""
|
||||
roms_path = fs.get_roms_structure(p_slug)
|
||||
|
||||
log.info(f"\t · {r_igbd_id_search or rom_attrs['file_name']}")
|
||||
|
||||
if rom_attrs.get("multi", False):
|
||||
for file in rom_attrs["files"]:
|
||||
log.info(f"\t\t · {file}")
|
||||
|
||||
# Update properties that don't require IGDB
|
||||
file_size, file_size_units = fs.get_rom_size(
|
||||
multi=rom_attrs["multi"],
|
||||
file_name=rom_attrs["file_name"],
|
||||
multi_files=rom_attrs["files"],
|
||||
roms_path=roms_path,
|
||||
)
|
||||
reg, rev, other_tags = parse_tags(rom_attrs["file_name"])
|
||||
rom_attrs.update(
|
||||
{
|
||||
"file_path": roms_path,
|
||||
"file_name": rom_attrs["file_name"],
|
||||
"file_name_no_tags": get_file_name_with_no_tags(rom_attrs["file_name"]),
|
||||
"file_extension": get_file_extension(rom_attrs),
|
||||
"file_size": file_size,
|
||||
"file_size_units": file_size_units,
|
||||
"multi": rom_attrs["multi"],
|
||||
"region": reg,
|
||||
"revision": rev,
|
||||
"tags": other_tags,
|
||||
}
|
||||
)
|
||||
rom_attrs["p_igdb_id"] = platform.igdb_id
|
||||
rom_attrs["p_slug"] = platform.slug
|
||||
rom_attrs["p_name"] = platform.name
|
||||
|
||||
# Search in IGDB
|
||||
igdbh_rom = (
|
||||
igdbh.get_rom_by_id(int(r_igbd_id_search))
|
||||
if r_igbd_id_search
|
||||
else igdbh.get_rom(rom_attrs["file_name"], platform.igdb_id)
|
||||
)
|
||||
|
||||
rom_attrs.update(igdbh_rom)
|
||||
|
||||
# Return early if not found in IGDB
|
||||
if not igdbh_rom["r_igdb_id"]:
|
||||
log.warning(
|
||||
f"\t {r_igbd_id_search or rom_attrs['file_name']} not found in IGDB"
|
||||
)
|
||||
return Rom(**rom_attrs)
|
||||
|
||||
log.info(emoji.emojize(f"\t Identified as {igdbh_rom['r_name']} :alien_monster:"))
|
||||
|
||||
# Update properties from IGDB
|
||||
rom_attrs.update(
|
||||
fs.get_cover(
|
||||
overwrite=overwrite,
|
||||
p_slug=platform.slug,
|
||||
r_name=rom_attrs["r_name"],
|
||||
url_cover=rom_attrs["url_cover"],
|
||||
)
|
||||
)
|
||||
rom_attrs.update(
|
||||
fs.get_screenshots(
|
||||
p_slug=platform.slug,
|
||||
r_name=rom_attrs["r_name"],
|
||||
url_screenshots=rom_attrs["url_screenshots"],
|
||||
)
|
||||
)
|
||||
|
||||
return Rom(**rom_attrs)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
import shutil
|
||||
import datetime
|
||||
from pathlib import Path
|
||||
import datetime
|
||||
import requests
|
||||
|
||||
from config import (
|
||||
@@ -13,7 +13,7 @@ from config import (
|
||||
DEFAULT_URL_COVER_S,
|
||||
DEFAULT_PATH_COVER_S,
|
||||
)
|
||||
from config.config_loader import ConfigLoader
|
||||
from config.config_loader import config
|
||||
from utils.exceptions import (
|
||||
PlatformsNotFoundException,
|
||||
RomsNotFoundException,
|
||||
@@ -21,36 +21,34 @@ from utils.exceptions import (
|
||||
RomAlreadyExistsException,
|
||||
)
|
||||
|
||||
cl = ConfigLoader()
|
||||
|
||||
|
||||
# ========= Resources utils =========
|
||||
def _cover_exists(p_slug: str, file_name: str, size: str) -> bool:
|
||||
def _cover_exists(p_slug: str, r_name: str, size: str):
|
||||
"""Check if rom cover exists in filesystem
|
||||
|
||||
Args:
|
||||
p_slug: short name of the platform
|
||||
file_name: name of rom file
|
||||
r_name: name of rom file
|
||||
size: size of the cover -> big as 'l' | small as 's'
|
||||
Returns
|
||||
True if cover exists in filesystem else False
|
||||
"""
|
||||
return bool(
|
||||
os.path.exists(f"{RESOURCES_BASE_PATH}/{p_slug}/{file_name}/cover/{size}.png")
|
||||
os.path.exists(f"{RESOURCES_BASE_PATH}/{p_slug}/{r_name}/cover/{size}.png")
|
||||
)
|
||||
|
||||
|
||||
def _store_cover(p_slug: str, file_name: str, url_cover: str, size: str) -> None:
|
||||
def _store_cover(p_slug: str, r_name: str, url_cover: str, size: str):
|
||||
"""Store roms resources in filesystem
|
||||
|
||||
Args:
|
||||
p_slug: short name of the platform
|
||||
file_name: name of rom file
|
||||
r_name: name of rom file
|
||||
url_cover: url to get the cover
|
||||
size: size of the cover -> big | small
|
||||
"""
|
||||
cover_file: str = f"{size}.png"
|
||||
cover_path: str = f"{RESOURCES_BASE_PATH}/{p_slug}/{file_name}/cover"
|
||||
cover_file = f"{size}.png"
|
||||
cover_path = f"{RESOURCES_BASE_PATH}/{p_slug}/{r_name}/cover"
|
||||
res = requests.get(
|
||||
url_cover.replace("t_thumb", f"t_cover_{size}"), stream=True, timeout=120
|
||||
)
|
||||
@@ -60,7 +58,7 @@ def _store_cover(p_slug: str, file_name: str, url_cover: str, size: str) -> None
|
||||
shutil.copyfileobj(res.raw, f)
|
||||
|
||||
|
||||
def _get_cover_path(p_slug: str, file_name: str, size: str) -> str:
|
||||
def _get_cover_path(p_slug: str, r_name: str, size: str):
|
||||
"""Returns rom cover filesystem path adapted to frontend folder structure
|
||||
|
||||
Args:
|
||||
@@ -68,26 +66,29 @@ def _get_cover_path(p_slug: str, file_name: str, size: str) -> str:
|
||||
file_name: name of rom file
|
||||
size: size of the cover -> big | small
|
||||
"""
|
||||
return f"{p_slug}/{file_name}/cover/{size}.png?timestamp={str(datetime.datetime.now().timestamp())}"
|
||||
strtime = str(datetime.datetime.now().timestamp())
|
||||
return f"{p_slug}/{r_name}/cover/{size}.png?timestamp={strtime}"
|
||||
|
||||
|
||||
def get_cover(overwrite: bool, p_slug: str, file_name: str, url_cover: str) -> dict:
|
||||
def get_cover(overwrite: bool, p_slug: str, r_name: str, url_cover: str = "") -> dict:
|
||||
# Cover small
|
||||
if (overwrite or not _cover_exists(p_slug, file_name, "small")) and url_cover:
|
||||
_store_cover(p_slug, file_name, url_cover, "small")
|
||||
if (overwrite or not _cover_exists(p_slug, r_name, "small")) and url_cover:
|
||||
_store_cover(p_slug, r_name, url_cover, "small")
|
||||
path_cover_s = (
|
||||
_get_cover_path(p_slug, file_name, "small")
|
||||
if _cover_exists(p_slug, file_name, "small")
|
||||
_get_cover_path(p_slug, r_name, "small")
|
||||
if _cover_exists(p_slug, r_name, "small")
|
||||
else DEFAULT_PATH_COVER_S
|
||||
)
|
||||
|
||||
# Cover big
|
||||
if (overwrite or not _cover_exists(p_slug, file_name, "big")) and url_cover:
|
||||
_store_cover(p_slug, file_name, url_cover, "big")
|
||||
if (overwrite or not _cover_exists(p_slug, r_name, "big")) and url_cover:
|
||||
_store_cover(p_slug, r_name, url_cover, "big")
|
||||
(path_cover_l, has_cover) = (
|
||||
(_get_cover_path(p_slug, file_name, "big"), 1)
|
||||
if _cover_exists(p_slug, file_name, "big")
|
||||
(_get_cover_path(p_slug, r_name, "big"), 1)
|
||||
if _cover_exists(p_slug, r_name, "big")
|
||||
else (DEFAULT_PATH_COVER_L, 0)
|
||||
)
|
||||
|
||||
return {
|
||||
"path_cover_s": path_cover_s,
|
||||
"path_cover_l": path_cover_l,
|
||||
@@ -95,7 +96,7 @@ def get_cover(overwrite: bool, p_slug: str, file_name: str, url_cover: str) -> d
|
||||
}
|
||||
|
||||
|
||||
def _store_screenshot(p_slug: str, file_name: str, url: str, idx: int) -> None:
|
||||
def _store_screenshot(p_slug: str, r_name: str, url: str, idx: int):
|
||||
"""Store roms resources in filesystem
|
||||
|
||||
Args:
|
||||
@@ -104,7 +105,7 @@ def _store_screenshot(p_slug: str, file_name: str, url: str, idx: int) -> None:
|
||||
url: url to get the screenshot
|
||||
"""
|
||||
screenshot_file: str = f"{idx}.jpg"
|
||||
screenshot_path: str = f"{RESOURCES_BASE_PATH}/{p_slug}/{file_name}/screenshots"
|
||||
screenshot_path: str = f"{RESOURCES_BASE_PATH}/{p_slug}/{r_name}/screenshots"
|
||||
res = requests.get(url, stream=True, timeout=120)
|
||||
if res.status_code == 200:
|
||||
Path(screenshot_path).mkdir(parents=True, exist_ok=True)
|
||||
@@ -112,7 +113,7 @@ def _store_screenshot(p_slug: str, file_name: str, url: str, idx: int) -> None:
|
||||
shutil.copyfileobj(res.raw, f)
|
||||
|
||||
|
||||
def _get_screenshot_path(p_slug: str, file_name: str, idx: str) -> str:
|
||||
def _get_screenshot_path(p_slug: str, r_name: str, idx: str):
|
||||
"""Returns rom cover filesystem path adapted to frontend folder structure
|
||||
|
||||
Args:
|
||||
@@ -120,20 +121,20 @@ def _get_screenshot_path(p_slug: str, file_name: str, idx: str) -> str:
|
||||
file_name: name of rom file
|
||||
idx: index number of screenshot
|
||||
"""
|
||||
return f"{p_slug}/{file_name}/screenshots/{idx}.jpg"
|
||||
return f"{p_slug}/{r_name}/screenshots/{idx}.jpg"
|
||||
|
||||
|
||||
def get_screenshots(p_slug: str, file_name: str, url_screenshots: list) -> dict:
|
||||
def get_screenshots(p_slug: str, r_name: str, url_screenshots: list) -> dict:
|
||||
path_screenshots: list[str] = []
|
||||
for idx, url in enumerate(url_screenshots):
|
||||
_store_screenshot(p_slug, file_name, url, idx)
|
||||
path_screenshots.append(_get_screenshot_path(p_slug, file_name, str(idx)))
|
||||
_store_screenshot(p_slug, r_name, url, idx)
|
||||
path_screenshots.append(_get_screenshot_path(p_slug, r_name, str(idx)))
|
||||
return {"path_screenshots": path_screenshots}
|
||||
|
||||
|
||||
def store_default_resources() -> None:
|
||||
def store_default_resources():
|
||||
"""Store default cover resources in the filesystem"""
|
||||
defaul_covers: list = [
|
||||
defaul_covers = [
|
||||
{"url": DEFAULT_URL_COVER_L, "size": "big"},
|
||||
{"url": DEFAULT_URL_COVER_S, "size": "small"},
|
||||
]
|
||||
@@ -143,11 +144,11 @@ def store_default_resources() -> None:
|
||||
|
||||
|
||||
# ========= Platforms utils =========
|
||||
def _exclude_platforms(platforms) -> None:
|
||||
_ = [
|
||||
platforms.remove(excluded)
|
||||
for excluded in cl.config["EXCLUDED_PLATFORMS"]
|
||||
if excluded in platforms
|
||||
def _exclude_platforms(platforms: list):
|
||||
return [
|
||||
platform
|
||||
for platform in platforms
|
||||
if platform not in config["EXCLUDED_PLATFORMS"]
|
||||
]
|
||||
|
||||
|
||||
@@ -163,14 +164,13 @@ def get_platforms() -> list[str]:
|
||||
if os.path.exists(HIGH_PRIO_STRUCTURE_PATH)
|
||||
else list(os.walk(LIBRARY_BASE_PATH))[0][1]
|
||||
)
|
||||
_exclude_platforms(platforms)
|
||||
return _exclude_platforms(platforms)
|
||||
except IndexError as exc:
|
||||
raise PlatformsNotFoundException from exc
|
||||
return platforms
|
||||
|
||||
|
||||
# ========= Roms utils =========
|
||||
def get_roms_structure(p_slug: str) -> str:
|
||||
def get_roms_structure(p_slug: str):
|
||||
return (
|
||||
f"roms/{p_slug}"
|
||||
if os.path.exists(HIGH_PRIO_STRUCTURE_PATH)
|
||||
@@ -179,71 +179,83 @@ def get_roms_structure(p_slug: str) -> str:
|
||||
|
||||
|
||||
def _exclude_files(files, filetype) -> list[str]:
|
||||
excluded_extensions = cl.config[f"EXCLUDED_{filetype.upper()}_EXT"]
|
||||
excluded_names = cl.config[f"EXCLUDED_{filetype.upper()}_FILES"]
|
||||
excluded_extensions = config[f"EXCLUDED_{filetype.upper()}_EXT"]
|
||||
excluded_names = config[f"EXCLUDED_{filetype.upper()}_FILES"]
|
||||
filtered_files: list = []
|
||||
|
||||
for file in files:
|
||||
if file.split(".")[-1] in excluded_extensions or file in excluded_names:
|
||||
filtered_files.append(file)
|
||||
files = [f for f in files if f not in filtered_files]
|
||||
return files
|
||||
|
||||
return [f for f in files if f not in filtered_files]
|
||||
|
||||
|
||||
def _exclude_multi_roms(roms) -> list[str]:
|
||||
excluded_names = cl.config["EXCLUDED_MULTI_FILES"]
|
||||
excluded_names = config["EXCLUDED_MULTI_FILES"]
|
||||
filtered_files: list = []
|
||||
|
||||
for rom in roms:
|
||||
if rom in excluded_names:
|
||||
filtered_files.append(rom)
|
||||
roms = [f for f in roms if f not in filtered_files]
|
||||
return roms
|
||||
|
||||
return [f for f in roms if f not in filtered_files]
|
||||
|
||||
|
||||
def get_rom_files(rom: str, roms_path: str) -> list[str]:
|
||||
rom_files: list = []
|
||||
|
||||
for path, _, files in os.walk(f"{roms_path}/{rom}"):
|
||||
_ = [
|
||||
for f in _exclude_files(files, "multi_parts"):
|
||||
rom_files.append(f"{Path(path, f)}".replace(f"{roms_path}/{rom}/", ""))
|
||||
for f in _exclude_files(files, "multi_parts")
|
||||
]
|
||||
|
||||
return rom_files
|
||||
|
||||
|
||||
def get_roms(p_slug: str) -> list[dict] or int:
|
||||
def get_roms(p_slug: str):
|
||||
"""Gets all filesystem roms for a platform
|
||||
|
||||
Args:
|
||||
p_slug: short name of the platform
|
||||
Returns: list with all the filesystem roms for a platform found in the LIBRARY_BASE_PATH.
|
||||
Returns:
|
||||
list with all the filesystem roms for a platform found in the LIBRARY_BASE_PATH
|
||||
"""
|
||||
roms_path = get_roms_structure(p_slug)
|
||||
roms_file_path = f"{LIBRARY_BASE_PATH}/{roms_path}"
|
||||
|
||||
try:
|
||||
fs_single_roms: list[str] = list(os.walk(roms_file_path))[0][2]
|
||||
except IndexError as exc:
|
||||
raise RomsNotFoundException(p_slug) from exc
|
||||
|
||||
try:
|
||||
fs_multi_roms: list[str] = list(os.walk(roms_file_path))[0][1]
|
||||
except IndexError as exc:
|
||||
raise RomsNotFoundException(p_slug) from exc
|
||||
|
||||
fs_roms: list[dict] = [
|
||||
{"multi": False, "file_name": rom}
|
||||
for rom in _exclude_files(fs_single_roms, "single")
|
||||
] + [
|
||||
{"multi": True, "file_name": rom} for rom in _exclude_multi_roms(fs_multi_roms)
|
||||
]
|
||||
_ = [
|
||||
rom.update({"files": get_rom_files(rom["file_name"], roms_file_path)})
|
||||
|
||||
return [
|
||||
dict(
|
||||
rom,
|
||||
files=get_rom_files(rom["file_name"], roms_file_path),
|
||||
)
|
||||
for rom in fs_roms
|
||||
]
|
||||
return fs_roms
|
||||
|
||||
|
||||
def get_rom_size(multi: bool, rom: str, files: list, roms_path: str) -> str:
|
||||
files: list = (
|
||||
[f"{LIBRARY_BASE_PATH}/{roms_path}/{rom}"]
|
||||
def get_rom_size(roms_path: str, file_name: str, multi: bool, multi_files: list = []):
|
||||
files = (
|
||||
[f"{LIBRARY_BASE_PATH}/{roms_path}/{file_name}"]
|
||||
if not multi
|
||||
else [f"{LIBRARY_BASE_PATH}/{roms_path}/{rom}/{file}" for file in files]
|
||||
else [
|
||||
f"{LIBRARY_BASE_PATH}/{roms_path}/{file_name}/{file}"
|
||||
for file in multi_files
|
||||
]
|
||||
)
|
||||
total_size: float = 0.0
|
||||
for file in files:
|
||||
@@ -255,7 +267,7 @@ def get_rom_size(multi: bool, rom: str, files: list, roms_path: str) -> str:
|
||||
return round(total_size, 2), unit
|
||||
|
||||
|
||||
def _rom_exists(p_slug: str, file_name: str) -> bool:
|
||||
def _rom_exists(p_slug: str, file_name: str):
|
||||
"""Check if rom exists in filesystem
|
||||
|
||||
Args:
|
||||
@@ -268,7 +280,7 @@ def _rom_exists(p_slug: str, file_name: str) -> bool:
|
||||
return bool(os.path.exists(f"{LIBRARY_BASE_PATH}/{rom_path}/{file_name}"))
|
||||
|
||||
|
||||
def rename_rom(p_slug: str, old_name: str, new_name: str) -> None:
|
||||
def rename_rom(p_slug: str, old_name: str, new_name: str):
|
||||
if new_name != old_name:
|
||||
rom_path = get_roms_structure(p_slug)
|
||||
if _rom_exists(p_slug, new_name):
|
||||
@@ -279,7 +291,7 @@ def rename_rom(p_slug: str, old_name: str, new_name: str) -> None:
|
||||
)
|
||||
|
||||
|
||||
def remove_rom(p_slug: str, file_name: str) -> None:
|
||||
def remove_rom(p_slug: str, file_name: str):
|
||||
rom_path = get_roms_structure(p_slug)
|
||||
try:
|
||||
try:
|
||||
|
||||
14
backend/utils/socket.py
Normal file
14
backend/utils/socket.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import socketio # type: ignore
|
||||
|
||||
from utils.cache import redis_url, redis_connectable
|
||||
|
||||
|
||||
socket_server = socketio.AsyncServer(
|
||||
cors_allowed_origins="*",
|
||||
async_mode="asgi",
|
||||
logger=False,
|
||||
engineio_logger=False,
|
||||
client_manager=socketio.AsyncRedisManager(redis_url) if redis_connectable else None,
|
||||
)
|
||||
|
||||
socket_app = socketio.ASGIApp(socket_server)
|
||||
0
backend/utils/tests/__init__.py
Normal file
0
backend/utils/tests/__init__.py
Normal file
2624
backend/utils/tests/cassettes/test_get_cover.yaml
generated
Normal file
2624
backend/utils/tests/cassettes/test_get_cover.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
140
backend/utils/tests/cassettes/test_scan_platform.yaml
generated
Normal file
140
backend/utils/tests/cassettes/test_scan_platform.yaml
generated
Normal file
@@ -0,0 +1,140 @@
|
||||
interactions:
|
||||
- request:
|
||||
body: fields id, name; where slug="n64";
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '34'
|
||||
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:
|
||||
- 7eff5636a99d36a1-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Encoding:
|
||||
- gzip
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Tue, 01 Aug 2023 16:07:54 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=M6jV8IDBXuhn5koc54NIo92mpS_07Vq_YCS_Er_x8Ho-1690906074-0-Aatz9H75G6sex1NR59WNaayPhbzHq5bsGY69J802KkuOxTJIRVagK7kMa09OIayfKnTNr4nci8tkf4PwZtAPBCQ=;
|
||||
path=/; expires=Tue, 01-Aug-23 16:37:54 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Transfer-Encoding:
|
||||
- chunked
|
||||
Via:
|
||||
- 1.1 77f3bc2c9964f50671e7151896d06648.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- Q_HAeLD8jS46IJCOE7dnaNhMJy844TeELDlDwNXScyuwNEiQIqIUgw==
|
||||
X-Amz-Cf-Pop:
|
||||
- YUL62-C2
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '1'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- I_QaOHVMPHcFiCQ=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '50'
|
||||
x-amzn-Remapped-Date:
|
||||
- Tue, 01 Aug 2023 16:07:54 GMT
|
||||
x-amzn-RequestId:
|
||||
- a5224844-883a-4a2b-9e5a-a1278adeaec3
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: fields id, name; where slug="";
|
||||
headers:
|
||||
Accept:
|
||||
- application/json
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Client-ID:
|
||||
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '31'
|
||||
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:
|
||||
- 7eff5637ea8e53ef-YYZ
|
||||
Connection:
|
||||
- keep-alive
|
||||
Content-Length:
|
||||
- '2'
|
||||
Content-Type:
|
||||
- application/json
|
||||
Date:
|
||||
- Tue, 01 Aug 2023 16:07:55 GMT
|
||||
Server:
|
||||
- cloudflare
|
||||
Set-Cookie:
|
||||
- __cf_bm=gE4jVTITKRcjnyoGHaSakiXPFmrb2UPnGvjjliZc0NU-1690906075-0-AZJKx7NGH6ws1e8nUErmNIBGvc1tW4ATwpOgnX3lwXHds7EMTL3plHx8pdSpnvFINrX66SVa+Z1GmnGGfOc8HJ0=;
|
||||
path=/; expires=Tue, 01-Aug-23 16:37:55 GMT; domain=.igdb.com; HttpOnly; Secure;
|
||||
SameSite=None
|
||||
Strict-Transport-Security:
|
||||
- max-age=31536000; includeSubDomains; preload
|
||||
Via:
|
||||
- 1.1 d7e35fb15b3339fbd8a9457f22308ea0.cloudfront.net (CloudFront)
|
||||
X-Amz-Cf-Id:
|
||||
- sSYuZMZMfaWt75JeV6cdJzVc5cGFHQ3LmMu7xU1USOVDSQdjM-z44w==
|
||||
X-Amz-Cf-Pop:
|
||||
- YTO50-P1
|
||||
X-Cache:
|
||||
- Miss from cloudfront
|
||||
X-Content-Type-Options:
|
||||
- nosniff
|
||||
X-Count:
|
||||
- '0'
|
||||
alt-svc:
|
||||
- h3=":443"; ma=86400
|
||||
x-amz-apigw-id:
|
||||
- I_QaQEcrvHcF0Ig=
|
||||
x-amzn-Remapped-Content-Length:
|
||||
- '2'
|
||||
x-amzn-Remapped-Date:
|
||||
- Tue, 01 Aug 2023 16:07:54 GMT
|
||||
x-amzn-RequestId:
|
||||
- ad21ab8d-30f2-4d81-b3bf-1a241b6379a2
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
version: 1
|
||||
144370
backend/utils/tests/cassettes/test_scan_rom.yaml
generated
Normal file
144370
backend/utils/tests/cassettes/test_scan_rom.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
44
backend/utils/tests/test_fastapi.py
Normal file
44
backend/utils/tests/test_fastapi.py
Normal file
@@ -0,0 +1,44 @@
|
||||
import pytest
|
||||
|
||||
from utils.fastapi import scan_platform, scan_rom
|
||||
from utils.exceptions import RomsNotFoundException
|
||||
from models.platform import Platform
|
||||
from models.rom import Rom
|
||||
|
||||
|
||||
@pytest.mark.vcr()
|
||||
def test_scan_platform():
|
||||
platform = scan_platform("n64")
|
||||
|
||||
assert platform.__class__ == Platform
|
||||
assert platform.slug == "n64"
|
||||
assert platform.name == "Nintendo 64"
|
||||
assert platform.igdb_id == 4
|
||||
|
||||
try:
|
||||
platform = scan_platform("")
|
||||
except RomsNotFoundException as e:
|
||||
assert "Roms not found for platform" in str(e)
|
||||
|
||||
|
||||
@pytest.mark.vcr()
|
||||
def test_scan_rom():
|
||||
platform = Platform(slug="n64", igdb_id=4)
|
||||
rom = scan_rom(
|
||||
platform,
|
||||
{
|
||||
"file_name": "Paper Mario (USA).z64",
|
||||
"multi": False,
|
||||
"files": ["Paper Mario (USA).z64"],
|
||||
},
|
||||
)
|
||||
|
||||
assert rom.__class__ == Rom
|
||||
assert rom.file_name == "Paper Mario (USA).z64"
|
||||
assert rom.r_name == "Paper Mario"
|
||||
assert rom.r_igdb_id == 3340
|
||||
assert rom.file_size == 1.0
|
||||
assert rom.file_size_units == "KB"
|
||||
assert rom.files == ["Paper Mario (USA).z64"]
|
||||
assert rom.tags == []
|
||||
assert not rom.multi
|
||||
112
backend/utils/tests/test_fs.py
Normal file
112
backend/utils/tests/test_fs.py
Normal file
@@ -0,0 +1,112 @@
|
||||
import pytest
|
||||
|
||||
from utils.fs import (
|
||||
get_cover,
|
||||
get_platforms,
|
||||
get_roms_structure,
|
||||
get_roms,
|
||||
get_rom_size,
|
||||
# get_rom_files, # TODO: write test
|
||||
# rename_rom, # TODO: write test
|
||||
# remove_rom, # TODO: write test
|
||||
)
|
||||
|
||||
from config import (
|
||||
DEFAULT_PATH_COVER_L,
|
||||
DEFAULT_PATH_COVER_S,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.vcr
|
||||
def test_get_cover():
|
||||
# Game: Paper Mario (USA).z64
|
||||
cover = get_cover(
|
||||
overwrite=False,
|
||||
p_slug="n64",
|
||||
r_name="Paper Mario",
|
||||
)
|
||||
|
||||
assert "n64/Paper Mario/cover/small.png" in cover["path_cover_s"]
|
||||
assert "n64/Paper Mario/cover/big.png" in cover["path_cover_l"]
|
||||
assert cover["has_cover"] == 1
|
||||
|
||||
# Game: Paper Mario (USA).z64
|
||||
cover = get_cover(
|
||||
overwrite=True,
|
||||
p_slug="n64",
|
||||
r_name="Paper Mario",
|
||||
url_cover="https://images.igdb.com/igdb/image/upload/t_thumb/co1qda.png",
|
||||
)
|
||||
|
||||
assert "n64/Paper Mario/cover/small.png" in cover["path_cover_s"]
|
||||
assert "n64/Paper Mario/cover/big.png" in cover["path_cover_l"]
|
||||
assert cover["has_cover"] == 1
|
||||
|
||||
# Game: Super Mario 64 (J) (Rev A)
|
||||
cover = get_cover(
|
||||
overwrite=False,
|
||||
p_slug="n64",
|
||||
r_name="Super Mario 64",
|
||||
url_cover="https://images.igdb.com/igdb/image/upload/t_thumb/co6cl1.png",
|
||||
)
|
||||
|
||||
assert "n64/Super Mario 64/cover/small.png" in cover["path_cover_s"]
|
||||
assert "n64/Super Mario 64/cover/big.png" in cover["path_cover_l"]
|
||||
assert cover["has_cover"] == 1
|
||||
|
||||
# Game: Fake Game.xyz
|
||||
cover = get_cover(
|
||||
overwrite=False,
|
||||
p_slug="n64",
|
||||
r_name="Fake Game",
|
||||
)
|
||||
|
||||
assert DEFAULT_PATH_COVER_S in cover["path_cover_s"]
|
||||
assert DEFAULT_PATH_COVER_L in cover["path_cover_l"]
|
||||
assert cover["has_cover"] == 0
|
||||
|
||||
|
||||
def test_get_platforms():
|
||||
platforms = get_platforms()
|
||||
|
||||
assert "n64" in platforms
|
||||
assert "psx" in platforms
|
||||
|
||||
|
||||
def test_get_roms_structure():
|
||||
roms_structure = get_roms_structure(p_slug="n64")
|
||||
|
||||
assert roms_structure == "n64/roms"
|
||||
|
||||
|
||||
def test_get_roms():
|
||||
roms = get_roms(p_slug="n64")
|
||||
|
||||
assert len(roms) == 2
|
||||
assert roms[0]["file_name"] == "Paper Mario (USA).z64"
|
||||
assert not roms[0]["multi"]
|
||||
|
||||
assert roms[1]["file_name"] == "Super Mario 64 (J) (Rev A)"
|
||||
assert roms[1]["multi"]
|
||||
|
||||
|
||||
def test_rom_size():
|
||||
rom_size = get_rom_size(
|
||||
roms_path=get_roms_structure(p_slug="n64"),
|
||||
file_name="Paper Mario (USA).z64",
|
||||
multi=False,
|
||||
)
|
||||
|
||||
assert rom_size == (1.0, "KB")
|
||||
|
||||
rom_size = get_rom_size(
|
||||
roms_path=get_roms_structure(p_slug="n64"),
|
||||
file_name="Super Mario 64 (J) (Rev A)",
|
||||
multi=True,
|
||||
multi_files=[
|
||||
"Super Mario 64 (J) (Rev A) [Part 1].z64",
|
||||
"Super Mario 64 (J) (Rev A) [Part 2].z64",
|
||||
],
|
||||
)
|
||||
|
||||
assert rom_size == (2.0, "KB")
|
||||
59
backend/utils/tests/test_utils.py
Normal file
59
backend/utils/tests/test_utils.py
Normal file
@@ -0,0 +1,59 @@
|
||||
from utils import (
|
||||
parse_tags,
|
||||
get_file_name_with_no_tags as gfnwt,
|
||||
get_file_extension as gfe,
|
||||
)
|
||||
|
||||
|
||||
def test_parse_tags():
|
||||
file_name = "Super Mario Bros. (World).nes"
|
||||
assert parse_tags(file_name) == ("World", "", [])
|
||||
|
||||
file_name = "Super Mario Bros. (W) (Rev A).nes"
|
||||
assert parse_tags(file_name) == ("World", "A", [])
|
||||
|
||||
file_name = "Super Mario Bros. (USA) (Rev A) (Beta).nes"
|
||||
assert parse_tags(file_name) == ("USA", "A", ["Beta"])
|
||||
|
||||
file_name = "Super Mario Bros. (U) (Beta).nes"
|
||||
assert parse_tags(file_name) == ("USA", "", ["Beta"])
|
||||
|
||||
file_name = "Super Mario Bros. (CH) [!].nes"
|
||||
assert parse_tags(file_name) == ("China", "", [])
|
||||
|
||||
file_name = "Super Mario Bros. (reg-T) (rev-1.2).nes"
|
||||
assert parse_tags(file_name) == ("Taiwan", "1.2", [])
|
||||
|
||||
file_name = "Super Mario Bros. (Reg S) (Rev A).nes"
|
||||
assert parse_tags(file_name) == ("Spain", "A", [])
|
||||
|
||||
|
||||
def test_get_file_name_with_no_tags():
|
||||
file_name = "Super Mario Bros. (World).nes"
|
||||
assert gfnwt(file_name) == "Super Mario Bros."
|
||||
|
||||
file_name = "Super Mario Bros. (W) (Rev A).nes"
|
||||
assert gfnwt(file_name) == "Super Mario Bros."
|
||||
|
||||
file_name = "Super Mario Bros. (USA) (Rev A) (Beta).nes"
|
||||
assert gfnwt(file_name) == "Super Mario Bros."
|
||||
|
||||
file_name = "Super Mario Bros. (U) (Beta).nes"
|
||||
assert gfnwt(file_name) == "Super Mario Bros."
|
||||
|
||||
file_name = "Super Mario Bros. (U) [!].nes"
|
||||
assert gfnwt(file_name) == "Super Mario Bros."
|
||||
|
||||
file_name = "Super Mario Bros. (reg-T) (rev-1.2).nes"
|
||||
assert gfnwt(file_name) == "Super Mario Bros."
|
||||
|
||||
file_name = "Super Mario Bros. (Reg S) (Rev A).nes"
|
||||
assert gfnwt(file_name) == "Super Mario Bros."
|
||||
|
||||
|
||||
def test_get_file_extension():
|
||||
rom = {"file_name": "Super Mario Bros. (World).nes", "multi": False}
|
||||
assert gfe(rom) == "nes"
|
||||
|
||||
rom = {"file_name": "Super Mario Bros. (World).nes", "multi": True}
|
||||
assert gfe(rom) == ""
|
||||
15
backend/worker.py
Executable file
15
backend/worker.py
Executable file
@@ -0,0 +1,15 @@
|
||||
import sys
|
||||
from rq import Worker, Queue, Connection
|
||||
|
||||
from utils.cache import redis_client, redis_connectable
|
||||
|
||||
listen = ["high", "default", "low"]
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Exit if Redis is not connectable
|
||||
if not redis_connectable:
|
||||
sys.exit(0)
|
||||
|
||||
with Connection(redis_client):
|
||||
worker = Worker(map(Queue, listen))
|
||||
worker.work()
|
||||
@@ -3,11 +3,18 @@ services:
|
||||
mariadb:
|
||||
image: mariadb:latest
|
||||
container_name: mariadb
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWD}
|
||||
- MYSQL_DATABASE=${DB_NAME}
|
||||
- MYSQL_USER=${DB_USER}
|
||||
- MYSQL_PASSWORD=${DB_PASSWD}
|
||||
- MYSQL_ROOT_PASSWORD=$DB_ROOT_PASSWD
|
||||
- MYSQL_DATABASE=$DB_NAME
|
||||
- MYSQL_USER=$DB_USER
|
||||
- MYSQL_PASSWORD=$DB_PASSWD
|
||||
ports:
|
||||
- ${DB_PORT}:3306
|
||||
restart: "no"
|
||||
- $DB_PORT:3306
|
||||
|
||||
# redis:
|
||||
# image: redis:alpine
|
||||
# container_name: redis
|
||||
# restart: unless-stopped
|
||||
# ports:
|
||||
# - ${REDIS_PORT}:6379
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
# Build frontend
|
||||
FROM node:lts-alpine as front-build-stage
|
||||
WORKDIR /front
|
||||
COPY ./frontend/package*.json .
|
||||
COPY ./frontend ./
|
||||
RUN npm install
|
||||
COPY ./frontend .
|
||||
RUN npm run build
|
||||
|
||||
# Setup frontend
|
||||
@@ -23,12 +22,13 @@ RUN apt update && \
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F23C5A6CF475977595C89F51BA6932366A755776 && \
|
||||
apt update && \
|
||||
apt install -y --no-install-recommends \
|
||||
libmariadb3 libmariadb-dev gcc \
|
||||
gcc netcat \
|
||||
libmariadb3 libmariadb-dev \
|
||||
python3.10 python3.10-dev python3-pip && \
|
||||
apt autoremove && \
|
||||
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
|
||||
WORKDIR /back
|
||||
COPY ./pyproject.toml ./poetry.lock .
|
||||
COPY ./pyproject.toml ./poetry.lock ./
|
||||
RUN pip install --no-cache --upgrade pip && \
|
||||
pip install --no-cache poetry && \
|
||||
poetry config virtualenvs.create false && \
|
||||
|
||||
6
docker/build_local_image.sh
Executable file
6
docker/build_local_image.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
VERSION=$(cat .romm-version)
|
||||
branch_name="$(git symbolic-ref HEAD 2>/dev/null)"
|
||||
branch_name=${branch_name##refs/heads/}
|
||||
docker build -t zurdi15/romm:local-${VERSION}-${branch_name} . --file ./docker/Dockerfile
|
||||
@@ -1,11 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Run migrations and start uvicorn
|
||||
/init_back &
|
||||
|
||||
|
||||
# Start nginx
|
||||
/init_front &
|
||||
|
||||
|
||||
# Start rq worker
|
||||
# /init_worker &
|
||||
|
||||
# Wait for any process to exit
|
||||
wait -n
|
||||
|
||||
|
||||
# Exit with status of process that exited first
|
||||
exit $?
|
||||
|
||||
4
docker/init_scripts/init_worker
Executable file
4
docker/init_scripts/init_worker
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd /back
|
||||
nc -z ${REDIS_HOST:-localhost} ${REDIS_PORT:-6379} && rq worker high default low --logging_level WARN
|
||||
10
env.template
10
env.template
@@ -14,7 +14,11 @@ ROMM_DB_DRIVER=
|
||||
# Database config (only for mariadb)
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_ROOT_PASSWD=
|
||||
DB_USER=
|
||||
DB_PASSWD=
|
||||
DB_NAME=romm
|
||||
DB_USER=romm
|
||||
DB_PASSWD=
|
||||
DB_ROOT_PASSWD=
|
||||
|
||||
# Redis config (optional)
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PORT=6379
|
||||
|
||||
@@ -12,12 +12,14 @@ services:
|
||||
- DB_USER=romm-user # [Optional] Only needed if ROMM_DB_DRIVER=mariadb
|
||||
- DB_NAME=romm # [Optional] Only needed if ROMM_DB_DRIVER=mariadb. Can be optionally changed, and should match the MYSQL_DATABASE value in the mariadb container.
|
||||
- DB_PASSWD=<database password> # [Optional] Only needed if ROMM_DB_DRIVER=mariadb
|
||||
- REDIS_HOST=redis # [Optional][Experimental] Redis enables workers to run long tasks, like full library rescans, without having to wait on the main thread. Can be used with an already existent redis container
|
||||
- REDIS_PORT=6379 # [Optional][Experimental]
|
||||
- CLIENT_ID=<IGDB client id>
|
||||
- CLIENT_SECRET=<IGDB client secret>
|
||||
- STEAMGRIDDB_API_KEY=<SteamGridDB api key>
|
||||
- STEAMGRIDDB_API_KEY=<SteamGridDB api key> # [Optional]
|
||||
volumes:
|
||||
- '/path/to/library:/romm/library'
|
||||
- '/path/to/resources:/romm/resources' # [Optional] Path where roms metadata (cover) are stored
|
||||
- '/path/to/resources:/romm/resources' # [Optional] Path where roms metadata (covers) are stored
|
||||
- '/path/to/config.yml:/romm/config.yml' # [Optional] Path where config is stored
|
||||
- '/path/to/database:/romm/database' # [Optional] Only needed if ROMM_DB_DRIVER=sqlite or ROMM_DB_DRIVER not exists
|
||||
- '/path/to/logs:/romm/logs' # [Optional] Path where RomM logs are stored
|
||||
@@ -27,7 +29,7 @@ services:
|
||||
- romm_db
|
||||
restart: "unless-stopped"
|
||||
|
||||
# Only needed if ROMM_DB_DRIVER=mariadb
|
||||
# [Optional] Only needed if ROMM_DB_DRIVER=mariadb
|
||||
mariadb:
|
||||
image: mariadb:latest
|
||||
container_name: mariadb
|
||||
@@ -41,3 +43,11 @@ services:
|
||||
ports:
|
||||
- 3306:3306
|
||||
restart: "unless-stopped"
|
||||
|
||||
# [Optional][Experimental]
|
||||
redis:
|
||||
image: redis:alpine
|
||||
container_name: redis
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- 6379:6379
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
VITE_ROMM_VERSION=1.9
|
||||
1
frontend/.nvmrc
Normal file
1
frontend/.nvmrc
Normal file
@@ -0,0 +1 @@
|
||||
16
|
||||
4
frontend/package-lock.json
generated
4
frontend/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "romm",
|
||||
"version": "1.8.4",
|
||||
"version": "1.10",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "romm",
|
||||
"version": "1.8.4",
|
||||
"version": "1.9.2",
|
||||
"dependencies": {
|
||||
"@mdi/font": "7.0.96",
|
||||
"axios": "^1.3.4",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "romm",
|
||||
"version": "1.9",
|
||||
"version": "1.10",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite --host",
|
||||
|
||||
38
frontend/src/components/AdminMenu/Base.vue
Normal file
38
frontend/src/components/AdminMenu/Base.vue
Normal file
@@ -0,0 +1,38 @@
|
||||
<script setup>
|
||||
import { inject } from "vue";
|
||||
|
||||
const props = defineProps(["rom"]);
|
||||
const emitter = inject("emitter");
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<v-list rounded="0" class="pa-0">
|
||||
<v-list-item
|
||||
@click="emitter.emit('showSearchDialog', rom)"
|
||||
class="pt-4 pb-4 pr-5"
|
||||
>
|
||||
<v-list-item-title class="d-flex"
|
||||
><v-icon icon="mdi-search-web" class="mr-2" />Search
|
||||
IGDB</v-list-item-title
|
||||
>
|
||||
</v-list-item>
|
||||
<v-divider class="border-opacity-25" />
|
||||
<v-list-item
|
||||
@click="emitter.emit('showEditDialog', rom)"
|
||||
class="pt-4 pb-4 pr-5"
|
||||
>
|
||||
<v-list-item-title class="d-flex"
|
||||
><v-icon icon="mdi-pencil-box" class="mr-2" />Edit</v-list-item-title
|
||||
>
|
||||
</v-list-item>
|
||||
<v-divider class="border-opacity-25" />
|
||||
<v-list-item
|
||||
@click="emitter.emit('showDeleteDialog', rom)"
|
||||
class="pt-4 pb-4 pr-5 text-red"
|
||||
>
|
||||
<v-list-item-title class="d-flex"
|
||||
><v-icon icon="mdi-delete" class="mr-2" />Delete</v-list-item-title
|
||||
>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
</template>
|
||||
115
frontend/src/components/Dialog/DeleteRom.vue
Normal file
115
frontend/src/components/Dialog/DeleteRom.vue
Normal file
@@ -0,0 +1,115 @@
|
||||
<script setup>
|
||||
import { ref, inject } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { useDisplay } from "vuetify";
|
||||
import { deleteRomApi } from "@/services/api.js";
|
||||
|
||||
const { xs, mdAndDown, lgAndUp } = useDisplay();
|
||||
const router = useRouter();
|
||||
const show = ref(false);
|
||||
const rom = ref();
|
||||
const deleteFromFs = ref(false);
|
||||
|
||||
const emitter = inject("emitter");
|
||||
emitter.on("showDeleteDialog", (romToDelete) => {
|
||||
rom.value = romToDelete;
|
||||
show.value = true;
|
||||
});
|
||||
|
||||
async function deleteRom() {
|
||||
await deleteRomApi(rom.value, deleteFromFs.value)
|
||||
.then((response) => {
|
||||
emitter.emit("snackbarShow", {
|
||||
msg: response.data.msg,
|
||||
icon: "mdi-check-bold",
|
||||
color: "green",
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
emitter.emit("snackbarShow", {
|
||||
msg: error.response.data.detail,
|
||||
icon: "mdi-close-circle",
|
||||
color: "red",
|
||||
});
|
||||
return;
|
||||
});
|
||||
await router.push(`/platform/${rom.value.p_slug}`);
|
||||
emitter.emit("refreshGallery");
|
||||
emitter.emit("refreshPlatforms");
|
||||
show.value = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<v-dialog
|
||||
:modelValue="show"
|
||||
width="auto"
|
||||
@click:outside="show = false"
|
||||
@keydown.esc="show = false"
|
||||
no-click-animation
|
||||
persistent
|
||||
>
|
||||
<v-card
|
||||
rounded="0"
|
||||
:class="{
|
||||
'delete-content': lgAndUp,
|
||||
'delete-content-tablet': mdAndDown,
|
||||
'delete-content-mobile': xs,
|
||||
}"
|
||||
>
|
||||
<v-toolbar density="compact" class="bg-primary">
|
||||
<v-row class="align-center" no-gutters>
|
||||
<v-col cols="9" xs="9" sm="10" md="10" lg="11">
|
||||
<v-icon icon="mdi-delete" class="ml-5" />
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-btn
|
||||
@click="show = false"
|
||||
class="bg-primary"
|
||||
rounded="0"
|
||||
variant="text"
|
||||
icon="mdi-close"
|
||||
block
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-toolbar>
|
||||
<v-divider class="border-opacity-25" :thickness="1" />
|
||||
|
||||
<v-card-text class="bg-secondary">
|
||||
<v-row class="justify-center pa-2" no-gutters>
|
||||
<span>Deleting {{ rom.file_name }}. Do you confirm?</span>
|
||||
</v-row>
|
||||
<v-row class="justify-center pa-2" no-gutters>
|
||||
<v-btn @click="show = false">Cancel</v-btn>
|
||||
<v-btn @click="deleteRom()" class="text-red ml-5">Confirm</v-btn>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
|
||||
<v-divider class="border-opacity-25" :thickness="1" />
|
||||
<v-toolbar class="bg-primary" density="compact">
|
||||
<v-checkbox
|
||||
v-model="deleteFromFs"
|
||||
label="Remove from filesystem"
|
||||
class="ml-3"
|
||||
hide-details
|
||||
/>
|
||||
</v-toolbar>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.delete-content {
|
||||
width: 900px;
|
||||
}
|
||||
|
||||
.delete-content-tablet {
|
||||
width: 570px;
|
||||
}
|
||||
|
||||
.delete-content-mobile {
|
||||
width: 85vw;
|
||||
}
|
||||
</style>
|
||||
148
frontend/src/components/Dialog/EditRom.vue
Normal file
148
frontend/src/components/Dialog/EditRom.vue
Normal file
@@ -0,0 +1,148 @@
|
||||
<script setup>
|
||||
import { ref, inject } from "vue";
|
||||
import { useDisplay } from "vuetify";
|
||||
import { updateRomApi } from "@/services/api.js";
|
||||
|
||||
const { xs, mdAndDown, lgAndUp } = useDisplay();
|
||||
const show = ref(false);
|
||||
const rom = ref();
|
||||
const renameAsIGDB = ref(false);
|
||||
|
||||
const emitter = inject("emitter");
|
||||
emitter.on("showEditDialog", (romToEdit) => {
|
||||
show.value = true;
|
||||
rom.value = romToEdit;
|
||||
});
|
||||
|
||||
async function updateRom(updatedData = { ...rom.value }) {
|
||||
show.value = false;
|
||||
emitter.emit("showLoadingDialog", { loading: true, scrim: true });
|
||||
|
||||
await updateRomApi(rom.value, updatedData, renameAsIGDB.value)
|
||||
.then((response) => {
|
||||
emitter.emit("snackbarShow", {
|
||||
msg: response.data.msg,
|
||||
icon: "mdi-check-bold",
|
||||
color: "green",
|
||||
});
|
||||
emitter.emit("refreshGallery");
|
||||
})
|
||||
.catch((error) => {
|
||||
emitter.emit("snackbarShow", {
|
||||
msg: error.response.data.detail,
|
||||
icon: "mdi-close-circle",
|
||||
color: "red",
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
emitter.emit("showLoadingDialog", { loading: false, scrim: false });
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<v-dialog
|
||||
:modelValue="show"
|
||||
scroll-strategy="none"
|
||||
width="auto"
|
||||
:scrim="false"
|
||||
@click:outside="show = false"
|
||||
@keydown.esc="show = false"
|
||||
no-click-animation
|
||||
persistent
|
||||
>
|
||||
<v-card
|
||||
rounded="0"
|
||||
:class="{
|
||||
'edit-content': lgAndUp,
|
||||
'edit-content-tablet': mdAndDown,
|
||||
'edit-content-mobile': xs,
|
||||
}"
|
||||
>
|
||||
<v-toolbar density="compact" class="bg-primary">
|
||||
<v-row class="align-center" no-gutters>
|
||||
<v-col cols="9" xs="9" sm="10" md="10" lg="11">
|
||||
<v-icon icon="mdi-pencil-box" class="ml-5" />
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-btn
|
||||
@click="show = false"
|
||||
class="bg-primary"
|
||||
rounded="0"
|
||||
variant="text"
|
||||
icon="mdi-close"
|
||||
block
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-toolbar>
|
||||
<v-divider class="border-opacity-25" :thickness="1" />
|
||||
|
||||
<v-card-text class="bg-secondary scroll">
|
||||
<v-row class="justify-center pa-2" no-gutters>
|
||||
<v-text-field
|
||||
@keyup.enter="updateRom()"
|
||||
v-model="rom.r_name"
|
||||
label="Name"
|
||||
variant="outlined"
|
||||
required
|
||||
hide-details
|
||||
/>
|
||||
</v-row>
|
||||
<v-row class="justify-center pa-2" no-gutters>
|
||||
<v-text-field
|
||||
@keyup.enter="updateRom()"
|
||||
v-model="rom.file_name"
|
||||
label="File name"
|
||||
variant="outlined"
|
||||
required
|
||||
hide-details
|
||||
/>
|
||||
</v-row>
|
||||
<v-row class="justify-center pa-2" no-gutters>
|
||||
<v-textarea
|
||||
@keyup.enter="updateRom()"
|
||||
v-model="rom.summary"
|
||||
label="Summary"
|
||||
variant="outlined"
|
||||
required
|
||||
hide-details
|
||||
/>
|
||||
</v-row>
|
||||
<v-row class="justify-center pa-2" no-gutters>
|
||||
<v-file-input
|
||||
@keyup.enter="updateRom()"
|
||||
label="Custom cover [Coming soon]"
|
||||
prepend-inner-icon="mdi-image"
|
||||
prepend-icon=""
|
||||
variant="outlined"
|
||||
disabled
|
||||
hide-details
|
||||
/>
|
||||
</v-row>
|
||||
<v-row class="justify-center pa-2" no-gutters>
|
||||
<v-btn @click="show = false">Cancel</v-btn>
|
||||
<v-btn
|
||||
@click="updateRom()"
|
||||
class="text-rommGreen ml-5"
|
||||
>Apply</v-btn
|
||||
>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.edit-content {
|
||||
width: 900px;
|
||||
}
|
||||
|
||||
.edit-content-tablet {
|
||||
width: 570px;
|
||||
}
|
||||
|
||||
.edit-content-mobile {
|
||||
width: 85vw;
|
||||
}
|
||||
</style>
|
||||
29
frontend/src/components/Dialog/Loading.vue
Normal file
29
frontend/src/components/Dialog/Loading.vue
Normal file
@@ -0,0 +1,29 @@
|
||||
<script setup>
|
||||
import { ref, inject } from "vue";
|
||||
|
||||
const show = ref(false);
|
||||
const scrim = ref(false);
|
||||
|
||||
const emitter = inject("emitter");
|
||||
emitter.on("showLoadingDialog", (args) => {
|
||||
show.value = args.loading;
|
||||
scrim.value = args.scrim;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<v-dialog
|
||||
:modelValue="show"
|
||||
scroll-strategy="none"
|
||||
width="auto"
|
||||
:scrim="false"
|
||||
persistent
|
||||
>
|
||||
<v-progress-circular
|
||||
:width="3"
|
||||
:size="70"
|
||||
color="rommAccent1"
|
||||
indeterminate
|
||||
/>
|
||||
</v-dialog>
|
||||
</template>
|
||||
241
frontend/src/components/Dialog/SearchRom.vue
Normal file
241
frontend/src/components/Dialog/SearchRom.vue
Normal file
@@ -0,0 +1,241 @@
|
||||
<script setup>
|
||||
import { ref, inject, onBeforeUnmount } from "vue";
|
||||
import { useDisplay } from "vuetify";
|
||||
import { updateRomApi, searchRomIGDBApi } from "@/services/api.js";
|
||||
|
||||
const { xs, mdAndDown, lgAndUp } = useDisplay();
|
||||
const show = ref(false);
|
||||
const rom = ref();
|
||||
const renameAsIGDB = ref(false);
|
||||
const searching = ref(false);
|
||||
const searchTerm = ref("");
|
||||
const searchBy = ref("Name");
|
||||
const matchedRoms = ref([]);
|
||||
|
||||
const emitter = inject("emitter");
|
||||
emitter.on("showSearchDialog", (romToSearch) => {
|
||||
rom.value = romToSearch;
|
||||
searchTerm.value = romToSearch.file_name_no_tags;
|
||||
show.value = true;
|
||||
searchRomIGDB();
|
||||
});
|
||||
|
||||
async function searchRomIGDB() {
|
||||
if (!searching.value) {
|
||||
searching.value = true;
|
||||
await searchRomIGDBApi(searchTerm.value, searchBy.value, rom.value)
|
||||
.then((response) => {
|
||||
matchedRoms.value = response.data.roms;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
})
|
||||
.finally(() => {
|
||||
searching.value = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function updateRom(updatedData = { ...rom.value }) {
|
||||
show.value = false;
|
||||
emitter.emit("showLoadingDialog", { loading: true, scrim: true });
|
||||
|
||||
await updateRomApi(rom.value, updatedData, renameAsIGDB.value)
|
||||
.then((response) => {
|
||||
emitter.emit("snackbarShow", {
|
||||
msg: response.data.msg,
|
||||
icon: "mdi-check-bold",
|
||||
color: "green",
|
||||
});
|
||||
emitter.emit("refreshGallery");
|
||||
})
|
||||
.catch((error) => {
|
||||
emitter.emit("snackbarShow", {
|
||||
msg: error.response.data.detail,
|
||||
icon: "mdi-close-circle",
|
||||
color: "red",
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
emitter.emit("showLoadingDialog", { loading: false, scrim: false });
|
||||
});
|
||||
}
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
emitter.off("showSearchDialog");
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<v-dialog
|
||||
:modelValue="show"
|
||||
scroll-strategy="none"
|
||||
width="auto"
|
||||
:scrim="false"
|
||||
@click:outside="show = false"
|
||||
@keydown.esc="show = false"
|
||||
no-click-animation
|
||||
persistent
|
||||
>
|
||||
<v-card
|
||||
:class="{
|
||||
'search-content': lgAndUp,
|
||||
'search-content-tablet': mdAndDown,
|
||||
'search-content-mobile': xs,
|
||||
}"
|
||||
rounded="0"
|
||||
>
|
||||
<v-toolbar density="compact" class="bg-primary">
|
||||
<v-row class="align-center" no-gutters>
|
||||
<v-col cols="9" xs="9" sm="10" md="10" lg="11">
|
||||
<v-icon icon="mdi-search-web" class="ml-5" />
|
||||
<v-chip class="ml-5 text-rommAccent1" variant="outlined" label
|
||||
>IGDB</v-chip
|
||||
>
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-btn
|
||||
@click="show = false"
|
||||
class="bg-primary"
|
||||
rounded="0"
|
||||
variant="text"
|
||||
icon="mdi-close"
|
||||
block
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-toolbar>
|
||||
<v-divider class="border-opacity-25" :thickness="1" />
|
||||
|
||||
<v-toolbar density="compact" class="bg-primary">
|
||||
<v-row class="align-center" no-gutters>
|
||||
<v-col cols="7" xs="7" sm="8" md="8" lg="9">
|
||||
<v-text-field
|
||||
@keyup.enter="searchRomIGDB()"
|
||||
@click:clear="searchTerm = ''"
|
||||
v-model="searchTerm"
|
||||
label="search"
|
||||
hide-details
|
||||
clearable
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="3" xs="3" sm="2" md="2" lg="2">
|
||||
<v-select
|
||||
label="by"
|
||||
:items="['ID', 'Name']"
|
||||
v-model="searchBy"
|
||||
hide-details
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="2" xs="2" sm="2" md="2" lg="1">
|
||||
<v-btn
|
||||
type="submit"
|
||||
@click="searchRomIGDB()"
|
||||
class="bg-primary"
|
||||
rounded="0"
|
||||
variant="text"
|
||||
icon="mdi-search-web"
|
||||
block
|
||||
:disabled="searching"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-toolbar>
|
||||
|
||||
<v-card-text class="pa-1 scroll bg-secondary">
|
||||
<v-row
|
||||
class="justify-center loader-searching"
|
||||
v-show="searching"
|
||||
no-gutters
|
||||
>
|
||||
<v-progress-circular
|
||||
:width="2"
|
||||
:size="40"
|
||||
color="rommAccent1"
|
||||
indeterminate
|
||||
/>
|
||||
</v-row>
|
||||
<v-row
|
||||
class="justify-center no-results-searching"
|
||||
v-show="!searching && matchedRoms.length == 0"
|
||||
no-gutters
|
||||
>
|
||||
<span>No results found</span>
|
||||
</v-row>
|
||||
<v-row no-gutters>
|
||||
<v-col
|
||||
class="pa-1"
|
||||
cols="4"
|
||||
xs="4"
|
||||
sm="3"
|
||||
md="3"
|
||||
lg="2"
|
||||
v-show="!searching"
|
||||
v-for="rom in matchedRoms"
|
||||
:key="rom.file_name"
|
||||
>
|
||||
<v-hover v-slot="{ isHovering, props }">
|
||||
<v-card
|
||||
@click="updateRom((updatedData = rom))"
|
||||
v-bind="props"
|
||||
:class="{ 'on-hover': isHovering }"
|
||||
:elevation="isHovering ? 20 : 3"
|
||||
>
|
||||
<v-tooltip activator="parent" location="top" class="tooltip">{{
|
||||
rom.r_name
|
||||
}}</v-tooltip>
|
||||
<v-img v-bind="props" :src="rom.url_cover" cover />
|
||||
<v-card-text>
|
||||
<v-row class="pa-1">
|
||||
<span class="d-inline-block text-truncate">{{
|
||||
rom.r_name
|
||||
}}</span>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-hover>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
|
||||
<v-divider class="border-opacity-25" :thickness="1" />
|
||||
<v-toolbar class="bg-primary" density="compact">
|
||||
<v-checkbox
|
||||
v-model="renameAsIGDB"
|
||||
label="Rename rom"
|
||||
class="ml-3"
|
||||
hide-details
|
||||
/>
|
||||
</v-toolbar>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.tooltip :deep(.v-overlay__content) {
|
||||
background: rgba(201, 201, 201, 0.98) !important;
|
||||
color: rgb(41, 41, 41) !important;
|
||||
}
|
||||
.scroll {
|
||||
overflow-y: scroll;
|
||||
}
|
||||
.loader-searching,
|
||||
.no-results-searching {
|
||||
margin-top: 200px;
|
||||
}
|
||||
|
||||
.search-content {
|
||||
width: 900px;
|
||||
height: 640px;
|
||||
}
|
||||
|
||||
.search-content-tablet {
|
||||
width: 570px;
|
||||
height: 640px;
|
||||
}
|
||||
|
||||
.search-content-mobile {
|
||||
width: 85vw;
|
||||
height: 640px;
|
||||
}
|
||||
</style>
|
||||
@@ -2,12 +2,12 @@
|
||||
import { ref } from "vue";
|
||||
import { downloadRomApi } from "@/services/api.js";
|
||||
import useDownloadStore from "@/stores/download.js";
|
||||
|
||||
const downloadStore = useDownloadStore();
|
||||
import AdminMenu from "@/components/AdminMenu/Base.vue";
|
||||
|
||||
// Props
|
||||
const props = defineProps(["rom"]);
|
||||
const saveFiles = ref(false);
|
||||
const downloadStore = useDownloadStore();
|
||||
const downloadUrl = `${window.location.origin}${props.rom.download_path}`;
|
||||
</script>
|
||||
|
||||
@@ -18,9 +18,10 @@ const downloadUrl = `${window.location.origin}${props.rom.download_path}`;
|
||||
<template v-if="rom.multi">
|
||||
<v-btn
|
||||
@click="downloadRomApi(rom)"
|
||||
:disabled="downloadStore.value.includes(rom.file_name)"
|
||||
:disabled="downloadStore.value.includes(rom.id)"
|
||||
icon="mdi-download"
|
||||
size="x-small"
|
||||
rounded="0"
|
||||
variant="text"
|
||||
/>
|
||||
</template>
|
||||
@@ -30,12 +31,14 @@ const downloadUrl = `${window.location.origin}${props.rom.download_path}`;
|
||||
download
|
||||
icon="mdi-download"
|
||||
size="x-small"
|
||||
rounded="0"
|
||||
variant="text"
|
||||
/>
|
||||
</template>
|
||||
<v-btn
|
||||
icon="mdi-content-save-all"
|
||||
size="x-small"
|
||||
rounded="0"
|
||||
variant="text"
|
||||
:disabled="!saveFiles"
|
||||
/>
|
||||
@@ -48,39 +51,11 @@ const downloadUrl = `${window.location.origin}${props.rom.download_path}`;
|
||||
v-bind="props"
|
||||
icon="mdi-dots-vertical"
|
||||
size="x-small"
|
||||
rounded="0"
|
||||
variant="text"
|
||||
disabled
|
||||
/>
|
||||
</template>
|
||||
<v-list rounded="0" class="pa-0">
|
||||
<v-list-item @click="searchRomIGDB()" class="pt-4 pb-4 pr-5">
|
||||
<v-list-item-title class="d-flex"
|
||||
><v-icon icon="mdi-search-web" class="mr-2" />Search
|
||||
IGDB</v-list-item-title
|
||||
>
|
||||
</v-list-item>
|
||||
<v-divider class="border-opacity-25" />
|
||||
<v-list-item @click="dialogEditRom = true" class="pt-4 pb-4 pr-5">
|
||||
<v-list-item-title class="d-flex"
|
||||
><v-icon
|
||||
icon="mdi-pencil-box"
|
||||
class="mr-2"
|
||||
/>Edit</v-list-item-title
|
||||
>
|
||||
</v-list-item>
|
||||
<v-divider class="border-opacity-25" />
|
||||
<v-list-item
|
||||
@click="dialogDeleteRom = true"
|
||||
class="pt-4 pb-4 pr-5 text-red"
|
||||
>
|
||||
<v-list-item-title class="d-flex"
|
||||
><v-icon
|
||||
icon="mdi-delete"
|
||||
class="mr-2"
|
||||
/>Delete</v-list-item-title
|
||||
>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
<admin-menu :rom="rom" />
|
||||
</v-menu>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
|
||||
@@ -14,7 +14,7 @@ const props = defineProps(["rom", "isHovering", "hoverProps", "size"]);
|
||||
>
|
||||
<v-progress-linear
|
||||
color="rommAccent1"
|
||||
:active="downloadStore.value.includes(rom.file_name)"
|
||||
:active="downloadStore.value.includes(rom.id)"
|
||||
:indeterminate="true"
|
||||
absolute
|
||||
/>
|
||||
|
||||
@@ -5,7 +5,7 @@ const props = defineProps(["image"]);
|
||||
<template>
|
||||
<v-card id="header-background" position="absolute" rounded="0" flat>
|
||||
<v-img
|
||||
:src="`/assets/romm/resources/${image}?reload=${Date.now()}`"
|
||||
:src="`/assets/romm/resources/${image}`"
|
||||
id="header-background-img"
|
||||
cover
|
||||
/>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { ref, inject } from "vue";
|
||||
import { downloadRomApi } from "@/services/api.js";
|
||||
import useDownloadStore from "@/stores/download.js";
|
||||
import AdminMenu from "@/components/AdminMenu/Base.vue";
|
||||
|
||||
// Props
|
||||
const emitter = inject("emitter");
|
||||
const props = defineProps(["rom"]);
|
||||
const saveFiles = ref(false);
|
||||
const downloadStore = useDownloadStore();
|
||||
@@ -43,7 +45,7 @@ const downloadUrl = `${window.location.origin}${props.rom.download_path}`;
|
||||
<v-avatar :rounded="0">
|
||||
<v-progress-linear
|
||||
color="rommAccent1"
|
||||
:active="downloadStore.value.includes(rom.file_name)"
|
||||
:active="downloadStore.value.includes(rom.id)"
|
||||
:indeterminate="true"
|
||||
absolute
|
||||
/>
|
||||
@@ -67,9 +69,10 @@ const downloadUrl = `${window.location.origin}${props.rom.download_path}`;
|
||||
<template v-if="rom.multi">
|
||||
<v-btn
|
||||
@click="downloadRomApi(rom)"
|
||||
:disabled="downloadStore.value.includes(rom.file_name)"
|
||||
:disabled="downloadStore.value.includes(rom.id)"
|
||||
icon="mdi-download"
|
||||
size="x-small"
|
||||
rounded="0"
|
||||
variant="text"
|
||||
/>
|
||||
</template>
|
||||
@@ -79,12 +82,14 @@ const downloadUrl = `${window.location.origin}${props.rom.download_path}`;
|
||||
download
|
||||
icon="mdi-download"
|
||||
size="x-small"
|
||||
rounded="0"
|
||||
variant="text"
|
||||
/>
|
||||
</template>
|
||||
<v-btn
|
||||
icon="mdi-content-save-all"
|
||||
size="x-small"
|
||||
rounded="0"
|
||||
variant="text"
|
||||
:disabled="!saveFiles"
|
||||
/>
|
||||
@@ -95,39 +100,11 @@ const downloadUrl = `${window.location.origin}${props.rom.download_path}`;
|
||||
v-bind="props"
|
||||
icon="mdi-dots-vertical"
|
||||
size="x-small"
|
||||
rounded="0"
|
||||
variant="text"
|
||||
disabled
|
||||
/>
|
||||
</template>
|
||||
<v-list rounded="0" class="pa-0">
|
||||
<v-list-item @click="searchRomIGDB()" class="pt-4 pb-4 pr-5">
|
||||
<v-list-item-title class="d-flex"
|
||||
><v-icon icon="mdi-search-web" class="mr-2" />Search
|
||||
IGDB</v-list-item-title
|
||||
>
|
||||
</v-list-item>
|
||||
<v-divider class="border-opacity-25" />
|
||||
<v-list-item @click="dialogEditRom = true" class="pt-4 pb-4 pr-5">
|
||||
<v-list-item-title class="d-flex"
|
||||
><v-icon
|
||||
icon="mdi-pencil-box"
|
||||
class="mr-2"
|
||||
/>Edit</v-list-item-title
|
||||
>
|
||||
</v-list-item>
|
||||
<v-divider class="border-opacity-25" />
|
||||
<v-list-item
|
||||
@click="dialogDeleteRom = true"
|
||||
class="pt-4 pb-4 pr-5 text-red"
|
||||
>
|
||||
<v-list-item-title class="d-flex"
|
||||
><v-icon
|
||||
icon="mdi-delete"
|
||||
class="mr-2"
|
||||
/>Delete</v-list-item-title
|
||||
>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
<admin-menu :rom="rom" />
|
||||
</v-menu>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
@@ -16,9 +16,9 @@ emitter.on("snackbarShow", (snackbar) => {
|
||||
<template>
|
||||
<v-snackbar
|
||||
v-model="snackbarShow"
|
||||
:timeout="4000"
|
||||
:timeout="2000"
|
||||
location="top"
|
||||
color="notification"
|
||||
color="tooltip"
|
||||
>
|
||||
<v-icon
|
||||
:icon="snackbarStatus.icon"
|
||||
@@ -27,9 +27,9 @@ emitter.on("snackbarShow", (snackbar) => {
|
||||
/>
|
||||
{{ snackbarStatus.msg }}
|
||||
<template v-slot:actions>
|
||||
<v-btn @click="snackbarShow = false" variant="text"
|
||||
><v-icon icon="mdi-close"
|
||||
/></v-btn>
|
||||
<v-btn @click="snackbarShow = false" variant="text">
|
||||
<v-icon icon="mdi-close"/>
|
||||
</v-btn>
|
||||
</template>
|
||||
</v-snackbar>
|
||||
</template>
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import PlatformIcon from "./PlatformIcon.vue";
|
||||
|
||||
const props = defineProps(["platform"]);
|
||||
const platformIconUrl = ref(`/assets/platforms/${props.platform.slug.toLowerCase()}.ico`);
|
||||
|
||||
function onImageError() {
|
||||
platformIconUrl.value = "/assets/platforms/default.ico";
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -23,7 +18,7 @@ function onImageError() {
|
||||
</v-row>
|
||||
<v-row class="pa-1 justify-center">
|
||||
<v-avatar :rounded="0" size="100%" class="mt-2">
|
||||
<v-img :src="platformIconUrl" @error="onImageError"></v-img>
|
||||
<platform-icon :platform="platform"></platform-icon>
|
||||
</v-avatar>
|
||||
<v-chip
|
||||
class="bg-chip position-absolute"
|
||||
|
||||
14
frontend/src/components/Platform/PlatformIcon.vue
Normal file
14
frontend/src/components/Platform/PlatformIcon.vue
Normal file
@@ -0,0 +1,14 @@
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
|
||||
const props = defineProps(["platform"]);
|
||||
const platformIconUrl = ref(`/assets/platforms/${props.platform.slug.toLowerCase()}.ico`);
|
||||
|
||||
function onImageError() {
|
||||
platformIconUrl.value = "/assets/platforms/default.ico";
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<v-img :src="platformIconUrl" @error="onImageError"></v-img>
|
||||
</template>
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup>
|
||||
// Props
|
||||
const props = defineProps(["platform", "rail"]);
|
||||
import PlatformIcon from "./PlatformIcon.vue";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -15,7 +16,7 @@ const props = defineProps(["platform", "rail"]);
|
||||
}}</span>
|
||||
<template v-slot:prepend>
|
||||
<v-avatar :rounded="0" size="40">
|
||||
<v-img :src="`/assets/platforms/${platform.slug.toLowerCase()}.ico`"></v-img>
|
||||
<platform-icon :platform="platform"></platform-icon>
|
||||
</v-avatar>
|
||||
</template>
|
||||
<template v-slot:append>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import axios from "axios";
|
||||
import useDownloadStore from "@/stores/download.js";
|
||||
import socket from "@/services/socket.js";
|
||||
|
||||
export async function fetchPlatformsApi() {
|
||||
return axios.get("/api/platforms");
|
||||
@@ -20,35 +21,52 @@ export async function fetchRomApi(platform, rom) {
|
||||
return axios.get(`/api/platforms/${platform}/roms/${rom}`);
|
||||
}
|
||||
|
||||
function clearRomFromDownloads({ id }) {
|
||||
const downloadStore = useDownloadStore();
|
||||
downloadStore.remove(id);
|
||||
|
||||
// Disconnect socket when no more downloads are in progress
|
||||
if (downloadStore.value.length === 0) socket.disconnect();
|
||||
}
|
||||
|
||||
// Listen for multi-file download completion events
|
||||
socket.on("download:complete", clearRomFromDownloads);
|
||||
|
||||
// Used only for multi-file downloads
|
||||
export async function downloadRomApi(rom, files) {
|
||||
// Force download of all multirom-parts when no part is selected
|
||||
if (files != undefined && files.length == 0) {
|
||||
files = undefined;
|
||||
}
|
||||
|
||||
const downloadStore = useDownloadStore();
|
||||
downloadStore.add(rom.file_name);
|
||||
const a = document.createElement("a");
|
||||
a.href = `/api/platforms/${rom.p_slug}/roms/${rom.id}/download?files=${
|
||||
files || rom.files
|
||||
}`;
|
||||
a.download = `${rom.r_name}.zip`;
|
||||
a.click();
|
||||
|
||||
axios
|
||||
.get(
|
||||
`/api/platforms/${rom.p_slug}/roms/${rom.id}/download?files=${
|
||||
files || rom.files
|
||||
}`,
|
||||
{
|
||||
responseType: "blob",
|
||||
}
|
||||
)
|
||||
.then((response) => {
|
||||
const a = document.createElement("a");
|
||||
a.href = window.URL.createObjectURL(new Blob([response.data]));
|
||||
a.download = `${rom.r_name}.zip`;
|
||||
a.click();
|
||||
if (!socket.connected) socket.connect();
|
||||
useDownloadStore().add(rom.id);
|
||||
|
||||
downloadStore.remove(rom.file_name);
|
||||
});
|
||||
// Clear download state after 60 seconds in case error/timeout
|
||||
setTimeout(() => {
|
||||
clearRomFromDownloads(rom);
|
||||
}, 60 * 1000);
|
||||
}
|
||||
|
||||
export async function updateRomApi(rom, updatedRom) {
|
||||
export async function updateRomApi(rom, updatedData, renameAsIGDB) {
|
||||
const updatedRom = {
|
||||
r_igdb_id: updatedData.r_igdb_id,
|
||||
r_slug: updatedData.r_slug,
|
||||
summary: updatedData.summary,
|
||||
url_cover: updatedData.url_cover,
|
||||
url_screenshots: updatedData.url_screenshots,
|
||||
r_name: updatedData.r_name,
|
||||
file_name: renameAsIGDB
|
||||
? rom.file_name.replace(rom.file_name_no_tags, updatedData.r_name)
|
||||
: updatedData.file_name,
|
||||
};
|
||||
return axios.patch(`/api/platforms/${rom.p_slug}/roms/${rom.id}`, {
|
||||
updatedRom,
|
||||
});
|
||||
|
||||
@@ -4,11 +4,11 @@ export default defineStore("download", {
|
||||
state: () => ({ value: [] }),
|
||||
|
||||
actions: {
|
||||
add(filename) {
|
||||
this.value.push(filename);
|
||||
add(id) {
|
||||
this.value.push(id);
|
||||
},
|
||||
remove(filename) {
|
||||
this.value.splice(this.value.indexOf(filename), 1);
|
||||
remove(id) {
|
||||
this.value.splice(this.value.indexOf(id), 1);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user