Skip to content

Commit

Permalink
Merge pull request #248 from zurdi15/develop
Browse files Browse the repository at this point in the history
v1.8.3
  • Loading branch information
zurdi15 authored May 17, 2023
2 parents 1fcd61a + 0f265a5 commit a71416c
Show file tree
Hide file tree
Showing 43 changed files with 568 additions and 123 deletions.
Binary file added .github/screenshots/details.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/screenshots/gallery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/screenshots/home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/screenshots/m_details.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/screenshots/m_gallery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/screenshots/m_home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/screenshots/m_search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/screenshots/search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# v1.8.3 (_17-05-2023_)

## Added
- Added platforms to home page.
- Added the scan log in real time in the scan section.
- Added fast scan button in the gallery to direct scan the current platform. Solves [#250](https://github.com/zurdi15/romm/issues/250)
- Added Game and Watch support. Partially solves [#245](https://github.com/zurdi15/romm/issues/245)
- Added Amstrad CPC support. Partially solves [#245](https://github.com/zurdi15/romm/issues/245)
- Added Game and Gear support. Partially solves [#245](https://github.com/zurdi15/romm/issues/245)
- Added PC-98 support. Partially solves [#245](https://github.com/zurdi15/romm/issues/245)
- Added Pokemini support. Partially solves [#245](https://github.com/zurdi15/romm/issues/245)
- Added DOOM support. Partially solves [#245](https://github.com/zurdi15/romm/issues/245)

## Fixed
- Fixed a bug that caused scan to run twice. Solves [#221](https://github.com/zurdi15/romm/issues/221)
- Improved RomM initial setup logs for bad folder structure configurations. Solves [#217](https://github.com/zurdi15/romm/issues/217)
- Improved gallery loading when switching between view modes.

<br>

# v1.8.2 (_09-05-2023_)

## Added
Expand Down
2 changes: 2 additions & 0 deletions DEVELOPER-SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ 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
poetry install
```

Expand Down
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,30 @@ Inspired by [Jellyfin](https://jellyfin.org/), allows you to manage all your gam
# Preview

## 🖥 Desktop
<br>
<details>
<summary>Expand to preview</summary>

![Desktop home](.github/screenshots/home.png "RomM home")
![Desktop gallery](.github/screenshots/gallery.png "RomM gallery")
![Desktop details](.github/screenshots/details.png "RomM details")
![Desktop search](.github/screenshots/search.png "RomM search")

<details><summary>Video preview</summary><span>https://user-images.githubusercontent.com/34356590/227992371-33056130-c067-49c1-ae32-b3ba78db6798.mp4</span></details>
</details>
<br>

## 📱 Mobile
<br>
<details>
<summary>Expand to preview</summary>

![Mobile home](.github/screenshots/m_home.png "RomM home")
![Mobile gallery](.github/screenshots/m_gallery.png "RomM gallery")
![Mobile details](.github/screenshots/m_details.png "RomM details")
![Mobile search](.github/screenshots/m_search.png "RomM search")

<details><summary>Video preview</summary><span>https://user-images.githubusercontent.com/34356590/228007442-0a9cbf6b-4b62-4c1a-aad8-48b13e6337e8.mp4</span></details>
</details>
<br>

# Installation

Expand Down
32 changes: 32 additions & 0 deletions backend/alembic/versions/1.8.3_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""update to 1.8.3
Revision ID: 1.8.3
Revises: 1.8.2
Create Date: 2023-05-17 12:59:44.344356
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '1.8.3'
down_revision = '1.8.2'
branch_labels = None
depends_on = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("roms") as batch_op:
batch_op.execute("UPDATE roms SET file_path = REPLACE(file_path, '/romm/library/', '')")
batch_op.execute("UPDATE roms SET path_cover_s = REPLACE(path_cover_s, '/romm/resources/', '')")
batch_op.execute("UPDATE roms SET path_cover_l = REPLACE(path_cover_l, '/romm/resources/', '')")
batch_op.execute("UPDATE roms SET path_screenshots = REPLACE(path_screenshots, '/romm/resources/', '')")
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
4 changes: 2 additions & 2 deletions backend/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

# DEFAULT RESOURCES
DEFAULT_URL_COVER_L: str = "https://images.igdb.com/igdb/image/upload/t_cover_big/nocover.png"
DEFAULT_PATH_COVER_L: str = f"{RESOURCES_BASE_PATH}/default/default/cover/big.png"
DEFAULT_PATH_COVER_L: str = f"default/default/cover/big.png"
DEFAULT_URL_COVER_S: str = "https://images.igdb.com/igdb/image/upload/t_cover_small/nocover.png"
DEFAULT_PATH_COVER_S: str = f"{RESOURCES_BASE_PATH}/default/default/cover/small.png"
DEFAULT_PATH_COVER_S: str = f"default/default/cover/small.png"

# IGDB
CLIENT_ID: str = os.environ.get('CLIENT_ID')
Expand Down
29 changes: 11 additions & 18 deletions backend/endpoints/scan.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from fastapi import APIRouter, status, HTTPException
import emoji
import json

Expand All @@ -9,47 +8,41 @@
from models.platform import Platform
from models.rom import Rom

router = APIRouter()


@router.get("/scan", status_code=200)
def scan(platforms: str, complete_rescan: bool=False) -> dict:
async def scan(sid: str, platforms: str, complete_rescan: bool=True, sm=None):
"""Scan platforms and roms and write them in database."""

log.info(emoji.emojize(":magnifying_glass_tilted_right: Scanning "))
fs.store_default_resources()

# Scanning platforms
try:
try: # Scanning platforms
fs_platforms: list[str] = fs.get_platforms()
except PlatformsNotFoundException as e:
error: str = f"{e}"
log.warning(error)
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=error)
log.error(e); await sm.emit('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} {COLORS['reset']}"))
scanned_platform: Platform = fastapi.scan_platform(platform)
try:
scanned_platform: Platform = fastapi.scan_platform(platform)
except RomsNotFoundException as e:
log.error(e); continue
await sm.emit('scanning_platform', [scanned_platform.name, scanned_platform.slug]); await sm.emit('') # Workaround to emit in real-time
if platform != str(scanned_platform): log.info(f"Identified as {COLORS['blue']}{scanned_platform}{COLORS['reset']}")
dbh.add_platform(scanned_platform)

# Scanning roms
try:
fs_roms: list[str] = fs.get_roms(scanned_platform.fs_slug)
except RomsNotFoundException as e:
error: str = f"{e}"
log.warning(error)
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=error)
fs_roms: list[str] = fs.get_roms(scanned_platform.fs_slug)
for rom in fs_roms:
rom_id: int = dbh.rom_exists(scanned_platform.slug, rom['file_name'])
if rom_id and not complete_rescan: continue
await sm.emit('scanning_rom', rom['file_name']); await sm.emit('') # Workaround to emit in real-time
log.info(f"Scanning {COLORS['orange']}{rom['file_name']}{COLORS['reset']}")
if rom['multi']: [log.info(f"\t - {COLORS['orange_i']}{file}{COLORS['reset']}") for file in rom['files']]
scanned_rom: Rom = fastapi.scan_rom(scanned_platform, rom)
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.purge_platforms(fs_platforms)
return {'msg': 'Scan completed successfully!'}
await sm.emit('done')
32 changes: 32 additions & 0 deletions backend/handler/socket_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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)
11 changes: 10 additions & 1 deletion backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from fastapi.middleware.cors import CORSMiddleware

from config import DEV_PORT, DEV_HOST
from handler.socket_manager import SocketManager
from endpoints import scan, search, platform, rom

app = FastAPI()
Expand All @@ -13,15 +14,23 @@
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(scan.router)
app.include_router(search.router)
app.include_router(platform.router)
app.include_router(rom.router)

sm = SocketManager()
sm.mount_to("/ws", app)

async def scan_handler(*args): await scan.scan(*args, sm)
sm.on('scan', handler=scan_handler)


@app.on_event("startup")
def startup() -> None:
"""Startup application."""
pass


if __name__ == '__main__':
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)
4 changes: 2 additions & 2 deletions backend/utils/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class PlatformsNotFoundException(Exception):
def __init__(self):
self.message = f"Platforms not found"
self.message = f"Platforms not found. Check RomM folder structure here: https://github.com/zurdi15/romm#-folder-structure"
super().__init__(self.message)

def __repr__(self) -> str:
Expand All @@ -9,7 +9,7 @@ def __repr__(self) -> str:

class RomsNotFoundException(Exception):
def __init__(self, platform: str):
self.message = f"Roms not found for platform {platform}"
self.message = f"Roms not found for platform {platform}. Check RomM folder structure here: https://github.com/zurdi15/romm#-folder-structure"
super().__init__(self.message)

def __repr__(self) -> str:
Expand Down
4 changes: 4 additions & 0 deletions backend/utils/fastapi.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from fastapi import status, HTTPException

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 models.platform import Platform
from models.rom import Rom

Expand Down
2 changes: 1 addition & 1 deletion docker/init_scripts/init_back
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

cd /back
alembic upgrade head && uvicorn main:app --proxy-headers --host 0.0.0.0 --port 5000
alembic upgrade head && uvicorn main:app --proxy-headers --host 0.0.0.0 --port 5000 --workers 2
6 changes: 6 additions & 0 deletions docker/nginx/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,11 @@ http {
rewrite /api/(.*) /$1 break;
proxy_pass http://localhost:5000/;
}
location /ws {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
}
2 changes: 1 addition & 1 deletion frontend/.env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VITE_ROMM_VERSION=1.8.1
VITE_ROMM_VERSION=1.8.3
File renamed without changes.
Binary file added frontend/assets/platforms/doom.ico
Binary file not shown.
File renamed without changes.
File renamed without changes.
Binary file added frontend/assets/platforms/pc-98.ico
Binary file not shown.
File renamed without changes.
Binary file added frontend/assets/platforms/rpgmaker.ico
Binary file not shown.
Loading

0 comments on commit a71416c

Please sign in to comment.