66import requests
77from fastapi import HTTPException
88
9- from config import user_config , LIBRARY_BASE_PATH , HIGH_PRIO_STRUCTURE_PATH , RESERVED_FOLDERS , DEFAULT_URL_COVER_L , DEFAULT_PATH_COVER_L , DEFAULT_URL_COVER_S , DEFAULT_PATH_COVER_S
10- from models .platform import Platform
11- from models .rom import Rom
9+ 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
1210from handler import dbh
1311from logger .logger import log
1412
@@ -38,7 +36,6 @@ def get_platforms() -> list[str]:
3836 platforms : list [str ] = list (os .walk (f"{ LIBRARY_BASE_PATH } /roms" ))[0 ][1 ]
3937 else :
4038 platforms : list [str ] = list (os .walk (LIBRARY_BASE_PATH ))[0 ][1 ]
41- [platforms .remove (reserved ) for reserved in RESERVED_FOLDERS if reserved in platforms ]
4239 try :
4340 excluded_folders : list = user_config ['exclude' ]['folders' ]
4441 try :
@@ -159,19 +156,19 @@ def _cover_exists(p_slug: str, file_name: str, size: str) -> bool:
159156 Returns
160157 True if cover exists in filesystem else False
161158 """
162- logo_path : str = f"{ LIBRARY_BASE_PATH } /resources /{ p_slug } /{ file_name } _{ size } .png"
159+ logo_path : str = f"{ RESOURCES_BASE_PATH } /{ p_slug } /{ file_name } _{ size } .png"
163160 return True if os .path .exists (logo_path ) else False
164161
165162
166163def _get_cover_path (p_slug : str , file_name : str , size : str ) -> str :
167- """Returns platform logo filesystem path
164+ """Returns rom cover filesystem path adapted to frontend folder structure
168165
169166 Args:
170167 p_slug: short name of the platform
171168 file_name: name of rom file
172169 size: size of the cover -> big as 'l' | small as 's'
173170 """
174- return f"/assets/library/resources /{ p_slug } /{ file_name } _{ size } .png"
171+ return f"{ RESOURCES_BASE_PATH } /{ p_slug } /{ file_name } _{ size } .png"
175172
176173
177174def _store_cover (p_slug : str , file_name : str , url_cover : str , size : str ) -> None :
@@ -184,7 +181,7 @@ def _store_cover(p_slug: str, file_name: str, url_cover: str, size: str) -> None
184181 size: size of the cover -> big as 'l' | small as 's'
185182 """
186183 cover_file : str = f"{ file_name } _{ size } .png"
187- cover_path : str = f"{ LIBRARY_BASE_PATH } /resources /{ p_slug } /"
184+ cover_path : str = f"{ RESOURCES_BASE_PATH } /{ p_slug } /"
188185 sizes : dict = {'l' : 'big' , 's' : 'small' }
189186 res = requests .get (url_cover .replace ('t_thumb' , f't_cover_{ sizes [size ]} ' ), stream = True )
190187 if res .status_code == 200 :
0 commit comments