diff --git a/backend/src/utils/fs.py b/backend/src/utils/fs.py
index dc5466474..eda84353e 100644
--- a/backend/src/utils/fs.py
+++ b/backend/src/utils/fs.py
@@ -21,6 +21,10 @@ def store_default_resources() -> None:
# ========= Platforms utils =========
+def _exclude_platforms(platforms) -> list['str']:
+ [platforms.remove(excluded) for excluded in user_config['exclude']['platforms'] if excluded in platforms]
+
+
def get_platforms() -> list[str]:
"""Gets all filesystem platforms
@@ -30,7 +34,7 @@ def get_platforms() -> list[str]:
try:
platforms: list[str] = list(os.walk(HIGH_PRIO_STRUCTURE_PATH))[0][1] if os.path.exists(HIGH_PRIO_STRUCTURE_PATH) else list(os.walk(LIBRARY_BASE_PATH))[0][1]
try:
- [platforms.remove(excluded) for excluded in user_config['exclude']['folders'] if excluded in platforms]
+ _exclude_platforms(platforms)
except (KeyError, TypeError):
pass
return platforms
@@ -45,17 +49,65 @@ def _get_roms_structure(p_slug) -> tuple:
return f"{HIGH_PRIO_STRUCTURE_PATH}/{p_slug}" if os.path.exists(HIGH_PRIO_STRUCTURE_PATH) else f"{LIBRARY_BASE_PATH}/{p_slug}/roms"
-def _exclude_files(roms_files) -> list[str]:
+def _exclude_single_roms(roms) -> list[str]:
try:
- excluded_files: list = user_config['exclude']['files']
- filtered_files: list = []
- for file_name in roms_files:
- if file_name.split('.')[-1] in excluded_files:
- filtered_files.append(file_name)
- roms_files = [f for f in roms_files if f not in filtered_files]
+ excluded_extensions: list = []
+ excluded_extensions = user_config['exclude']['roms']['single_file']['extensions']
except (TypeError, KeyError):
- pass
- return roms_files
+ log.warning(f"Config file for excluding single file extensions malformed")
+ try:
+ excluded_names: list = []
+ excluded_names = user_config['exclude']['roms']['single_file']['names']
+ except (TypeError, KeyError):
+ log.warning(f"Config file for excluding single file game names malformed")
+ filtered_files: list = []
+ for rom in roms:
+ try:
+ if rom.split('.')[-1] in excluded_extensions or rom in excluded_names:
+ filtered_files.append(rom)
+ except TypeError:
+ log.warning(f"Config file is malformed")
+ roms = [f for f in roms if f not in filtered_files]
+ return roms
+
+
+def _exclude_multi_roms(roms) -> list[str]:
+ try:
+ excluded_names: list = []
+ excluded_names = user_config['exclude']['roms']['multi_file']['names']
+ except (TypeError, KeyError):
+ log.warning(f"Config file for excluding multi file game names malformed")
+ filtered_files: list = []
+ for rom in roms:
+ try:
+ if rom in excluded_names:
+ filtered_files.append(rom)
+ except TypeError:
+ log.warning(f"Config file is malformed")
+ roms = [f for f in roms if f not in filtered_files]
+ return roms
+
+
+def _exclude_multi_roms_parts(parts) -> list[str]:
+ try:
+ excluded_extensions: list = []
+ excluded_extensions = user_config['exclude']['roms']['multi_file']['parts']['extensions']
+ except (TypeError, KeyError):
+ log.warning(f"Config file for excluding multi file game parts extensions malformed")
+ try:
+ excluded_names: list = []
+ excluded_names = user_config['exclude']['roms']['multi_file']['parts']['names']
+ except (TypeError, KeyError):
+ log.warning(f"Config file for excluding multi file game parts names malformed")
+ filtered_files: list = []
+ for part in parts:
+ try:
+ if part.split('.')[-1] in excluded_extensions or part in excluded_names:
+ filtered_files.append(part)
+ except TypeError:
+ log.warning(f"Config file is malformed")
+ parts = [f for f in parts if f not in filtered_files]
+ return parts
def parse_tags(file_name: str) -> tuple:
@@ -80,7 +132,7 @@ def _get_file_extension(file: str) -> str:
def _get_rom_files(multi: bool, rom: str, roms_path: str) -> list[str]:
- return [] if not multi else _exclude_files(list(os.walk(f"{roms_path}/{rom}"))[0][2])
+ return [] if not multi else _exclude_multi_roms_parts(list(os.walk(f"{roms_path}/{rom}"))[0][2])
def _get_file_size(multi: bool, rom: str, files: list, roms_path:str) -> str:
@@ -102,14 +154,18 @@ def get_roms(p_slug: str, full_scan: bool, only_amount: bool = False) -> list[di
"""
roms_path = _get_roms_structure(p_slug)
roms: list[dict] = []
+
db_roms: list[str] = [rom.file_name for rom in dbh.get_roms(p_slug)]
- fs_roms: list[dict] = [{'multi': False, 'file': rom} for rom in _exclude_files(list(os.walk(roms_path))[0][2])] + \
- [{'multi': True, 'file': rom} for rom in list(os.walk(roms_path))[0][1]]
+
+ fs_single_roms: list[str] = list(os.walk(roms_path))[0][2]
+ fs_multi_roms: list[str] = list(os.walk(roms_path))[0][1]
+ fs_roms: list[dict] = [{'multi': False, 'file': rom} for rom in _exclude_single_roms(fs_single_roms)] + \
+ [{'multi': True, 'file': rom} for rom in _exclude_multi_roms(fs_multi_roms)]
if only_amount: return len(fs_roms)
for rom in fs_roms:
- if rom['file'] in db_roms and not full_scan: continue
+ if rom['file'] in db_roms and not full_scan and not rom['multi']: continue
reg, rev, other_tags = parse_tags(rom['file'])
file_extension: str = _get_file_extension(rom['file'])
files: list = _get_rom_files(rom['multi'], rom['file'], roms_path)
diff --git a/frontend/src/views/Details.vue b/frontend/src/views/Details.vue
index 943b96534..4d488bb72 100644
--- a/frontend/src/views/Details.vue
+++ b/frontend/src/views/Details.vue
@@ -178,7 +178,7 @@ async function deleteRom() {
Size
{{ rom.file_size }} MB
-
+
IGDB
{{ rom.r_igdb_id }}