mirror of
https://github.com/rommapp/romm.git
synced 2025-12-22 10:27:13 +00:00
added basic platform info from the igdb api call
This commit is contained in:
@@ -2,12 +2,12 @@
|
||||
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
|
||||
version: 0.1
|
||||
cli:
|
||||
version: 1.22.4
|
||||
version: 1.22.8
|
||||
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
|
||||
plugins:
|
||||
sources:
|
||||
- id: trunk
|
||||
ref: v1.6.2
|
||||
ref: v1.6.5
|
||||
uri: https://github.com/trunk-io/plugins
|
||||
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
|
||||
runtimes:
|
||||
@@ -18,25 +18,25 @@ runtimes:
|
||||
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
|
||||
lint:
|
||||
enabled:
|
||||
- markdownlint@0.41.0
|
||||
- eslint@9.9.1
|
||||
- actionlint@1.7.1
|
||||
- bandit@1.7.9
|
||||
- black@24.8.0
|
||||
- checkov@3.2.239
|
||||
- markdownlint@0.42.0
|
||||
- eslint@9.14.0
|
||||
- actionlint@1.7.4
|
||||
- bandit@1.7.10
|
||||
- black@24.10.0
|
||||
- checkov@3.2.296
|
||||
- git-diff-check
|
||||
- isort@5.13.2
|
||||
- mypy@1.13.0
|
||||
- osv-scanner@1.8.4
|
||||
- osv-scanner@1.9.1
|
||||
- oxipng@9.1.2
|
||||
- prettier@3.3.3
|
||||
- ruff@0.6.3
|
||||
- ruff@0.7.3
|
||||
- shellcheck@0.10.0
|
||||
- shfmt@3.6.0
|
||||
- svgo@3.3.2
|
||||
- taplo@0.9.3
|
||||
- trivy@0.54.1
|
||||
- trufflehog@3.81.10
|
||||
- trivy@0.56.2
|
||||
- trufflehog@3.83.6
|
||||
- yamllint@1.35.1
|
||||
ignore:
|
||||
- linters: [ALL]
|
||||
|
||||
40
backend/alembic/versions/0027_platforms_data.py
Normal file
40
backend/alembic/versions/0027_platforms_data.py
Normal file
@@ -0,0 +1,40 @@
|
||||
"""platforms_data
|
||||
|
||||
Revision ID: 0027_platforms_data
|
||||
Revises: 0026_romuser_status_fields
|
||||
Create Date: 2024-11-17 23:05:31.038917
|
||||
|
||||
"""
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "0027_platforms_data"
|
||||
down_revision = "0026_romuser_status_fields"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("platforms", schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column("category", sa.String(length=50), nullable=True))
|
||||
batch_op.add_column(sa.Column("generation", sa.Integer(), nullable=True))
|
||||
batch_op.add_column(sa.Column("family", sa.String(length=1000), nullable=True))
|
||||
batch_op.add_column(sa.Column("url", sa.String(length=1000), nullable=True))
|
||||
batch_op.add_column(
|
||||
sa.Column("url_logo", sa.String(length=1000), nullable=True)
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table("platforms", schema=None) as batch_op:
|
||||
batch_op.drop_column("url_logo")
|
||||
batch_op.drop_column("url")
|
||||
batch_op.drop_column("family")
|
||||
batch_op.drop_column("generation")
|
||||
batch_op.drop_column("category")
|
||||
# ### end Alembic commands ###
|
||||
@@ -35,6 +35,12 @@ class IGDBPlatform(TypedDict):
|
||||
slug: str
|
||||
igdb_id: int | None
|
||||
name: NotRequired[str]
|
||||
category: NotRequired[str]
|
||||
generation: NotRequired[str]
|
||||
family: NotRequired[int]
|
||||
url: NotRequired[str]
|
||||
url_logo: NotRequired[str]
|
||||
logo_path: NotRequired[str]
|
||||
|
||||
|
||||
class IGDBAgeRating(TypedDict):
|
||||
@@ -323,13 +329,17 @@ class IGDBBaseHandler(MetadataHandler):
|
||||
self.platform_endpoint,
|
||||
data=f'fields {",".join(self.platforms_fields)}; where slug="{slug.lower()}";',
|
||||
)
|
||||
|
||||
platform = pydash.get(platforms, "[0]", None)
|
||||
if platform:
|
||||
return IGDBPlatform(
|
||||
igdb_id=platform["id"],
|
||||
igdb_id=platform.get("id", None),
|
||||
slug=slug,
|
||||
name=platform["name"],
|
||||
name=platform.get("name", slug),
|
||||
category=IGDB_PLATFORM_CATEGORIES.get(platform["category"], "Unknown"),
|
||||
generation=platform.get("generation", None),
|
||||
family=platform.get("family", None),
|
||||
url=platform.get("url", None),
|
||||
url_logo=platform.get("url_logo", None),
|
||||
)
|
||||
|
||||
# Check if platform is a version if not found
|
||||
@@ -651,7 +661,15 @@ class TwitchAuth:
|
||||
return token
|
||||
|
||||
|
||||
PLATFORMS_FIELDS = ["id", "name"]
|
||||
PLATFORMS_FIELDS = [
|
||||
"id",
|
||||
"name",
|
||||
"category",
|
||||
"generation",
|
||||
"url",
|
||||
# "platform_families.name",
|
||||
# "platform_logos.image_id",
|
||||
]
|
||||
|
||||
GAMES_FIELDS = [
|
||||
"id",
|
||||
@@ -931,6 +949,15 @@ IGDB_PLATFORM_LIST = [
|
||||
{"slug": "airconsole", "name": "AirConsole"},
|
||||
]
|
||||
|
||||
IGDB_PLATFORM_CATEGORIES: dict[int, str] = {
|
||||
1: "Console",
|
||||
2: "Arcade",
|
||||
3: "Platform",
|
||||
4: "Operative System",
|
||||
5: "Portable Console",
|
||||
6: "Computer",
|
||||
}
|
||||
|
||||
IGDB_AGE_RATINGS: dict[int, IGDBAgeRating] = {
|
||||
1: {
|
||||
"rating": "Three",
|
||||
|
||||
@@ -95,6 +95,8 @@ async def scan_platform(
|
||||
if "igdb" in metadata_sources
|
||||
else IGDBPlatform(igdb_id=None, slug=platform_attrs["slug"])
|
||||
)
|
||||
for key, value in igdb_platform.items():
|
||||
log.debug(key + ": " + str(value))
|
||||
moby_platform = (
|
||||
meta_moby_handler.get_platform(platform_attrs["slug"])
|
||||
if "moby" in metadata_sources
|
||||
|
||||
@@ -21,6 +21,11 @@ class Platform(BaseModel):
|
||||
slug: Mapped[str] = mapped_column(String(length=50))
|
||||
fs_slug: Mapped[str] = mapped_column(String(length=50))
|
||||
name: Mapped[str] = mapped_column(String(length=400))
|
||||
category: Mapped[str | None] = mapped_column(String(length=50), default="")
|
||||
generation: Mapped[int | None]
|
||||
family: Mapped[str | None] = mapped_column(String(length=1000), default="")
|
||||
url: Mapped[str | None] = mapped_column(String(length=1000), default="")
|
||||
url_logo: Mapped[str | None] = mapped_column(String(length=1000), default="")
|
||||
logo_path: Mapped[str | None] = mapped_column(String(length=1000), default="")
|
||||
|
||||
roms: Mapped[list[Rom]] = relationship(back_populates="platform")
|
||||
|
||||
Reference in New Issue
Block a user