@@ -1,25 +1,23 @@
|
||||
import os
|
||||
import pathlib
|
||||
import yaml
|
||||
from yaml.loader import SafeLoader
|
||||
|
||||
|
||||
# Uvicorn
|
||||
DEV_PORT: int = 5000
|
||||
DEV_HOST: str = "0.0.0.0"
|
||||
|
||||
# PATHS
|
||||
LIBRARY_BASE_PATH: str = f"{pathlib.Path(__file__).parent.parent.parent.parent.resolve()}/library"
|
||||
ROMM_USER_CONFIG_PATH: str = f"{pathlib.Path(__file__).parent.parent.parent.parent.resolve()}/romm/config.yml"
|
||||
|
||||
# ROMM RESERVED FOLDERS
|
||||
RESERVED_FOLDERS: list = ['resources', 'database']
|
||||
LIBRARY_BASE_PATH: str = "/romm/library"
|
||||
ROMM_USER_CONFIG_PATH: str = "/romm/config.yml"
|
||||
SQLITE_DB_BASE_PATH: str = "/romm/database"
|
||||
HIGH_PRIO_STRUCTURE_PATH: str = f"{LIBRARY_BASE_PATH}/roms"
|
||||
RESOURCES_BASE_PATH: str = "/romm/resources"
|
||||
|
||||
# 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"/assets/library/resources/default/cover_l.png"
|
||||
DEFAULT_PATH_COVER_L: str = f"{RESOURCES_BASE_PATH}/default/cover_l.png"
|
||||
DEFAULT_URL_COVER_S: str = "https://images.igdb.com/igdb/image/upload/t_cover_small/nocover.png"
|
||||
DEFAULT_PATH_COVER_S: str = f"/assets/library/resources/default/cover_s.png"
|
||||
DEFAULT_PATH_COVER_S: str = f"{RESOURCES_BASE_PATH}/default/cover_s.png"
|
||||
|
||||
# IGDB
|
||||
CLIENT_ID: str = os.getenv('CLIENT_ID')
|
||||
|
||||
@@ -2,7 +2,7 @@ import os
|
||||
import sys
|
||||
from urllib.parse import quote_plus
|
||||
|
||||
from config import ROMM_DB_DRIVER, SUPPORTED_DB_DRIVERS, LIBRARY_BASE_PATH
|
||||
from config import ROMM_DB_DRIVER, SUPPORTED_DB_DRIVERS, SQLITE_DB_BASE_PATH
|
||||
from logger.logger import log
|
||||
|
||||
|
||||
@@ -23,9 +23,8 @@ def get_db_engine():
|
||||
return f"mariadb+mariadbconnector://{DB_USER}:%s@{DB_HOST}:{DB_PORT}/{DB_NAME}" % quote_plus(DB_PASSWD)
|
||||
|
||||
elif ROMM_DB_DRIVER == 'sqlite':
|
||||
SQLITE_PATH: str = f"{LIBRARY_BASE_PATH}/database"
|
||||
if not os.path.exists(SQLITE_PATH): os.makedirs(SQLITE_PATH)
|
||||
return f"sqlite:////{SQLITE_PATH}/romm.db"
|
||||
if not os.path.exists(SQLITE_DB_BASE_PATH): os.makedirs(SQLITE_DB_BASE_PATH)
|
||||
return f"sqlite:////{SQLITE_DB_BASE_PATH}/romm.db"
|
||||
|
||||
else:
|
||||
log.critical(f"Not supported {ROMM_DB_DRIVER} database")
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import functools
|
||||
import json
|
||||
|
||||
from fastapi import HTTPException
|
||||
from sqlalchemy import select
|
||||
|
||||
@@ -64,7 +64,7 @@ class IGDBHandler():
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
else:
|
||||
else: #TODO: improve API calls to make only one
|
||||
search_term: str = unidecode.unidecode(file_name_no_tags)
|
||||
if p_igdb_id:
|
||||
try:
|
||||
|
||||
@@ -75,7 +75,7 @@ async def platforms() -> dict:
|
||||
|
||||
|
||||
@app.put("/scan")
|
||||
async def scan(req: Request, overwrite: bool=False) -> dict:
|
||||
async def scan(req: Request, full_scan: bool=False, overwrite: bool=False) -> dict:
|
||||
"""Scan platforms and roms and write them in database."""
|
||||
|
||||
log.info("complete scaning...")
|
||||
@@ -84,10 +84,10 @@ async def scan(req: Request, overwrite: bool=False) -> dict:
|
||||
platforms: list[str] = data['platforms'] if data['platforms'] else fs.get_platforms()
|
||||
for p_slug in platforms:
|
||||
platform: Platform = fastapi.scan_platform(p_slug)
|
||||
roms: list[dict] = fs.get_roms(p_slug)
|
||||
roms: list[dict] = fs.get_roms(p_slug, full_scan)
|
||||
for rom in roms:
|
||||
fastapi.scan_rom(platform, rom)
|
||||
dbh.purge_roms(p_slug, roms)
|
||||
dbh.purge_roms(p_slug, fs.get_roms(p_slug, True))
|
||||
dbh.purge_platforms(fs.get_platforms())
|
||||
return {'msg': 'success'}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ def scan_platform(p_slug: str) -> Platform:
|
||||
platform_attrs: dict = igdbh.get_platform_details(p_slug)
|
||||
platform_attrs['slug'] = p_slug
|
||||
platform_attrs['logo_path'] = ''
|
||||
platform_attrs['n_roms'] = fs.get_roms(p_slug, only_amount=True)
|
||||
platform_attrs['n_roms'] = fs.get_roms(p_slug, True, only_amount=True)
|
||||
log.info(f"Platform n_roms: {platform_attrs['n_roms']}")
|
||||
platform = Platform(**platform_attrs)
|
||||
dbh.add_platform(platform)
|
||||
|
||||
@@ -6,7 +6,8 @@ from pathlib import Path
|
||||
import requests
|
||||
from fastapi import HTTPException
|
||||
|
||||
from config import user_config, LIBRARY_BASE_PATH, RESERVED_FOLDERS, DEFAULT_URL_COVER_L, DEFAULT_PATH_COVER_L, DEFAULT_URL_COVER_S, DEFAULT_PATH_COVER_S
|
||||
from config import user_config, LIBRARY_BASE_PATH, HIGH_PRIO_STRUCTURE_PATH, RESOURCES_BASE_PATH, DEFAULT_URL_COVER_L, DEFAULT_PATH_COVER_L, DEFAULT_URL_COVER_S, DEFAULT_PATH_COVER_S
|
||||
from handler import dbh
|
||||
from logger.logger import log
|
||||
|
||||
|
||||
@@ -35,7 +36,6 @@ def get_platforms() -> list[str]:
|
||||
platforms: list[str] = list(os.walk(f"{LIBRARY_BASE_PATH}/roms"))[0][1]
|
||||
else:
|
||||
platforms: list[str] = list(os.walk(LIBRARY_BASE_PATH))[0][1]
|
||||
[platforms.remove(reserved) for reserved in RESERVED_FOLDERS if reserved in platforms]
|
||||
try:
|
||||
excluded_folders: list = user_config['exclude']['folders']
|
||||
try:
|
||||
@@ -52,12 +52,11 @@ def get_platforms() -> list[str]:
|
||||
|
||||
# ========= Roms utils =========
|
||||
def _check_folder_structure(p_slug) -> tuple:
|
||||
if os.path.exists(f"{LIBRARY_BASE_PATH}/roms"):
|
||||
roms_path: str = f"{LIBRARY_BASE_PATH}/roms/{p_slug}"
|
||||
roms_files = list(os.walk(f"{LIBRARY_BASE_PATH}/roms/{p_slug}"))[0][2]
|
||||
else:
|
||||
roms_path: str = f"{LIBRARY_BASE_PATH}/{p_slug}/roms"
|
||||
roms_files = list(os.walk(f"{LIBRARY_BASE_PATH}/{p_slug}/roms"))[0][2]
|
||||
roms_path: str = f"{HIGH_PRIO_STRUCTURE_PATH}/{p_slug}" if os.path.exists(HIGH_PRIO_STRUCTURE_PATH) else f"{LIBRARY_BASE_PATH}/{p_slug}/roms"
|
||||
try:
|
||||
roms_files = list(os.walk(roms_path))[0][2]
|
||||
except IndexError:
|
||||
roms_files = []
|
||||
return roms_path, roms_files
|
||||
|
||||
|
||||
@@ -91,7 +90,7 @@ def parse_tags(file_name: str) -> tuple:
|
||||
return reg, rev, other_tags
|
||||
|
||||
|
||||
def get_roms(p_slug: str, only_amount: bool = False) -> list[dict]:
|
||||
def get_roms(p_slug: str, full_scan: bool, only_amount: bool = False) -> list[dict]:
|
||||
"""Gets all filesystem roms for a platform
|
||||
|
||||
Args:
|
||||
@@ -99,22 +98,21 @@ def get_roms(p_slug: str, only_amount: bool = False) -> list[dict]:
|
||||
only_amount: flag to return only amount of roms instead of all info
|
||||
Returns: list with all the filesystem roms for a platform found in the LIBRARY_BASE_PATH. Just the amount of them if only_amount=True
|
||||
"""
|
||||
try:
|
||||
roms: list[dict] = []
|
||||
roms_path, roms_files = _check_folder_structure(p_slug)
|
||||
roms_files = _exclude_files(roms_files)
|
||||
roms: list[dict] = []
|
||||
roms_path, roms_files = _check_folder_structure(p_slug)
|
||||
roms_files = _exclude_files(roms_files)
|
||||
|
||||
if only_amount: return len(roms_files)
|
||||
if only_amount: return len(roms_files)
|
||||
|
||||
for rom in roms_files:
|
||||
file_size: str = str(round(os.stat(f"{roms_path}/{rom}").st_size / (1024 * 1024), 2))
|
||||
file_extension: str = rom.split('.')[-1] if '.' in rom else ""
|
||||
reg, rev, other_tags = parse_tags(rom)
|
||||
roms.append({'file_name': rom, 'file_path': roms_path, 'file_size': file_size, 'file_extension': file_extension,
|
||||
'region': reg, 'revision': rev, 'tags': other_tags})
|
||||
log.info(f"Roms found for {p_slug}: {roms}")
|
||||
except IndexError:
|
||||
log.warning(f"Roms not found for {p_slug}")
|
||||
excluded_roms: list[str] = [rom.file_name for rom in dbh.get_roms(p_slug)]
|
||||
for rom in roms_files:
|
||||
if rom in excluded_roms and not full_scan: continue
|
||||
file_size: str = str(round(os.stat(f"{roms_path}/{rom}").st_size / (1024 * 1024), 2))
|
||||
file_extension: str = rom.split('.')[-1] if '.' in rom else ""
|
||||
reg, rev, other_tags = parse_tags(rom)
|
||||
roms.append({'file_name': rom, 'file_path': roms_path, 'file_size': file_size, 'file_extension': file_extension,
|
||||
'region': reg, 'revision': rev, 'tags': other_tags})
|
||||
log.info(f"Roms found for {p_slug}: {roms}")
|
||||
if only_amount: return 0
|
||||
return roms
|
||||
|
||||
@@ -158,19 +156,19 @@ def _cover_exists(p_slug: str, file_name: str, size: str) -> bool:
|
||||
Returns
|
||||
True if cover exists in filesystem else False
|
||||
"""
|
||||
logo_path: str = f"{LIBRARY_BASE_PATH}/resources/{p_slug}/{file_name}_{size}.png"
|
||||
logo_path: str = f"{RESOURCES_BASE_PATH}/{p_slug}/{file_name}_{size}.png"
|
||||
return True if os.path.exists(logo_path) else False
|
||||
|
||||
|
||||
def _get_cover_path(p_slug: str, file_name: str, size: str) -> str:
|
||||
"""Returns platform logo filesystem path
|
||||
"""Returns rom cover filesystem path adapted to frontend folder structure
|
||||
|
||||
Args:
|
||||
p_slug: short name of the platform
|
||||
file_name: name of rom file
|
||||
size: size of the cover -> big as 'l' | small as 's'
|
||||
"""
|
||||
return f"/assets/library/resources/{p_slug}/{file_name}_{size}.png"
|
||||
return f"{RESOURCES_BASE_PATH}/{p_slug}/{file_name}_{size}.png"
|
||||
|
||||
|
||||
def _store_cover(p_slug: str, file_name: str, url_cover: str, size: str) -> None:
|
||||
@@ -183,7 +181,7 @@ def _store_cover(p_slug: str, file_name: str, url_cover: str, size: str) -> None
|
||||
size: size of the cover -> big as 'l' | small as 's'
|
||||
"""
|
||||
cover_file: str = f"{file_name}_{size}.png"
|
||||
cover_path: str = f"{LIBRARY_BASE_PATH}/resources/{p_slug}/"
|
||||
cover_path: str = f"{RESOURCES_BASE_PATH}/{p_slug}/"
|
||||
sizes: dict = {'l': 'big', 's': 'small'}
|
||||
res = requests.get(url_cover.replace('t_thumb', f't_cover_{sizes[size]}'), stream=True)
|
||||
if res.status_code == 200:
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
- Now sqlite database location can be binded to ``/romm/database``. Check [docker-compose](docker/docker-compose.example.yml) example.
|
||||
- Now resources location (games cover) can be binded to ``/romm/resources``. Check [docker-compose](docker/docker-compose.example.yml) example.
|
||||
- More platforms support. Check [platforms support](https://github.com/zurdi15/romm#platforms-support)
|
||||
- Now RomM version appears in the bottom of the settings panel
|
||||
## Fixed
|
||||
- Download feature is now fixed for RomM structucture 1
|
||||
## Changed
|
||||
|
||||
@@ -10,7 +10,9 @@ RUN npm run build
|
||||
FROM ubuntu/nginx:1.18-22.04_edge as production-stage
|
||||
COPY --from=front-build-stage /front/dist /var/www/html
|
||||
COPY ./frontend/assets/platforms /var/www/html/assets/platforms
|
||||
RUN ln -s /library /var/www/html/assets/library
|
||||
RUN mkdir -p /var/www/html/assets/romm
|
||||
RUN ln -s /romm/library /var/www/html/assets/romm/library
|
||||
RUN ln -s /romm/resources /var/www/html/assets/romm/resources
|
||||
|
||||
# setup backend
|
||||
RUN apt update
|
||||
|
||||
@@ -14,8 +14,10 @@ services:
|
||||
- CLIENT_SECRET=<IGDB client secret>
|
||||
- STEAMGRIDDB_API_KEY=WIP
|
||||
volumes:
|
||||
- '/path/to/library:/library'
|
||||
- '/path/to/library:/romm/library'
|
||||
- '/path/to/resources:/romm/resources'
|
||||
- '/path/to/config.yml:/romm/config.yml'
|
||||
- '/path/to/database:/romm/database' # Only if ROMM_DB_DRIVER='sqlite' or ROMM_DB_DRIVER not exists
|
||||
ports:
|
||||
- '80:80'
|
||||
depends_on:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd /back
|
||||
uvicorn main:app --proxy-headers --host 0.0.0.0 --port 5000 --workers 2
|
||||
uvicorn main:app --proxy-headers --host 0.0.0.0 --port 5000 --workers 3
|
||||
1
frontend/.env
Normal file
@@ -0,0 +1 @@
|
||||
VITE_ROMM_VERSION='1.6.1'
|
||||
BIN
frontend/assets/platforms/3ds.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 7.2 KiB |
BIN
frontend/assets/platforms/amiga.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 21 KiB |
BIN
frontend/assets/platforms/arcade.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 15 KiB |
BIN
frontend/assets/platforms/atari.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 18 KiB |
BIN
frontend/assets/platforms/coleco.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 13 KiB |
BIN
frontend/assets/platforms/commodore.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 16 KiB |
BIN
frontend/assets/platforms/cpc.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 10 KiB |
BIN
frontend/assets/platforms/cps1.ico
Normal file
|
After Width: | Height: | Size: 111 KiB |
|
Before Width: | Height: | Size: 13 KiB |
BIN
frontend/assets/platforms/cps2.ico
Normal file
|
After Width: | Height: | Size: 111 KiB |
|
Before Width: | Height: | Size: 14 KiB |
BIN
frontend/assets/platforms/cps3.ico
Normal file
|
After Width: | Height: | Size: 111 KiB |
|
Before Width: | Height: | Size: 14 KiB |
BIN
frontend/assets/platforms/daphne.ico
Normal file
|
After Width: | Height: | Size: 121 KiB |
|
Before Width: | Height: | Size: 18 KiB |
BIN
frontend/assets/platforms/dc.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
BIN
frontend/assets/platforms/dos.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 14 KiB |
BIN
frontend/assets/platforms/fairchild.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 8.5 KiB |
BIN
frontend/assets/platforms/fba2012.ico
Normal file
|
After Width: | Height: | Size: 110 KiB |
|
Before Width: | Height: | Size: 15 KiB |
BIN
frontend/assets/platforms/fbneo.ico
Normal file
|
After Width: | Height: | Size: 110 KiB |
|
Before Width: | Height: | Size: 15 KiB |
BIN
frontend/assets/platforms/fds.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 14 KiB |
BIN
frontend/assets/platforms/gb.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 13 KiB |
BIN
frontend/assets/platforms/gba.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 13 KiB |
BIN
frontend/assets/platforms/gbc.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 14 KiB |
BIN
frontend/assets/platforms/genesis-slash-megadrive.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 16 KiB |
BIN
frontend/assets/platforms/gg.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 13 KiB |
BIN
frontend/assets/platforms/gw.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 14 KiB |
BIN
frontend/assets/platforms/intellivision.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 15 KiB |
BIN
frontend/assets/platforms/jaguar.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 13 KiB |
BIN
frontend/assets/platforms/lynx.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 11 KiB |
BIN
frontend/assets/platforms/md.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 13 KiB |
BIN
frontend/assets/platforms/megaduck.ico
Normal file
|
After Width: | Height: | Size: 110 KiB |
|
Before Width: | Height: | Size: 13 KiB |
BIN
frontend/assets/platforms/ms.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 11 KiB |
BIN
frontend/assets/platforms/msx.ico
Normal file
|
After Width: | Height: | Size: 109 KiB |
|
Before Width: | Height: | Size: 16 KiB |
BIN
frontend/assets/platforms/n64.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 398 KiB |
BIN
frontend/assets/platforms/nds.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 40 KiB |
BIN
frontend/assets/platforms/neocd.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 12 KiB |
BIN
frontend/assets/platforms/neogeo.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 10 KiB |
BIN
frontend/assets/platforms/nes.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 12 KiB |
BIN
frontend/assets/platforms/ngc.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 52 KiB |
BIN
frontend/assets/platforms/ngp.ico
Normal file
|
After Width: | Height: | Size: 105 KiB |
|
Before Width: | Height: | Size: 12 KiB |
BIN
frontend/assets/platforms/odyssey.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 12 KiB |
BIN
frontend/assets/platforms/pce.ico
Normal file
|
After Width: | Height: | Size: 108 KiB |
|
Before Width: | Height: | Size: 14 KiB |
BIN
frontend/assets/platforms/pcecd.ico
Normal file
|
After Width: | Height: | Size: 107 KiB |
|
Before Width: | Height: | Size: 13 KiB |
BIN
frontend/assets/platforms/pico.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 15 KiB |
BIN
frontend/assets/platforms/poke.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 20 KiB |
BIN
frontend/assets/platforms/ps.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 17 KiB |
BIN
frontend/assets/platforms/ps2.ico
Normal file
|
After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 75 KiB |